Open martin-guthrie-docker opened 6 years ago
go.o: file not recognized: File format not recognized
very weird, looks like your toolchain is broken..
Are you sure that Target: mingw32
is an amd64 target? Please double-check the arch.
Note the GCC output above, it says Target mingw32. I googled around and saw that one could set environment variable MSYSTEM to mingw64, which I did, no change in result.
I am able to build other Go programs, specifically some easy tutorial go programs.
Here is full output,
Martin@MartinoOne ~ $ go version go version go1.10.3 windows/amd64
Martin@MartinoOne ~ $ gcc -v Using built-in specs. COLLECT_GCC=C:\MinGW\bin\gcc.exe COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe Target: mingw32 Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --with-gmp=/mingw --with-mpfr --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --enable-libgomp --disable-libvtv --enable-nls Thread model: win32 gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
Martin@MartinoOne ~ $ go install github.com/golang-ui/nuklear/nk /# github.com/go-gl/glfw/v3.2/glfw In file included from C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw\c_glfw_windows.go:6:0: C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function 'createMonitor': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:68:5: warning: implicit declaration of function 'wcscpy' [-Wimplicit-function-declaration] wcscpy(monitor->win32.adapterName, adapter->DeviceName); ^
~C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function '_glfwPlatformIsSameMonitor': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:228:9: warning: implicit declaration of function 'wcslen' [-Wimplicit-function-declaration] if (wcslen(first->win32.displayName)) ^~C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:229:16: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration] return wcscmp(first->win32.displayName, second->win32.displayName) == 0; ^~Martin@MartinoOne ~ $ go get github.com/golang-ui/nuklear/cmd/nk-example /# github.com/go-gl/glfw/v3.2/glfw In file included from C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw\c_glfw_windows.go:6:0: C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function 'createMonitor': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:68:5: warning: implicit declaration of function 'wcscpy' [-Wimplicit-function-declaration] wcscpy(monitor->win32.adapterName, adapter->DeviceName); ^
~C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function '_glfwPlatformIsSameMonitor': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:228:9: warning: implicit declaration of function 'wcslen' [-Wimplicit-function-declaration] if (wcslen(first->win32.displayName)) ^~C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:229:16: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration] return wcscmp(first->win32.displayName, second->win32.displayName) == 0; ^~/# github.com/golang-ui/nuklear/cmd/nk-example C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1 C:\Users\Martin\AppData\Local\Temp\go-link-702485631\go.o: file not recognized: File format not recognized collect2.exe: error: ld returned 1 exit status
okay I "think" I understand what the issue is.... The install of MinGW I have is for 32bit systems, but my machine is a 64bit system. I was lead to cygwin for MinGW 64bit version, and when I build in a cygwin shell, I get,
$ go get github.com/golang-ui/nuklear/cmd/nk-example /# github.com/go-gl/glfw/v3.2/glfw In file included from C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw\c_glfw_windows.go:6:0: C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function 'createMonitor': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:68:5: warning: implicit declaration of function 'wcscpy' [-Wimplicit-function-declaration] wcscpy(monitor->win32.adapterName, adapter->DeviceName); ^
~C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function '_glfwPlatformIsSameMonitor': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:228:9: warning: implicit declaration of function 'wcslen' [-Wimplicit-function-declaration] if (wcslen(first->win32.displayName)) ^~C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:229:16: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration] return wcscmp(first->win32.displayName, second->win32.displayName) == 0; ^~/# github.com/golang-ui/nuklear/cmd/nk-example C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1 /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingwex /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingw32 collect2: error: ld returned 1 exit status
So I think its an issue with using the "MinGW installer" link that is in the instructions, which is a 32bit gcc, versus my machine being 64bit. But I am just hypothesizing...
I was unable to find the missing files, and I suspect cygwin doesn't have these libs, so this may be a deeper make issue, which is beyond my pay grade...
I am willing to get to the bottom of this but I would need direction...
Based on all the experience I have, it seems that you've gone too far off the radar, the later errors are not common and it seems that your MinGW is totally broken.
It's important that Go's arch and GCC's arch match, you can get 64/64 or 32/32 on the same 64-bit machine, but they must match.
@martin-guthrie-docker Please remove any trace of MinGW/MSYS from your system and install by the steps from README:
MSYS 1.0: https://sourceforge.net/projects/mingw/files/latest/download
Thank you for the help.
I removed my previous MinGW, and installed new (64bit) one from this link,
https://sourceforge.net/projects/mingw-w64/?source=typ_redirect
I do start the batch file msys to get a console.
The result,
C:>go get github.com/golang-ui/nuklear/cmd/nk-example # github.com/go-gl/glfw/v3.2/glfw In file included from C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw\c_glfw_windows.go:6:0: C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function 'createMonitor': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:68:5: warning: implicit declaration of function 'wcscpy' [-Wimplicit-function-declaration] wcscpy(monitor->win32.adapterName, adapter->DeviceName); ^
~C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c: In function '_glfwPlatformIsSameMonitor': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:228:9: warning: implicit declaration of function 'wcslen' [-Wimplicit-function-declaration] if (wcslen(first->win32.displayName)) ^~C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/win32_monitor.c:229:16: warning: implicit declaration of function 'wcscmp' [-Wimplicit-function-declaration] return wcscmp(first->win32.displayName, second->win32.displayName) == 0; ^~# github.com/golang-ui/nuklear/cmd/nk-example C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1 C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o: In functionglfwSwapBuffers': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/context.c:609: undefined reference to
assert_func' C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o: In functionglfwExtensionSupported': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/context.c:642: undefined reference to
__assert_func' C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o: In functionglfwGetProcAddress': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/context.c:707: undefined reference to
assert_func' C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o: In functionglfwGetInputMode': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/input.c:153: undefined reference to
assert_func' C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o: In functionglfwSetInputMode': C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/input.c:174: undefined reference to
__assert_func' C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000007.o:C:\Users\Martin\go\src\github.com\go-gl\glfw\v3.2\glfw/glfw/src/input.c:262: more undefined references to `assert_func' follow C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000024.o: In function_cgo_cb1d4e13f0d1_C2func_calloc': /cygdrive/c/Users/Martin/AppData/Local/Temp/go-build054383554/b001/cgo-gcc-prolog:42: undefined reference to
errno' /cygdrive/c/Users/Martin/AppData/Local/Temp/go-build054383554/b001/cgo-gcc-prolog:44: undefined reference to `errno' C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000028.o: In functionnk_insert_window': C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:18504: undefined reference to
assert_func' C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:18505: undefined reference to__assert_func' C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:18499: undefined reference to
assert_func' C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:18498: undefined reference to__assert_func' C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000028.o: In function
nk_do_button': C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:14139: undefined reference to__assert_func' C:\Users\Martin\AppData\Local\Temp\go-link-060266583\000028.o:C:\Users\Martin\go\src\github.com\golang-ui\nuklear\nk/nuklear.h:14141: more undefined references to
__assert_func' follow collect2.exe: error: ld returned 1 exit status
It seems this is a known issue,
https://github.com/go-gl/glfw/issues/202 In that issue it says to select 686 target, but that is for 32bit...
I tried using msys2 from https://www.msys2.org but got the same result.
BTW, gcc version info:
C:>gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib ' Thread model: posix gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
Same here, undefined reference to __assert_func. I am using msys2 + go 1.12.
Getting this build error,
GCC:
Go: