Craft
Craft copied to clipboard
Compiling on Windows 7 with MinGW, missing symbols
OS: Windows 7 Ultimate 64-bit MinGW: 0.6.2-beta-20131004-1 CURL: curl-7.34.0-devel-mingw32 (manual install via zip file, installed in C:\Program Files\CURL) VS Studio 2013 Express is installed.
The first thing I had to do was add -DCURL_STATICLIB to add_definitions() so that make would stop complaining about missing CURL functions. I'm pretty sure that's because this CURL was compiled with static libs rather than dynamic libs.
Beyond that, no amount of adding -lws2_32 -lwsock32 to add_definitions() or any other combination to target_link_libraries(), or adding -LC:/MinGW/lib anywhere would resolve the apparently missing winsock functions.
I'll admit, my experience with compiling using MinGW on Windows is limited, so I'm really not sure what the linker is looking for and what I should provide it. Even adding -Wl,--print-map to the doesn't show what library it thinks it should be looking for.
So, does anyone know what I'm missing or what's missing from my system to make this compile?
C:\Users\Coding\Desktop\My Repo\development\not-minecraft\Craft-master>cmake -G "MinGW Makefiles" -- Found OpenGL: opengl32 -- Looking for include file pthread.h -- Looking for include file pthread.h - not found -- Found Threads: TRUE -- Found Doxygen: C:/Program Files (x86)/doxygen/bin/doxygen.exe (found version "1.7.4") -- Using Win32 for window creation -- Using WGL for context creation -- Found CURL: C:/Program Files/CURL/lib/libcurl.a (found version "7.34.0") -- Configuring done -- Generating done -- Build files have been written to: C:/Users/Coding/Desktop/My Repo/development/not-minecraft/Craft-master
C:\Users\Coding\Desktop\My Repo\development\not-minecraft\Craft-master>mingw32-make [ 2%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/clipboard.c.obj [ 5%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/context.c.obj [ 8%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/gamma.c.obj [ 11%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/init.c.obj [ 14%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/input.c.obj [ 17%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/joystick.c.obj [ 20%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/monitor.c.obj C:\Users\Coding\Desktop\My Repo\development\not-minecraft\Craft-master\deps\glfw\src\monitor.c: In function '_glfwCreateMonitor': C:\Users\Coding\Desktop\My Repo\development\not-minecraft\Craft-master\deps\glfw\src\monitor.c:181:5: warning: implicit declaration of function 'strdup' [-Wimplicit-function-declaration] monitor->name = strdup(name); ^ C:\Users\Coding\Desktop\My Repo\development\not-minecraft\Craft-master\deps\glfw\src\monitor.c:181:19: warning: assignment makes pointer from integer without acast [enabled by default] monitor->name = strdup(name); ^ [ 22%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/time.c.obj [ 25%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/window.c.obj [ 28%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/win32_clipboard.c.obj [ 31%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/win32_gamma.c.obj [ 34%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/win32_init.c.obj [ 37%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/win32_joystick.c.obj [ 40%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/win32_monitor.c.obj [ 42%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/win32_time.c.obj [ 45%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/win32_window.c.obj [ 48%] Building C object deps/glfw/src/CMakeFiles/glfw.dir/wgl_context.c.obj Linking C static library libglfw3.a [ 48%] Built target glfw Scanning dependencies of target craft [ 51%] Building C object CMakeFiles/craft.dir/src/auth.c.obj In file included from C:/Program Files/CURL/include/curl/curl.h:2283:0, from C:\Users\Coding\Desktop\My Repo\development\not-minecraft\Craft-master\src\auth.c:1: C:\Users\Coding\Desktop\My Repo\development\not-minecraft\Craft-master\src\auth.c: In function 'get_access_token': C:/Program Files/CURL/include/curl/typecheck-gcc.h:86:38: warning: call to '_curl_easy_setopt_err_cb_data' declared with attribute warning: curl_easy_setopt expects a private data pointer as argument for this option [enabled by default] _curl_easy_setopt_err_cb_data(); \
^
C:\Users\Coding\Desktop\My Repo\development\not-minecraft\Craft-master\src\auth.c:37:9: note: in expansion of macro 'curl_easy_setopt' curl_easy_setopt(curl, CURLOPT_WRITEDATA, response); ^ [ 54%] Building C object CMakeFiles/craft.dir/src/client.c.obj [ 57%] Building C object CMakeFiles/craft.dir/src/cube.c.obj [ 60%] Building C object CMakeFiles/craft.dir/src/db.c.obj [ 62%] Building C object CMakeFiles/craft.dir/src/item.c.obj [ 65%] Building C object CMakeFiles/craft.dir/src/main.c.obj [ 68%] Building C object CMakeFiles/craft.dir/src/map.c.obj [ 71%] Building C object CMakeFiles/craft.dir/src/matrix.c.obj [ 74%] Building C object CMakeFiles/craft.dir/src/ring.c.obj [ 77%] Building C object CMakeFiles/craft.dir/src/sign.c.obj [ 80%] Building C object CMakeFiles/craft.dir/src/util.c.obj [ 82%] Building C object CMakeFiles/craft.dir/src/world.c.obj [ 85%] Building C object CMakeFiles/craft.dir/deps/glew/src/glew.c.obj [ 88%] Building C object CMakeFiles/craft.dir/deps/lodepng/lodepng.c.obj [ 91%] Building C object CMakeFiles/craft.dir/deps/noise/noise.c.obj [ 94%] Building C object CMakeFiles/craft.dir/deps/sqlite/sqlite3.c.obj [ 97%] Building C object CMakeFiles/craft.dir/deps/tinycthread/tinycthread.c.obj
Linking C executable craft.exe
C:\Program Files\CURL\lib\libcurl.a(easy.o):(.text+0x16): undefined reference to WSAStartup@8' C:\Program Files\CURL\lib\libcurl.a(easy.o):(.text+0x39): undefined reference to
WSACleanup@0'
C:\Program Files\CURL\lib\libcurl.a(easy.o):(.text+0x21d): undefined reference to WSACleanup@0' c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Program Files\CURL\lib\libcurl.a(easy.o): bad reloc address 0x0 in section
.data'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\craft.dir\build.make:507: recipe for target 'craft.exe' failed
mingw32-make[2]: *** [craft.exe] Error 1
CMakeFiles\Makefile2:62: recipe for target 'CMakeFiles/craft.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/craft.dir/all] Error 2
Makefile:105: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
So, I finally got the code to compile. I had to change the cmake file to use the version of curl I compiled inside of msys. I'm still not sure why I was getting the undefined reference errors, especially since I was passing -I and -L at the correct places. I can't help but wonder if this wont be easier (from a compiling stand point) to just include each dependent library under deps/ and compiling it on the fly. Only thing I don't like about that is that OpenSSL takes forever to compile.
vadtec can you explain what you did?
@vadtec Could you explain your solution please? I am having this same issue.
Not sure what @vadtec did but I had the same issue on Windows 10. Here's what ended up working for me:
- Downloaded and unzipped curl-7.47.1.zip (version at time of this comment) from the top of page https://curl.haxx.se/download.html
- CD into the unzipped curl folder (mine was %USERPROFILE%\Desktop\curl-7.47.1\curl-7.47.1 because of where/how I extracted it but it doesn't matter where it is for now)
- Ran cmake -G "MinGW Makefiles" and then mingw32-make on cURL (lots of messages and failed tests but didn't seem to matter)
- Moved folder "%USERPROFILE%\Desktop\curl-7.47.1\curl-7.47.1" to "C:\Program Files (x86)" and renamed it to just "curl".
- Ran cmake -G "MinGW Makefiles" and then mingw32-make on Craft, just like in the instructions, which output craft.exe
- Got libcurl.dll missing error when trying to run craft.exe so I added "C:\Program Files (x86)\curl\lib" to my path and it ran.
Thank you @jasonkostempski ! That worked great! I had to run cmake -G "MinGW Makefiles" twice for both cmake and craft before mingw32-make would work properly, but it compiles great now.
For those who have found this issue: My total solution involves compiling each dependency manually using MinGW/msys on Windows. Once that is done, I tell cmake to look for my custom compiles over the system libs. It's not 100% fool proof, as sometimes cmake still uses the system libs, but that is a failing of the cmake search scripts. In those cases, I simply hard code the necessary paths/files to fix the issues.
Has anyone gotten Craft to compile with the precompiled mingw curl binaries at https://curl.haxx.se/download.html#Win32? (Win32 Generic - Win32 7zip 7.54.0 binary SSL SSH latest link at the time of this writing: https://bintray.com/artifact/download/vszakats/generic/curl-7.54.0-win32-mingw.7z)
I'm hitting similar errors with curl-7.54.0-win32-mingw.7z on Windows 10 extracted into C:\Program Files\CURL:
[ 25%] Linking C executable craft.exe
CMakeFiles\craft.dir/objects.a(auth.c.obj):auth.c:(.text+0xae): undefined reference to `_imp__curl_easy_init'
CMakeFiles\craft.dir/objects.a(auth.c.obj):auth.c:(.text+0x11a): undefined reference to `_imp__curl_easy_setopt'
CMakeFiles\craft.dir/objects.a(auth.c.obj):auth.c:(.text+0x189): undefined reference to `_imp__curl_easy_perform'
CMakeFiles\craft.dir/objects.a(auth.c.obj):auth.c:(.text+0x1a4): undefined reference to `_imp__curl_easy_getinfo'
CMakeFiles\craft.dir/objects.a(auth.c.obj):auth.c:(.text+0x1ad): undefined reference to `_imp__curl_easy_cleanup'
CMakeFiles\craft.dir/objects.a(main.c.obj):main.c:(.text.startup+0x27): undefined reference to `_imp__curl_global_init'
CMakeFiles\craft.dir/objects.a(main.c.obj):main.c:(.text.startup+0x768): undefined reference to `_imp__curl_global_cleanup'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\craft.dir\build.make:530: recipe for target 'craft.exe' failed
mingw32-make[2]: *** [craft.exe] Error 1
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/craft.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/craft.dir/all] Error 2
Makefile:128: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Command exited with code 2
...going to try building curl from scratch next.
for anyone else who has problems:
- try -DCURL_STATICLIB in the cmake file
- make sure you have the right version (i.e. 32 or 64 bit) of CURL.
- make sure the above is in your path
- if you get random "blah blah dll is not found (for me it was libcrypto)", just download them and stick them in your path. i even found some already on my system.