Mingw64 support ?
Hi,
Whenever I try to build HL from source on windows Mingw64 I get the following error:
hashlink\src\std\buffer.c:377:3: error: unsupported non-standard concatenation of string literals
377 | hl_buffer_str_sub(b, buf, usprintf(buf, 32, _PTR_FMT USTR("H"),(int_val)v));
| ^~~~~~~~~~~~~~~~~
mingw32-make[2]: *** [CMakeFiles\libhl.dir\build.make:273: CMakeFiles/libhl.dir/src/std/buffer.c.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:310: CMakeFiles/libhl.dir/all] Error 2
If you simply remove the USTR("H") do you get some other errors?
Sorry I was busy. I'm now back, i'll try your suggestion and report back later today.
Removing USTR did solved the original issue. Now it complains about missing library references:
src/std/socket.o:socket.c:(.text+0x128): undefined reference to `__imp_socket'
src/std/socket.o:socket.c:(.text+0x161): undefined reference to `__imp_socket'
src/std/socket.o:socket.c:(.text+0x199): undefined reference to `__imp_inet_addr'
src/std/socket.o:socket.c:(.text+0x1ba): undefined reference to `__imp_gethostbyname'
src/std/socket.o:socket.c:(.text+0x1e3): undefined reference to `__imp_inet_ntoa'
src/std/socket.o:socket.c:(.text+0x216): undefined reference to `__imp_gethostbyaddr'
src/std/socket.o:socket.c:(.text+0x258): undefined reference to `__imp_gethostname'
src/std/socket.o:socket.c:(.text+0x2ee): undefined reference to `__imp_accept'
src/std/socket.o:socket.c:(.text+0x358): undefined reference to `__imp_getpeername'
src/std/socket.o:socket.c:(.text+0x36e): undefined reference to `__imp_ntohs'
src/std/socket.o:socket.c:(.text+0x3b8): undefined reference to `__imp_getsockname'
src/std/socket.o:socket.c:(.text+0x3ce): undefined reference to `__imp_ntohs'
src/std/socket.o:socket.c:(.text+0x427): undefined reference to `__imp_setsockopt'
src/std/socket.o:socket.c:(.text+0x49f): undefined reference to `__imp_setsockopt'
src/std/socket.o:socket.c:(.text+0x4d5): undefined reference to `__imp_ioctlsocket'
src/std/socket.o:socket.c:(.text+0x510): undefined reference to `__imp_WSAStartup'
src/std/socket.o:socket.c:(.text+0x532): undefined reference to `__imp_closesocket'
src/std/socket.o:socket.c:(.text+0x57c): undefined reference to `__imp_recv'
src/std/socket.o:socket.c:(.text+0x5a7): undefined reference to `__imp_WSAGetLastError'
src/std/socket.o:socket.c:(.text+0x606): undefined reference to `__imp_recv'
src/std/socket.o:socket.c:(.text+0x629): undefined reference to `__imp_WSAGetLastError'
src/std/socket.o:socket.c:(.text+0x689): undefined reference to `__imp_htons'
src/std/socket.o:socket.c:(.text+0x6b3): undefined reference to `__imp_connect'
src/std/socket.o:socket.c:(.text+0x6bd): undefined reference to `__imp_WSAGetLastError'
src/std/socket.o:socket.c:(.text+0x720): undefined reference to `__imp_listen'
src/std/socket.o:socket.c:(.text+0x76b): undefined reference to `__imp_htons'
src/std/socket.o:socket.c:(.text+0x786): undefined reference to `__imp_bind'
src/std/socket.o:socket.c:(.text+0x7c8): undefined reference to `__imp_shutdown'
src/std/socket.o:socket.c:(.text+0x83b): undefined reference to `__imp_htons'
src/std/socket.o:socket.c:(.text+0x864): undefined reference to `__imp_sendto'
src/std/socket.o:socket.c:(.text+0x881): undefined reference to `__imp_WSAGetLastError'
src/std/socket.o:socket.c:(.text+0x8f4): undefined reference to `__imp_recvfrom'
src/std/socket.o:socket.c:(.text+0x915): undefined reference to `__imp_ntohs'
src/std/socket.o:socket.c:(.text+0x937): undefined reference to `__imp_WSAGetLastError'
src/std/socket.o:socket.c:(.text+0x992): undefined reference to `__imp_send'
src/std/socket.o:socket.c:(.text+0x9b0): undefined reference to `__imp_WSAGetLastError'
src/std/socket.o:socket.c:(.text+0x9ef): undefined reference to `__imp_send'
src/std/socket.o:socket.c:(.text+0xa04): undefined reference to `__imp_WSAGetLastError'
src/std/socket.o:socket.c:(.text+0xb48): undefined reference to `__imp_select'
src/std/socket.o:socket.c:(.text+0xb87): undefined reference to `__WSAFDIsSet'
src/std/socket.o:socket.c:(.text+0xbf0): undefined reference to `__WSAFDIsSet'
src/std/socket.o:socket.c:(.text+0xc43): undefined reference to `__WSAFDIsSet'
src/std/socket.o:socket.c:(.text+0xcc6): undefined reference to `__imp_select'
src/std/sys.o:sys.c:(.text+0x39b): undefined reference to `__imp__wstat32'
src/std/sys.o:sys.c:(.text+0x3bb): undefined reference to `__imp__wstat32'
src/std/sys.o:sys.c:(.text+0x43b): undefined reference to `__imp__wstat32'
collect2.exe: error: ld returned 1 exit status
I'm not sure if I need to rebuild some dependencies with the Mingw64 compiler.. Any help is welcome.. Thanks
On msvc you need to link wsock32.lib or something similar
Le jeu. 8 août 2019 à 17:36, Mel Massadian [email protected] a écrit :
Removing USTR did solved the original issue. Now it complains about missing library references:
src/std/socket.o:socket.c:(.text+0x128): undefined reference to
__imp_socket'src/std/socket.o:socket.c:(.text+0x161): undefined reference to__imp_socket'src/std/socket.o:socket.c:(.text+0x199): undefined reference to__imp_inet_addr' src/std/socket.o:socket.c:(.text+0x1ba): undefined reference to__imp_gethostbyname'src/std/socket.o:socket.c:(.text+0x1e3): undefined reference to__imp_inet_ntoa'src/std/socket.o:socket.c:(.text+0x216): undefined reference to__imp_gethostbyaddr' src/std/socket.o:socket.c:(.text+0x258): undefined reference to__imp_gethostname'src/std/socket.o:socket.c:(.text+0x2ee): undefined reference to__imp_accept'src/std/socket.o:socket.c:(.text+0x358): undefined reference to__imp_getpeername' src/std/socket.o:socket.c:(.text+0x36e): undefined reference to__imp_ntohs'src/std/socket.o:socket.c:(.text+0x3b8): undefined reference to__imp_getsockname'src/std/socket.o:socket.c:(.text+0x3ce): undefined reference to__imp_ntohs' src/std/socket.o:socket.c:(.text+0x427): undefined reference to__imp_setsockopt'src/std/socket.o:socket.c:(.text+0x49f): undefined reference to__imp_setsockopt'src/std/socket.o:socket.c:(.text+0x4d5): undefined reference to__imp_ioctlsocket' src/std/socket.o:socket.c:(.text+0x510): undefined reference to__imp_WSAStartup'src/std/socket.o:socket.c:(.text+0x532): undefined reference to__imp_closesocket'src/std/socket.o:socket.c:(.text+0x57c): undefined reference to__imp_recv' src/std/socket.o:socket.c:(.text+0x5a7): undefined reference to__imp_WSAGetLastError'src/std/socket.o:socket.c:(.text+0x606): undefined reference to__imp_recv'src/std/socket.o:socket.c:(.text+0x629): undefined reference to__imp_WSAGetLastError' src/std/socket.o:socket.c:(.text+0x689): undefined reference to__imp_htons'src/std/socket.o:socket.c:(.text+0x6b3): undefined reference to__imp_connect'src/std/socket.o:socket.c:(.text+0x6bd): undefined reference to__imp_WSAGetLastError' src/std/socket.o:socket.c:(.text+0x720): undefined reference to__imp_listen'src/std/socket.o:socket.c:(.text+0x76b): undefined reference to__imp_htons'src/std/socket.o:socket.c:(.text+0x786): undefined reference to__imp_bind' src/std/socket.o:socket.c:(.text+0x7c8): undefined reference to__imp_shutdown'src/std/socket.o:socket.c:(.text+0x83b): undefined reference to__imp_htons'src/std/socket.o:socket.c:(.text+0x864): undefined reference to__imp_sendto' src/std/socket.o:socket.c:(.text+0x881): undefined reference to__imp_WSAGetLastError'src/std/socket.o:socket.c:(.text+0x8f4): undefined reference to__imp_recvfrom'src/std/socket.o:socket.c:(.text+0x915): undefined reference to__imp_ntohs' src/std/socket.o:socket.c:(.text+0x937): undefined reference to__imp_WSAGetLastError'src/std/socket.o:socket.c:(.text+0x992): undefined reference to__imp_send'src/std/socket.o:socket.c:(.text+0x9b0): undefined reference to__imp_WSAGetLastError' src/std/socket.o:socket.c:(.text+0x9ef): undefined reference to__imp_send'src/std/socket.o:socket.c:(.text+0xa04): undefined reference to__imp_WSAGetLastError'src/std/socket.o:socket.c:(.text+0xb48): undefined reference to__imp_select' src/std/socket.o:socket.c:(.text+0xb87): undefined reference to__WSAFDIsSet'src/std/socket.o:socket.c:(.text+0xbf0): undefined reference to__WSAFDIsSet'src/std/socket.o:socket.c:(.text+0xc43): undefined reference to__WSAFDIsSet' src/std/socket.o:socket.c:(.text+0xcc6): undefined reference to__imp_select'src/std/sys.o:sys.c:(.text+0x39b): undefined reference to__imp__wstat32'src/std/sys.o:sys.c:(.text+0x3bb): undefined reference to__imp__wstat32' src/std/sys.o:sys.c:(.text+0x43b): undefined reference to__imp__wstat32'collect2.exe: error: ld returned 1 exit statusI'm not sure if I need to rebuild some dependencies with the Mingw64 compiler.. Any help is welcome.. Thanks
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HaxeFoundation/hashlink/issues/271?email_source=notifications&email_token=AAHZXQEXIVNRL4EEC3C53UTQDQ4QJA5CNFSM4IF3NHVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD34AN4I#issuecomment-519571185, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHZXQF7LC33REI77YAFRQDQDQ4QJANCNFSM4IF3NHVA .
For unicode strings on windows use -municode flag. For sockets -lwsock32 -lws2_32.
Clang using both Microsoft and MinGW SDK is unhappy with following in sources:
https://github.com/HaxeFoundation/hashlink/blob/9cc78b6a33a012cdd273957cf39d6ac5e6682b8b/src/std/buffer.c#L377
string literals with different character kinds cannot be concatenated
https://github.com/HaxeFoundation/hashlink/blob/9cc78b6a33a012cdd273957cf39d6ac5e6682b8b/libs/ui/ui_win.c#L233
expression must be a modifiable lvalue
https://github.com/HaxeFoundation/hashlink/blob/9cc78b6a33a012cdd273957cf39d6ac5e6682b8b/libs/ui/ui_win.c#L234
expression must be a modifiable lvalue
Shouldn't cmake already generate Makefile properly linking ws2_32 from CMakeLists.txt? https://github.com/HaxeFoundation/hashlink/blob/9cc78b6a33a012cdd273957cf39d6ac5e6682b8b/CMakeLists.txt#L142
Current versions of cmake will allow compiler vendor language extensions(pass std=gnu11 to minGW).
If strict C11 needed set(CMAKE_C_EXTENSIONS OFF) must be used.
https://github.com/HaxeFoundation/hashlink/blob/9cc78b6a33a012cdd273957cf39d6ac5e6682b8b/src/hl.h#L172
Must be if defined (HL_VCC) || defined (HL_MINGW) this will fix unsupported non-standard concatenation of string literals proper way.
And linking bug with wisock, wstat due to cmake trying to use 64 bit MinGW hashlink is not 64 bit yet. But it still doesn't build. Makefile generated with cmake -G "MinGW Makefiles" -DWITH_VIDEO=OFF and only 32 bit MinGW installed on system. Full log below:
Scanning dependencies of target libhl
[ 0%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre16_ord2utf16.c.obj
[ 1%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre16_valid_utf16.c.obj
[ 1%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_chartables.c.obj
[ 2%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_compile.c.obj
[ 2%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_dfa_exec.c.obj
[ 2%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_exec.c.obj
[ 3%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_fullinfo.c.obj
[ 3%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_globals.c.obj
[ 3%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_newline.c.obj
[ 4%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_string_utils.c.obj
[ 4%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_tables.c.obj
[ 4%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_ucd.c.obj
[ 5%] Building C object CMakeFiles/libhl.dir/include/pcre/pcre_xclass.c.obj
[ 5%] Building C object CMakeFiles/libhl.dir/src/alloc.c.obj
[ 6%] Building C object CMakeFiles/libhl.dir/src/std/array.c.obj
[ 6%] Building C object CMakeFiles/libhl.dir/src/std/buffer.c.obj
[ 6%] Building C object CMakeFiles/libhl.dir/src/std/bytes.c.obj
[ 7%] Building C object CMakeFiles/libhl.dir/src/std/cast.c.obj
[ 7%] Building C object CMakeFiles/libhl.dir/src/std/date.c.obj
[ 7%] Building C object CMakeFiles/libhl.dir/src/std/error.c.obj
[ 8%] Building C object CMakeFiles/libhl.dir/src/std/file.c.obj
[ 8%] Building C object CMakeFiles/libhl.dir/src/std/fun.c.obj
[ 8%] Building C object CMakeFiles/libhl.dir/src/std/maps.c.obj
[ 9%] Building C object CMakeFiles/libhl.dir/src/std/math.c.obj
[ 9%] Building C object CMakeFiles/libhl.dir/src/std/obj.c.obj
[ 9%] Building C object CMakeFiles/libhl.dir/src/std/process.c.obj
D:\yurii\Documents\HaxeThings\hashlink\src\std\process.c: In function 'hl_process_run':
D:\yurii\Documents\HaxeThings\hashlink\src\std\process.c:108:26: warning: passing argument 2 of 'CreateProcessA' from incompatible pointer type [-Wincompatible-pointer-types]
if( !CreateProcess(NULL,(uchar*)cmd,NULL,NULL,detached?FALSE:TRUE,detached?CREATE_NEW_CONSOLE:0,NULL,NULL,&sinf,&p->pinf) ) {
^~~~~~~~~~~
In file included from C:/Users/yurii/scoop/apps/gcc/current/i686-w64-mingw32/include/winbase.h:29,
from C:/Users/yurii/scoop/apps/gcc/current/i686-w64-mingw32/include/windows.h:70,
from D:/yurii/Documents/HaxeThings/hashlink/src/hl.h:214,
from D:\yurii\Documents\HaxeThings\hashlink\src\std\process.c:22:
C:/Users/yurii/scoop/apps/gcc/current/i686-w64-mingw32/include/processthreadsapi.h:118:77: note: expected 'LPSTR' {aka 'char *'} but argument is of type 'uchar *' {aka 'short unsigned int
*'}
WINBASEAPI WINBOOL WINAPI CreateProcessA (LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, WINBOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
~~~~~~^~~~~~~~~~~~~
[ 10%] Building C object CMakeFiles/libhl.dir/src/std/random.c.obj
[ 10%] Building C object CMakeFiles/libhl.dir/src/std/regexp.c.obj
[ 11%] Building C object CMakeFiles/libhl.dir/src/std/socket.c.obj
In file included from D:\yurii\Documents\HaxeThings\hashlink\src\std\socket.c:30:
C:/Users/yurii/scoop/apps/gcc/current/i686-w64-mingw32/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
#warning Please include winsock2.h before windows.h
^~~~~~~
[ 11%] Building C object CMakeFiles/libhl.dir/src/std/string.c.obj
[ 11%] Building C object CMakeFiles/libhl.dir/src/std/sys.c.obj
D:\yurii\Documents\HaxeThings\hashlink\src\std\sys.c: In function 'hl_sys_locale':
D:\yurii\Documents\HaxeThings\hashlink\src\std\sys.c:132:12: warning: implicit declaration of function 'GetSystemDefaultLocaleName'; did you mean 'GetSystemDefaultUILanguage'? [-Wimplicit-function-declaration]
int len = GetSystemDefaultLocaleName(loc,LOCALE_NAME_MAX_LENGTH);
^~~~~~~~~~~~~~~~~~~~~~~~~~
GetSystemDefaultUILanguage
D:\yurii\Documents\HaxeThings\hashlink\src\std\sys.c: In function 'hl_sys_full_path':
D:\yurii\Documents\HaxeThings\hashlink\src\std\sys.c:547:37: warning: passing argument 2 of 'FindFirstFileW' from incompatible pointer type [-Wincompatible-pointer-types]
if ((handle = FindFirstFileW(out, &data)) != INVALID_HANDLE_VALUE) {
^~~~~
In file included from C:/Users/yurii/scoop/apps/gcc/current/i686-w64-mingw32/include/winbase.h:18,
from C:/Users/yurii/scoop/apps/gcc/current/i686-w64-mingw32/include/windows.h:70,
from D:/yurii/Documents/HaxeThings/hashlink/src/hl.h:214,
from D:\yurii\Documents\HaxeThings\hashlink\src\std\sys.c:22:
C:/Users/yurii/scoop/apps/gcc/current/i686-w64-mingw32/include/fileapi.h:61:83: note: expected 'LPWIN32_FIND_DATAW' {aka 'struct _WIN32_FIND_DATAW *'} but argument is of type 'WIN32_FIND_DATA *' {aka 'struct _WIN32_FIND_DATAA *'}
WINBASEAPI HANDLE WINAPI FindFirstFileW (LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData);
~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
[ 12%] Building C object CMakeFiles/libhl.dir/src/std/thread.c.obj
[ 12%] Building C object CMakeFiles/libhl.dir/src/std/track.c.obj
[ 12%] Building C object CMakeFiles/libhl.dir/src/std/types.c.obj
[ 13%] Building C object CMakeFiles/libhl.dir/src/std/ucs2.c.obj
[ 13%] Linking C shared library bin\liblibhl.dll
CMakeFiles\libhl.dir/objects.a(sys.c.obj):sys.c:(.text+0x70): undefined reference to `GetSystemDefaultLocaleName'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles\libhl.dir\build.make:630: bin/liblibhl.dll] Error 1
make[1]: *** [CMakeFiles\Makefile2:992: CMakeFiles/libhl.dir/all] Error 2
make: *** [Makefile:162: all] Error 2
Any ideas?
Mingw-w64 8.1 lacks winnls.h (scoop and win-builds distro tested) so function GetSystemDefaultLocaleName is indeed not defined.
MSYS2 provides Mingw 9, so I switched to cmake -G "MSYS Makefiles" -DWITH_VIDEO=OFF -DBUILD_TESTING=OFF
New one is:
D:/yurii/Documents/HaxeThings/hashlink/src/jit.c: In function 'hl_jit_function':
D:/yurii/Documents/HaxeThings/hashlink/src/jit.c:3936:21: error: 'setjmp' undeclared (first use in this function); did you mean '_setjmp'?
3936 | call_native(ctx,setjmp,size);
| ^~~~~~
| _setjmp
D:/yurii/Documents/HaxeThings/hashlink/src/jit.c:3936:21: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [CMakeFiles/hl.dir/build.make:76: CMakeFiles/hl.dir/src/jit.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:138: CMakeFiles/hl.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
C:\msys64\mingw32\i686-w64-mingw32\include\setjmp.h and C:\msys64\mingw32\i686-w64-mingw32\include\setjmpex.h both exist but not included. Most likely more defines somewhere.
Now that one is really bad. All is included and executed https://github.com/HaxeFoundation/hashlink/blob/9cc78b6a33a012cdd273957cf39d6ac5e6682b8b/src/hl.h#L831 But extensive network of defines in MinGW header fails to find correct setjmp implementation. It's _setjmp because msvc told me setjmp expand to _setjmp. I will stop this here because problem is not in hashlink source anymore. But if somebody will want to continue. Next one will be undefined reference to `WinMain@16'. Cmake generated commands without -municode compiler flag.
I filled support request here https://sourceforge.net/p/mingw-w64/support-requests/150/ Because I don't know if it's bug or intentional design.
Small update to celebrate 64 bit support. Not going to happen now until:
a) hashlink repo will provide full source of all third party dependencies (current sources are stripped and contains precompiled binaries include/turbojpeg/x64/simd.lib This is not going to work for x64 mingw)
b) cmake files modified to use pkg-config, and your mingw distribution provides all dependencies (This is not true for most linux distos. Debian broke pkg-config wrapper and derivatives pulled it in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930492
mingw version of libuv for Win32 threads missing in most distros https://repology.org/project/mingw:libuv/versions ).