Re: [Mingw-w64-public] C++ code using Microsoft ATL (Active Template Library)
El día Friday, March 08, 2019 a las 09:00:27PM +0800, Liu Hao escribió: > 在 2019/3/8 20:43, Matthias Apitz 写道: > > > > Hello, > > > > The next DLL I have to recompile for 64-bit was written on top of some > > packages Microsoft ATL (Active Template Library), which includes the > > header atlbase.h with VC++. Is there anything for this in MinGW? > > > > No. But you may want to have a look at the one in ReactOS [1] which is > supposed to compile with both MSVC and GCC. > > [1] https://github.com/reactos/reactos/blob/master/sdk/lib/atl/atlbase.h Thanks for the pointer. All that DLL is only made from one small C++ file and when I do read it right it does not make use of ATL, but only of a CString class provided there. Maybe we should rewrite it better with std::string? It serves only for the Java app to write bytes to some serial device. matthias Serout.cpp #include #include #include "sisis_lib_serout_Serout.h" bool WriteComPort(CString PortSpecifier, CString portInformation, jbyte* data, jsize size); void AdustDCB(CString portInformation, DCB* dcb); JNIEXPORT jint JNICALL Java_sisis_lib_serout_Serout_SeroutC (JNIEnv* env, jclass c, jstring jPort, jbyteArray array) { CString portSpecifier((char *) env->GetStringChars(jPort, 0)); CString portInformation = portSpecifier.Right(portSpecifier.GetLength() - portSpecifier.Find(":", 0) - 1); portSpecifier.Truncate(portSpecifier.Find(":", 0)); jbyte* data = env->GetByteArrayElements(array, NULL); jsize size = env->GetArrayLength(array); if (data != NULL && size > 0) { bool res = WriteComPort(portSpecifier, portInformation, data, size); env->ReleaseByteArrayElements(array, data, JNI_ABORT); } return JNI_FALSE; } bool WriteComPort(CString PortSpecifier, CString portInformation, jbyte* data, jsize size) { DCB dcb; DWORD byteswritten; HANDLE hPort = CreateFile( PortSpecifier, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL ); if (!GetCommState(hPort, &dcb)) return false; AdustDCB(portInformation, &dcb); if (!SetCommState(hPort, &dcb)) return false; bool retVal = WriteFile(hPort, data, size, &byteswritten, NULL); CloseHandle(hPort); //close the handle return retVal; } void AdustDCB(CString properties, DCB* dcb) { int curpos = 0; CString token; token = properties.Tokenize(",", curpos); if (!token.IsEmpty()) { dcb->BaudRate = _ttoi(token); } token = properties.Tokenize(",", curpos); if (!token.IsEmpty()) { // Parity(N = No, E = Even, O = Odd, M = Mark, S = Space if (token.Compare("N") == NULL) { dcb->Parity = NOPARITY; } else if (token == 'E') { dcb->Parity = EVENPARITY; } else if (token == 'O') { dcb->Parity = ODDPARITY; } else if (token == 'M') { dcb->Parity = MARKPARITY; } else if (token == 'S') { dcb->Parity = SPACEPARITY; } } token = properties.Tokenize(",", curpos); if (!token.IsEmpty()) { // ByteSize dcb->ByteSize = _ttoi(token); } token = properties.Tokenize(",", curpos); if (!token.IsEmpty()) { // StopBit dcb->ByteSize = _ttoi(token); } } -- Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] C++ code using Microsoft ATL (Active Template Library)
Hello, The next DLL I have to recompile for 64-bit was written on top of some packages Microsoft ATL (Active Template Library), which includes the header atlbase.h with VC++. Is there anything for this in MinGW? For more details see also: https://stackoverflow.com/questions/3898287/c-include-atlbase-h-is-not-found Thanks matthias -- Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub October, 7 -- The GDR was different: Peace instead of Bundeswehr and wars, Druschba instead of Nazis, to live instead of to survive. ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] DLL produced by Mingw-w64 can't be loaded
El día Thursday, March 07, 2019 a las 09:36:28AM +0100, Vincent Torri escribió: > > Below is the (very short) list of missing pieces which I can't see on my > > Windows file system. > > > > Any ideas? > > - - > > -- > > [ ? ] LIBGCC_S_SEH-1.DLL Error opening file. > > Das System kann die angege > > [ ? ] LIBSTDC++-6.DLLError opening file. > > Das System kann die angege > > those 2 files are in your gcc installation directory. They must be > copied in the directory of your DLL > > > [D? ] API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL Error opening file. > > Das System kann die angege > > [D? ] API-MS-WIN-CORE-WINRT-L1-1-0.DLL Error opening file. > > Das System kann die angege > > [D? ] API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL Error opening file. > > Das System kann die angege > > [D? ] API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLLError opening file. > > Das System kann die angege > > [D? ] DCOMP.DLL Error opening file. > > Das System kann die angege > > [D? ] IESHIMS.DLLError opening file. > > Das System kann die angege > > these above should be part of Windows. > > normally you only need to copy the 2 above gcc dll where your dll is located. I've copied the following DLLs into the place where my DLL SiPrinter.dll is: -rwxr-xr-x+ 1 apitzm Domain Users 354545 7. Mrz 08:27 SiPrinter.dll -rwxr-xr-x+ 1 apitzm Domain Users 78848 7. Mrz 09:53 libgcc_s_seh-1.dll -rwxr-xr-x+ 1 apitzm Domain Users 1407488 7. Mrz 09:54 libstdc++-6.dll -rwxr-xr-x+ 1 apitzm Domain Users 53779 7. Mrz 09:58 libwinpthread-1.dll And this made the Java DLL loader happy. Thanks Re/ crosscompiling: I'm used to do so on FreeBSD amd64 for x86 target, but never compiled something on FreeBSD/Linux for Windows. The CPP files here in question were written years ago with some Microsoft Visual Studio (at least some artefacts around the CPP files say so). I think, it's enough and easy to write some makefiles in addition and if I could integrate this in our Jenkins CI on Linux this would be the finest solution. matthias -- Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub October, 7 -- The GDR was different: Peace instead of Bundeswehr and wars, Druschba instead of Nazis, to live instead of to survive. ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] DLL produced by Mingw-w64 can't be loaded
El día Wednesday, March 06, 2019 a las 11:20:05AM -0800, David Grayson escribió: > Your experience matches mine: the Cygwin ldd utility does not work properly > with MinGW DLLs and prints a bunch of question marks. There is an ntldd > utility you can use instead. If it's not on your path already, I'm not > sure the best way to obtain it. I just use MSYS2, because it's basically a > fork of Cygwin that makes it easy to install MinGW compilers and all the > other open source utilities you would need to build software on Linux, > including ntldd. > > --David David, thanks for your reply. Does this mean I could move to a Linux system with Mingw-w64 to produce the DLL for Windows there? This would be the first option as I do know less as nothing about Windows, but 30++ years about UNIX :-) This also would allow to produce the DLL together with the Java software on our Jenkins server hosted on Linux... Re/ my problem "Can't find dependent libraries." from the Java DLL loader, I found a thread in stackoverflow https://stackoverflow.com/questions/6092200/how-to-fix-an-unsatisfiedlinkerror-cant-find-dependent-libraries-in-a-jni-pro/6092576#6092576 with a hint to a tool which analyses the DLL for missing dependencie (etc.) Below is the (very short) list of missing pieces which I can't see on my Windows file system. Any ideas? Thanks matthias $ cut -c1-100 short.txt | Module List |* * * * Legend: D Delay Load Module ? Missing Module 6 64-bit Module * * * Dynamic Module ! Invalid Module * *E Import/Export Mismatch or Load Failure * * * Module File Time Stamp Link Time Stamp File Size - - -- [ ? ] LIBGCC_S_SEH-1.DLL Error opening file. Das System kann die angege [ ? ] LIBSTDC++-6.DLLError opening file. Das System kann die angege [D? ] API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL Error opening file. Das System kann die angege [D? ] API-MS-WIN-CORE-WINRT-L1-1-0.DLL Error opening file. Das System kann die angege [D? ] API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL Error opening file. Das System kann die angege [D? ] API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLLError opening file. Das System kann die angege [D? ] DCOMP.DLL Error opening file. Das System kann die angege [D? ] IESHIMS.DLLError opening file. Das System kann die angege [ 6] API-MS-WIN-CORE-THREADPOOL-L1-1-0.DLL 09.01.2019 04:06 09.01.2019 04:07 4.608 [D 6] DWMAPI.DLL 09.07.2015 18:58 09.07.2015 18:53 82.944 [DE6] ESENT.DLL 11.03.2011 07:33 11.03.2011 07:22 2.565.632 ... -- Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub October, 7 -- The GDR was different: Peace instead of Bundeswehr and wars, Druschba instead of Nazis, to live instead of to survive. ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
[Mingw-w64-public] DLL produced by Mingw-w64 can't be loaded
Hello, We have some bigger Java applications running as fat clients on Windows PC. These clients are using some Windows services, for example for printing, through some DLL written in C++ many years ago and then only compiled as 32-bit DLL. Moving forward to OpenJDK 1.8 with a 64-bit JRE we now struggle with compiling these DLL to a 64-bit version and I proposed here in my company to give mingw-w64 a try. I installed the recent version of mingw-w64 into Cygwin and can produce the 64-bit DLL this way (more or less without going through all details): LANG=C export LANG CC=/usr/bin/x86_64-w64-mingw32-gcc.exe DLL=SiPrinter_x64.dll for i in *.cpp; do ${CC} -I/home/apitzm/jdk1.8.0_202/include -I/home/apitzm/jdk1.8.0_202/include/win32 -c ${i} done ${CC} -shared -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -o ${DLL} *.o -lwinspool -lstdc++ -lgdi32 -lcomdlg32 The resulting SiPrinter_x64.dll causes in Java a class loader exception because there is someting missing: $ ldd SiPrinter_x64.dll ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x7789) kernel32.dll => /cygdrive/c/Windows/system32/kernel32.dll (0x) KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll (0x7fefd66) ??? => ??? (0x6964) ^^^ and the loader exception is: java.lang.UnsatisfiedLinkError: C:\Users\apitzm\vb\SunRise\SRv70\Ausleih-Client\bin\SiPrinter.dll: Can't find dependent libraries at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at sisis.util.Printer.(Printer.java:67) at sisis.lib.drucker.GDIDrucker.(GDIDrucker.java:132) at sisis.app.btc.BTCApp.initDrucker(BTCApp.java:3419) at sisis.app.btc.BTCApp.(BTCApp.java:2840) at sisis.app.btc.BTCApp.main(BTCApp.java:1865) Exception: System.loadLibrary() What is missing in the DLL, also seen as a problem by the ldd-command? Thanks matthias -- Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public