I wrote simple apps with Openssl in C and C++. I compile them like this:
gcc openssltest.c -o openssltest -lcrypto
g++ openssltest.cpp -o openssltest -lcrypto
And its all ok but only, when you have Openssl installed.
I would like to compile it that I can run them on OS where theres no Openssl installend (linux-like OS). I tried this:
gcc -c openssltest.c -lcrypto -static
gcc openssltest.o -o openssltest -lcrypto -static
and same for C++:
g++ -c openssltest.cpp -lcrypto -static
g++ openssltest.o -o openssltest -lcrypto -static
But have those errors:
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x19): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x2c): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x37): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x354): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
(.text+0x3fb): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x474): undefined reference to `dlsym'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
(.text+0x52e): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x5a2): undefined reference to `dlopen'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x60b): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
(.text+0x638): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x6cd): undefined reference to `dladdr'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
(.text+0x731): undefined reference to `dlerror'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
(.text+0x78a): undefined reference to `dlclose'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x4d): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_free':
(.text+0x6b): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x284): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_ctrl':
(.text+0x342): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_expand_block':
(.text+0x411): undefined reference to `inflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_compress_block':
(.text+0x4ca): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x51f): undefined reference to `inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_finish':
(.text+0x528): undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x5d7): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `zlib_stateful_init':
(.text+0x659): undefined reference to `deflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x893): undefined reference to `inflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x90d): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_read':
(.text+0x97c): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xa6f): undefined reference to `deflate'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xaec): undefined reference to `zError'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libcrypto.a(c_zlib.o): In function `bio_zlib_write':
(.text+0xb7e): undefined reference to `deflateInit_'
collect2: error: ld returned 1 exit status
How can I make this? I remember that a while ago I did this but now, erm, forgot how to do it. Im on Ubuntu 13.04 x64 - can it be an issue?
I had a similar issue trying to statically compile a simple DES program using the openssl lib. I used -lcrypto -lz -ldl -static-libgcc and it worked for me. No warnings or errors.
You need to be aware that libraries need to availiable as statically linked *.a files. If they are not, then compilation will either fail or you end up with a dynamically linked executable.
If this gets too much PITA (all the libraries dependencies need to be statically compiled to, and their deps too and so on) use something like buildroot
A hotfix: try to link in libdl statically, too.
If this not works, IMHO your libcrypto.a is bad compiled.
I had the same problem as you. Here's the command that solved it for me:
gcc yourfile.c -o yourfile -static -lcrypto -lz -ldl
It generates this warning:
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup': (.text+0x1b): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
but the executable still works.
Related
I just installed GLFW3 on Ubuntu and I'm testing the example code from the documentation (http://www.glfw.org/documentation.html) and I got those errors.
I tried multiples thing like adding -ldl, but nothing seems to work.
Here is the error log (GCC):
g++ -o bin/Debug/Game obj/Debug/main.o -ldl -lglfw3 -lm -lGL -lGLU
//usr/local/lib/libglfw3.a(vulkan.c.o): In function `_glfwInitVulkan':
vulkan.c:(.text+0x42): undefined reference to `dlopen'
vulkan.c:(.text+0xa9): undefined reference to `dlsym'
//usr/local/lib/libglfw3.a(vulkan.c.o): In function `_glfwTerminateVulkan':
vulkan.c:(.text+0x382): undefined reference to `dlclose'
//usr/local/lib/libglfw3.a(vulkan.c.o): In function `glfwGetInstanceProcAddress':
vulkan.c:(.text+0x72f): undefined reference to `dlsym'
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `translateKeyCode':
x11_init.c:(.text+0x6a): undefined reference to `XkbKeycodeToKeysym'
x11_init.c:(.text+0x14a): undefined reference to `XkbKeycodeToKeysym'
x11_init.c:(.text+0x177): undefined reference to `XGetKeyboardMapping'
x11_init.c:(.text+0x191): undefined reference to `XFree'
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `createKeyTables':
x11_init.c:(.text+0xc3e): undefined reference to `XkbGetMap'
x11_init.c:(.text+0xc61): undefined reference to `XkbGetNames'
x11_init.c:(.text+0x137f): undefined reference to `XkbFreeNames'
x11_init.c:(.text+0x1395): undefined reference to `XkbFreeKeyboard'
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `hasUsableInputMethodStyle':
x11_init.c:(.text+0x14b2): undefined reference to `XGetIMValues'
x11_init.c:(.text+0x150c): undefined reference to `XFree'
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `getSupportedAtom':
x11_init.c:(.text+0x155b): undefined reference to `XInternAtom'
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `detectEWMH':
x11_init.c:(.text+0x15ea): undefined reference to `XInternAtom'
x11_init.c:(.text+0x1610): undefined reference to `XInternAtom'
x11_init.c:(.text+0x1678): undefined reference to `XFree'
x11_init.c:(.text+0x16a1): undefined reference to `XFree'
x11_init.c:(.text+0x16ad): undefined reference to `XFree'
x11_init.c:(.text+0x16be): undefined reference to `XFree'
x11_init.c:(.text+0x16ca): undefined reference to `XFree'
//usr/local/lib/libglfw3.a(x11_init.c.o):x11_init.c:(.text+0x190d): more undefined references to `XFree' follow
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `initExtensions':
x11_init.c:(.text+0x194e): undefined reference to `dlopen'
x11_init.c:(.text+0x1993): undefined reference to `dlsym'
x11_init.c:(.text+0x19c1): undefined reference to `dlsym'
x11_init.c:(.text+0x19ef): undefined reference to `dlsym'
x11_init.c:(.text+0x1a1d): undefined reference to `dlsym'
x11_init.c:(.text+0x1a8b): undefined reference to `dlopen'
x11_init.c:(.text+0x1ad0): undefined reference to `dlsym'
x11_init.c:(.text+0x1afe): undefined reference to `dlsym'
x11_init.c:(.text+0x1b56): undefined reference to `XQueryExtension'
x11_init.c:(.text+0x1bdf): undefined reference to `dlopen'
x11_init.c:(.text+0x1c24): undefined reference to `dlsym'
x11_init.c:(.text+0x1c52): undefined reference to `dlsym'
x11_init.c:(.text+0x1c80): undefined reference to `dlsym'
x11_init.c:(.text+0x1cae): undefined reference to `dlsym'
x11_init.c:(.text+0x1cdc): undefined reference to `dlsym'
//usr/local/lib/libglfw3.a(x11_init.c.o):x11_init.c:(.text+0x1d0a): more undefined references to `dlsym' follow
//usr/local/lib/libglfw3.a(x11_init.c.o): In function `initExtensions':
x11_init.c:(.text+0x214a): undefined reference to `dlopen'
x11_init.c:(.text+0x218f): undefined reference to `dlsym'
x11_init.c:(.text+0x21bd): undefined reference to `dlsym'
x11_init.c:(.text+0x21eb): undefined reference to `dlsym'
x11_init.c:(.text+0x220d): undefined reference to `dlopen'
x11_init.c:(.text+0x2252): undefined reference to `dlsym'
x11_init.c:(.text+0x2280): undefined reference to `dlsym'
x11_init.c:(.text+0x22ae): undefined reference to `dlsym'
x11_init.c:(.text+0x23b4): undefined reference to `XkbQueryExtension'
x11_init.c:(.text+0x23f3): undefined reference to `XkbSetDetectableAutoRepeat'
x11_init.c:(.text+0x2420): undefined reference to `dlopen'
Order of libraries matter. If library A depends on library B, then A must come before B on the command line.
In your case, since the glfw3 library depends on the dl library, you must switch order so that glfw3 comes before dl on the command line.
You also must link with the X11 library.
So the full command line should look something like
g++ -o bin/Debug/Game obj/Debug/main.o -lglfw3 -ldl -lm -lGL -lGLU -lX11
I'm working on a modification of the Wolfenstein 3D engine in SDL2 (using Wolf4SDL as a base) and I've run into a problem - when using -static in the linker options, I get a large variety of undefined references to various things. Here's my build log to show what I mean:
-------------- Build: Debug in Lazarus (compiler: GNU GCC Compiler)---------------
i686-w64-mingw32-g++.exe -LC:\SDL2\lib -o Lazarus.exe .objs\alu_cache.o .objs\alu_dbg_mem.o .objs\alu_gfx.o .objs\alu_hud.o .objs\alu_in.o .objs\alu_me_core.o .objs\alu_me_gui.o .objs\alu_me_symbols.o .objs\alu_me_textinput.o .objs\alu_me_tools.o .objs\alu_me_windows.o .objs\alu_menu.o .objs\alu_pak.o .objs\alu_particles.o .objs\asmcomp.o .objs\id_us_1.o .objs\vieasm.o .objs\wl_act1.o .objs\wl_act2.o .objs\wl_agent.o .objs\wl_debug.o .objs\wl_dir3dspr.o .objs\wl_draw.o .objs\wl_floorceiling.o .objs\wl_game.o .objs\wl_inter.o .objs\wl_main.o .objs\wl_play.o .objs\wl_state.o .objs\wl_text.o -static -pg -lgmon -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -mwindows
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `timeSetPeriod':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:58: undefined reference to `_imp__timeBeginPeriod#4'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:52: undefined reference to `_imp__timeEndPeriod#4'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:58: undefined reference to `_imp__timeBeginPeriod#4'
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `SDL_TicksInit':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:106: undefined reference to `_imp__timeGetTime#0'
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `timeSetPeriod':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:52: undefined reference to `_imp__timeEndPeriod#4'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:52: undefined reference to `_imp__timeEndPeriod#4'
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `SDL_GetTicks_REAL':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:159: undefined reference to `_imp__timeGetTime#0'
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `timeSetPeriod':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:58: undefined reference to `_imp__timeBeginPeriod#4'
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `SDL_TicksInit':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:106: undefined reference to `_imp__timeGetTime#0'
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `timeSetPeriod':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:52: undefined reference to `_imp__timeEndPeriod#4'
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `SDL_GetTicks_REAL':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:159: undefined reference to `_imp__timeGetTime#0'
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `timeSetPeriod':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:58: undefined reference to `_imp__timeBeginPeriod#4'
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `SDL_TicksInit':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:106: undefined reference to `_imp__timeGetTime#0'
C:\SDL2\lib\libSDL2.a(SDL_systimer.o): In function `timeSetPeriod':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/timer/windows/SDL_systimer.c:52: undefined reference to `_imp__timeEndPeriod#4'
C:\SDL2\lib\libSDL2.a(SDL_windows.o): In function `WIN_CoInitialize':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/core/windows/SDL_windows.c:68: undefined reference to `_imp__CoInitializeEx#8'
C:\SDL2\lib\libSDL2.a(SDL_windows.o): In function `WIN_CoUninitialize':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/core/windows/SDL_windows.c:87: undefined reference to `_imp__CoUninitialize#0'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_SetupAPI':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:596: undefined reference to `ImmGetIMEFileNameA#12'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:609: undefined reference to `ImmGetContext#4'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:612: undefined reference to `ImmReleaseContext#8'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_GetId':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:530: undefined reference to `ImmGetIMEFileNameA#12'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:545: undefined reference to `GetFileVersionInfoSizeA#8'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:549: undefined reference to `GetFileVersionInfoA#16'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:550: undefined reference to `VerQueryValueA#16'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `UILess_GetCandidateList':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:966: undefined reference to `_imp__SysFreeString#4'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_ClearComposition':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:662: undefined reference to `ImmGetContext#4'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:666: undefined reference to `ImmNotifyIME#16'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:670: undefined reference to `ImmNotifyIME#16'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:671: undefined reference to `ImmReleaseContext#8'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_Disable':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:344: undefined reference to `ImmAssociateContext#8'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_ClearComposition':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:668: undefined reference to `ImmSetCompositionStringW#24'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:662: undefined reference to `ImmGetContext#4'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:666: undefined reference to `ImmNotifyIME#16'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:670: undefined reference to `ImmNotifyIME#16'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:671: undefined reference to `ImmReleaseContext#8'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:668: undefined reference to `ImmSetCompositionStringW#24'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `UIElementSink_BeginUIElement#12':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:1033: undefined reference to `_imp__SysFreeString#4'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `UIElementSink_UpdateUIElement#8':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:1060: undefined reference to `_imp__SysFreeString#4'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_Init':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:289: undefined reference to `_imp__CoCreateInstance#20'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:303: undefined reference to `ImmGetContext#4'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:304: undefined reference to `ImmReleaseContext#8'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `UILess_SetupSinks':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:1174: undefined reference to `_imp__CoCreateInstance#20'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_GetId':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:530: undefined reference to `ImmGetIMEFileNameA#12'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:545: undefined reference to `GetFileVersionInfoSizeA#8'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:549: undefined reference to `GetFileVersionInfoA#16'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_GetReadingString':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:402: undefined reference to `ImmGetContext#4'
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:477: undefined reference to `ImmReleaseContext#8'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_GetId':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:550: undefined reference to `VerQueryValueA#16'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_Quit':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:358: undefined reference to `ImmAssociateContext#8'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_Enable':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:329: undefined reference to `ImmAssociateContext#8'
C:\SDL2\lib\libSDL2.a(SDL_windowskeyboard.o): In function `IME_ClearComposition':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/video/windows/SDL_windowskeyboard.c:662: undefined reference to `ImmGetContext#4'
Process terminated with status 1 (0 minute(s), 0 second(s))
50 error(s), 0 warning(s) (0 minute(s), 0 second(s))
This does not happen when linking a normal Wolf4SDL mod (which uses SDL 1.2), and it links correctly if I don't use -static but then won't run without various other DLLs being present (namely libgcc_s_dw2-1.dll and the like). While I can just change PATH to include my MinGW directory, when it comes time to distribute it I can't expect everyone to have MinGW installed, and I want to keep the number of DLLs I'm distributing with my mod to a minimum considering I'm already using SDL_mixer and SDL_image which come with a ton of DLLs already. Anyone have a solution to this?
OK, fixed the problem - I needed to link a variety of Windows libraries, namely Ole32, Oleaut32, Imm32, Winmm and Version. Not sure why this wasn't the case for SDL 1; it wasn't mentioned in the Migration Guide either so I'm not sure where the difference comes from.
For me this meant "use pkg-config --static" since I had compiled a static only version and wanted to use that.
Guess that's just how pkg-config rolls.
Another option (like the OP mentioned) is to either add the libraries you need "out of band" or to modify sdl2.pc so it includes "all the libraries you need" on the Libs: line (not Libs.static: line which probably already has them).
Again, that's how pkg-config rolls :|
I have the following example program
http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/example/http/client/sync_client.cpp
When I execute, I get this error ..
$ g++ sync_client.cpp -I usr/include/boost
/tmp/cc3eDbiW.o: In function `__static_initialization_and_destruction_0(int, int)':
sync_client.cpp:(.text+0xd61): undefined reference to `boost::system::generic_category()'
sync_client.cpp:(.text+0xd6d): undefined reference to `boost::system::generic_category()'
sync_client.cpp:(.text+0xd79): undefined reference to `boost::system::system_category()'
/tmp/cc3eDbiW.o: In function `boost::system::error_code::error_code()':
sync_client.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
/tmp/cc3eDbiW.o: In function `boost::asio::error::get_system_category()':
sync_client.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x5): undefined reference to `boost::system::system_category()'
/tmp/cc3eDbiW.o: In function `boost::asio::detail::posix_tss_ptr_create(unsigned int&)':
sync_client.cpp:(.text._ZN5boost4asio6detail20posix_tss_ptr_createERj[boost::asio::detail::posix_tss_ptr_create(unsigned int&)]+0x19): undefined reference to `pthread_key_create'
/tmp/cc3eDbiW.o: In function `boost::asio::detail::posix_thread::~posix_thread()':
sync_client.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26): undefined reference to `pthread_detach'
/tmp/cc3eDbiW.o: In function `boost::asio::detail::posix_thread::join()':
sync_client.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[boost::asio::detail::posix_thread::join()]+0x2b): undefined reference to `pthread_join'
/tmp/cc3eDbiW.o: In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service>::context>::~posix_tss_ptr()':
sync_client.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceEE7contextEED2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceEE7contextEED5Ev]+0x15): undefined reference to `pthread_key_delete'
/tmp/cc3eDbiW.o: In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::strand_service::strand_impl>::context>::~posix_tss_ptr()':
sync_client.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_14strand_service11strand_implEE7contextEED2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_14strand_service11strand_implEE7contextEED5Ev]+0x15): undefined reference to `pthread_key_delete'
collect2: ld returned 1 exit status
What is the correct compiler command?
g++ sync_client.cpp -lboost_iostreams -lboost_system -o sync_client
And then:
./sync_client
You may have to add -lpthread to the compilation command, it seems that your LD_LIBRARY_PATH or ld.so.conf is not configured properly.
Note: There's no need to add -I /usr/include/boost to the command line.
Update:
The command ls -l /usr/lib/libboost_iostreams* should output something like this:
... /usr/lib/libboost_iostreams.so -> libboost_iostreams.so.1.55.0*
... /usr/lib/libboost_iostreams.so.1.55.0*
If that's the case, try running sudo ldconfig.
After trying this for all of today with no result, and searching through LOTS of threads on here and on forums, I'm hoping someone here will be able to find a solution.
I'm trying to get this simple example using cURL to work on Windows using MinGW.
When I try to compile it with g++
g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
it always gives me the same errors:
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0x87): undefined reference to `_curl_easy_init'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xb6): undefined reference to `_curl_easy_setopt'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xc2): undefined reference to `_curl_easy_perform'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0xd9): undefined reference to `_curl_easy_strerror'
C:\Users\Xenon\AppData\Local\Temp\ccI5UUEq.o:Test.cpp:(.text+0x101): undefined reference to `_curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status
To be honest, I'm all out of ideas what could be causing this. Any help would be greatly appreciated. Thanks in advance!
Edit:
When adding the parameter -v, I'm getting the following output:
g++ -v -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.7.0/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-with-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.7.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/cc1plus.exe -quiet -v -I curl\include
-iprefix c:\mingw\bin\../lib/gcc/mingw32/4.7.0/ -D CURL_STATICLIB Test.cpp -quiet -dumpbase Test.cpp -mtune=i386 -march=i386 -auxbase Test -version -o C:\Users\Xenon\AppData\Local\Temp\ccsSlqnP.s
GNU C++ (GCC) version 4.7.0 (mingw32)
compiled by GNU C version 4.7.0, GMP version 5.0.1, MPFR version 2.4.1,
MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.7.0/../../../../mingw32/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++/mingw32"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include/c++/backward"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include"
ignoring nonexistent directory "/mingw/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/include-fixed"
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.7.0/../../../../mingw32/include"
ignoring nonexistent directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
curl\include
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++/mingw32
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++/backward
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/../../../../include
c:\mingw\bin\../lib/gcc/mingw32/4.7.0/include-fixed
End of search list.
GNU C++ (GCC) version 4.7.0 (mingw32)
compiled by GNU C version 4.7.0, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9fc40f37d31a03e5502141ce58bdf4c7
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/as.exe -o C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o C:\Users\Xenon\AppData\Local\Temp\ccsSlqnP.s
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.7.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../
COLLECT_GCC_OPTIONS='-v' '-o' 'Test.exe' '-D' 'CURL_STATICLIB' '-I' 'curl\include' '-Lcurl\lib' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/mingw/bin/../libexec/gcc/mingw32/4.7.0/collect2.exe -Bdynamic -u ___register_frame_info -u ___deregister_frame_info -o Test.exe c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/4.7.0/crtbegin.o -Lcurl\lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../.. C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o -lcurl -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32
-luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.7.0/crtend.o
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0xf): undefined reference to `_curl_easy_init'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x36): undefined reference to `_curl_easy_setopt'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x42): undefined reference to `_curl_easy_perform'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x59): undefined reference to `_curl_easy_strerror'
C:\Users\Xenon\AppData\Local\Temp\ccYxunOQ.o:Test.cpp:(.text+0x81): undefined reference to `_curl_easy_cleanup'
collect2.exe: error: ld returned 1 exit status
I still don't know what could be causing my problem though...are all those "ignored" directories normal?
Edit: After now using a 32-bit cURL library, the compiler is literally spamming error messages. I don't know if it means it's working or even more broken now... Had to remove a few messages, as they were 506 lines...
>g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurl
curl\lib/libcurl.a(easy.o):(.text+0x16): undefined reference to `_WSAStartup#8'
curl\lib/libcurl.a(easy.o):(.text+0x39): undefined reference to `_WSACleanup#0'
[...]
curl\lib/libcurl.a(ssluse.o):(.text+0x1662): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1688): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x16cb): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x16f7): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1723): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x174f): more undefined references to `_BN_num_bits' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x1833): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1876): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18a2): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18ce): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x18fa): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x192a): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x195a): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x199a): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x19c6): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x19f2): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1a22): undefined reference to `_BN_num_bits'
curl\lib/libcurl.a(ssluse.o):(.text+0x1a52): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ade): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1b22): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1b66): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1baa): undefined reference to `_BN_bn2bin'
curl\lib/libcurl.a(ssluse.o):(.text+0x1bee): more undefined references to `_BN_bn2bin' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x1e8c): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ea0): undefined reference to `_X509_get_subject_name'
curl\lib/libcurl.a(ssluse.o):(.text+0x1eca): undefined reference to `_X509_NAME_get_index_by_NID'
curl\lib/libcurl.a(ssluse.o):(.text+0x1ee2): undefined reference to `_X509_NAME_get_entry'
curl\lib/libcurl.a(ssluse.o):(.text+0x1eea): undefined reference to `_X509_NAME_ENTRY_get_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x1efc): undefined reference to `_ASN1_STRING_type'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f15): undefined reference to `_ASN1_STRING_to_UTF8'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f7f): undefined reference to `_CRYPTO_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x1f96): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x203f): undefined reference to `_ASN1_STRING_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x2052): undefined reference to `_ASN1_STRING_length'
curl\lib/libcurl.a(ssluse.o):(.text+0x20e0): undefined reference to `_PEM_read_X509'
curl\lib/libcurl.a(ssluse.o):(.text+0x2105): undefined reference to `_X509_check_issued'
curl\lib/libcurl.a(ssluse.o):(.text+0x213e): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2146): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x21c6): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2274): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x2280): undefined reference to `_X509_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x22b4): more undefined references to `_X509_free' follow
curl\lib/libcurl.a(ssluse.o):(.text+0x22c3): undefined reference to `_SSL_get_verify_result'
curl\lib/libcurl.a(ssluse.o):(.text+0x233e): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x23b7): undefined reference to `_ASN1_STRING_length'
curl\lib/libcurl.a(ssluse.o):(.text+0x23dc): undefined reference to `_CRYPTO_malloc'
curl\lib/libcurl.a(ssluse.o):(.text+0x23ec): undefined reference to `_ASN1_STRING_data'
curl\lib/libcurl.a(ssluse.o):(.text+0x2467): undefined reference to `_X509_verify_cert_error_string'
curl\lib/libcurl.a(ssluse.o):(.text+0x248e): undefined reference to `_X509_verify_cert_error_string'
curl\lib/libcurl.a(ssluse.o):(.text+0x24c9): undefined reference to `_GENERAL_NAMES_free'
curl\lib/libcurl.a(ssluse.o):(.text+0x251a): undefined reference to `_RAND_load_file'
curl\lib/libcurl.a(ssluse.o):(.text+0x251f): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x256a): undefined reference to `_RAND_add'
curl\lib/libcurl.a(ssluse.o):(.text+0x2578): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x2599): undefined reference to `_RAND_file_name'
curl\lib/libcurl.a(ssluse.o):(.text+0x25b2): undefined reference to `_RAND_load_file'
curl\lib/libcurl.a(ssluse.o):(.text+0x25b7): undefined reference to `_RAND_status'
curl\lib/libcurl.a(ssluse.o):(.text+0x267f): undefined reference to `_ERR_clear_error'
curl\lib/libcurl.a(ssluse.o):(.text+0x268a): undefined reference to `_SSL_connect'
[...]
curl\lib/libcurl.a(ssluse.o):(.text+0x3ecb): undefined reference to `_RAND_bytes'
curl\lib/libcurl.a(ftp.o):(.text+0xdac): undefined reference to `_bind#12'
curl\lib/libcurl.a(ftp.o):(.text+0xdbc): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0xdfc): undefined reference to `_htons#4'
curl\lib/libcurl.a(ftp.o):(.text+0xe4f): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0xe5f): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0xf2d): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0xf51): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0xfb4): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0xfc4): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0x10d1): undefined reference to `_listen#8'
curl\lib/libcurl.a(ftp.o):(.text+0x10dd): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ftp.o):(.text+0x11e9): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(ftp.o):(.text+0x1249): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(ftp.o):(.text+0x1429): undefined reference to `_getsockname#12'
curl\lib/libcurl.a(ftp.o):(.text+0x1478): undefined reference to `_accept#12'
curl\lib/libcurl.a(ftp.o):(.text+0x2bb9): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text+0x3fc): undefined reference to `_WSAStartup#8'
curl\lib/libcurl.a(telnet.o):(.text+0x432): undefined reference to `_WSACleanup#0'
curl\lib/libcurl.a(telnet.o):(.text+0xe1b): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text+0xe41): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text+0xf11): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x17b): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x18b): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x3bb): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x3cb): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x5bd): undefined reference to `_htons#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x5d2): undefined reference to `_htons#4'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x6ae): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x6ba): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x708): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x714): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x853): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x85f): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x9ad): undefined reference to `_send#16'
curl\lib/libcurl.a(telnet.o):(.text.unlikely+0x9b9): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(ldap.o):(.text+0x221): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x267): undefined reference to `__imp__ldap_msgfree'
curl\lib/libcurl.a(ldap.o):(.text+0x298): undefined reference to `__imp__ldap_unbind_s'
curl\lib/libcurl.a(ldap.o):(.text+0x6cb): undefined reference to `__imp__ldap_set_optionA'
curl\lib/libcurl.a(ldap.o):(.text+0x721): undefined reference to `__imp__ldap_simple_bind_sA'
curl\lib/libcurl.a(ldap.o):(.text+0x778): undefined reference to `__imp__ldap_search_sA'
curl\lib/libcurl.a(ldap.o):(.text+0x796): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x825): undefined reference to `__imp__ldap_err2stringA'
curl\lib/libcurl.a(ldap.o):(.text+0x888): undefined reference to `__imp__ldap_set_optionA'
curl\lib/libcurl.a(ldap.o):(.text+0x8a3): undefined reference to `__imp__ldap_initA'
curl\lib/libcurl.a(ldap.o):(.text+0x8dd): undefined reference to `__imp__ldap_first_entry'
curl\lib/libcurl.a(ldap.o):(.text+0x91e): undefined reference to `__imp__ldap_get_dnA'
curl\lib/libcurl.a(ldap.o):(.text+0x9bd): undefined reference to `__imp__ldap_first_attributeA'
curl\lib/libcurl.a(ldap.o):(.text+0x9e9): undefined reference to `__imp__ldap_get_values_lenA'
curl\lib/libcurl.a(ldap.o):(.text+0xbc9): undefined reference to `__imp__ldap_value_free_len'
curl\lib/libcurl.a(ldap.o):(.text+0xc1e): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc3d): undefined reference to `__imp__ldap_next_attributeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc56): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xc71): undefined reference to `__imp__ber_free'
curl\lib/libcurl.a(ldap.o):(.text+0xc86): undefined reference to `__imp__ldap_next_entry'
curl\lib/libcurl.a(ldap.o):(.text+0xcaf): undefined reference to `__imp__ldap_value_free_len'
curl\lib/libcurl.a(ldap.o):(.text+0xcbc): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xccb): undefined reference to `__imp__ldap_memfreeA'
curl\lib/libcurl.a(ldap.o):(.text+0xcea): undefined reference to `__imp__ber_free'
curl\lib/libcurl.a(tftp.o):(.text+0x210): undefined reference to `_sendto#24'
curl\lib/libcurl.a(tftp.o):(.text+0x29b): undefined reference to `_sendto#24'
[...]
curl\lib/libcurl.a(ssh.o):(.text+0x46a9): undefined reference to `_libssh2_knownhost_init'
curl\lib/libcurl.a(ssh.o):(.text+0x46cd): undefined reference to `_libssh2_knownhost_readfile'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x24): undefined reference to `_RTMP_Close'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x2c): undefined reference to `_RTMP_Free'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0xbc): undefined reference to `_setsockopt#20'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0xcf): undefined reference to `_RTMP_Connect1'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x13d): undefined reference to `_RTMP_Write'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x15e): undefined reference to `_RTMP_Alloc'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x16c): undefined reference to `_RTMP_Init'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x17c): undefined reference to `_RTMP_SetBufferMS'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x190): undefined reference to `_RTMP_SetupURL'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x1ac): undefined reference to `_RTMP_Free'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x1eb): undefined reference to `_RTMP_Read'
curl\lib/libcurl.a(curl_rtmp.o):(.text+0x24e): undefined reference to `_RTMP_ConnectStream'
curl\lib/libcurl.a(select.o):(.text+0x2e): undefined reference to `_WSASetLastError#4'
curl\lib/libcurl.a(select.o):(.text+0x2ae): undefined reference to `_select#20'
curl\lib/libcurl.a(select.o):(.text+0x2bd): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(select.o):(.text+0x354): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x374): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x3b4): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x3d1): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x42f): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x445): more undefined references to `___WSAFDIsSet#8' follow
curl\lib/libcurl.a(select.o):(.text+0x77d): undefined reference to `_select#20'
curl\lib/libcurl.a(select.o):(.text+0x78c): undefined reference to `_WSAGetLastError#0'
curl\lib/libcurl.a(select.o):(.text+0x849): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x863): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(select.o):(.text+0x884): undefined reference to `___WSAFDIsSet#8'
curl\lib/libcurl.a(content_encoding.o):(.text+0x170): undefined reference to `_inflate'
curl\lib/libcurl.a(content_encoding.o):(.text+0x18c): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x1ac): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x224): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x27e): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x294): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x2be): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x2ce): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x33e): undefined reference to `_inflateInit_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x472): undefined reference to `_zlibVersion'
curl\lib/libcurl.a(content_encoding.o):(.text+0x4b0): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x4f8): undefined reference to `_inflateInit2_'
curl\lib/libcurl.a(content_encoding.o):(.text+0x58c): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x5c9): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(content_encoding.o):(.text+0x6ca): undefined reference to `_inflateEnd'
curl\lib/libcurl.a(nonblock.o):(.text+0x2a): undefined reference to `_ioctlsocket#12'
curl\lib/libcurl.a(md5.o):(.text+0x15): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.text+0x3b): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.text+0x4e): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(md5.o):(.rdata+0x0): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.rdata+0x4): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.rdata+0x8): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(md5.o):(.rdata+0x14): undefined reference to `_MD5_Init'
curl\lib/libcurl.a(md5.o):(.rdata+0x18): undefined reference to `_MD5_Update'
curl\lib/libcurl.a(md5.o):(.rdata+0x1c): undefined reference to `_MD5_Final'
curl\lib/libcurl.a(curl_gethostname.o):(.text+0x19): undefined reference to `_gethostname#8'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x2e4): undefined reference to `_htons#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x427): undefined reference to `_ntohs#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0x811): undefined reference to `_htons#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0xc5c): undefined reference to `_htons#4'
curl\lib/libcurl.a(socks_sspi.o):(.text+0xd7e): undefined reference to `_ntohs#4'
collect2.exe: error: ld returned 1 exit status
Edit: I also tried downloading the Windows OpenSSL package offered on their website and including it - no change.
Edit: It's finally working! The solution was to use the 32-bit cURL package and to pass these parameters to the compiler:
g++ -o Test.exe Test.cpp -DCURL_STATICLIB -I curl\include -L curl\lib -lcurldll -lssh2 -lidn -lrtmp -lssl -lcrypto -lz -lws2_32 -lwldap32
Since everything is setup correctly, I see two solutions:
either remove -DCURL_STATICLIB or add -static to your command line.
Edit:
It took some time, but it looks like you have a 32 bit Mingw and a 64 bit libcurl. Download the 32 bit libcurl and try again.
I'm using Ubuntu and tried using synaptic to install everything that had the word "GLUT" in it and also SDL and opengl . But still a simple program fails to compile . It shows this :
opengl1.cpp:(.text+0xe): undefined reference to `glClear'
opengl1.cpp:(.text+0x1a): undefined reference to `glBegin'
opengl1.cpp:(.text+0x2e): undefined reference to `glVertex2i'
opengl1.cpp:(.text+0x33): undefined reference to `glEnd'
opengl1.cpp:(.text+0x38): undefined reference to `glFlush'
/tmp/ccnwQeLu.o: In function `MyInit()':
opengl1.cpp:(.text+0x4c): undefined reference to `glGetString'
opengl1.cpp:(.text+0x57): undefined reference to `std::cout'
opengl1.cpp:(.text+0x5c): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, unsigned char const*)'
opengl1.cpp:(.text+0x6c): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, char const*)'
opengl1.cpp:(.text+0x78): undefined reference to `glGetString'
opengl1.cpp:(.text+0x83): undefined reference to `std::cout'
opengl1.cpp:(.text+0x88): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, unsigned char const*)'
opengl1.cpp:(.text+0x98): undefined reference to `std::basic_ostream >& std::operator >(std::basic_ostream >&, char const*)'
opengl1.cpp:(.text+0xc0): undefined reference to `glClearColor'
opengl1.cpp:(.text+0xdf): undefined reference to `glColor3f'
opengl1.cpp:(.text+0xec): undefined reference to `glPointSize'
opengl1.cpp:(.text+0xf8): undefined reference to `glMatrixMode'
opengl1.cpp:(.text+0xfd): undefined reference to `glLoadIdentity'
opengl1.cpp:(.text+0x12d): undefined reference to `gluOrtho2D'
/tmp/ccnwQeLu.o: In function `main':
opengl1.cpp:(.text+0x14a): undefined reference to `glutInit'
opengl1.cpp:(.text+0x156): undefined reference to `glutInitDisplayMode'
opengl1.cpp:(.text+0x16d): undefined reference to `glutInitWindowSize'
opengl1.cpp:(.text+0x181): undefined reference to `glutInitWindowPosition'
opengl1.cpp:(.text+0x18d): undefined reference to `glutCreateWindow'
opengl1.cpp:(.text+0x19e): undefined reference to `glutDisplayFunc'
opengl1.cpp:(.text+0x1a3): undefined reference to `glutMainLoop'
/tmp/ccnwQeLu.o: In function `__static_initialization_and_destruction_0(int, int)':
opengl1.cpp:(.text+0x1cb): undefined reference to `std::ios_base::Init::Init()'
opengl1.cpp:(.text+0x1d0): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccnwQeLu.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
If I use g++ instead of gcc I get this:
vim opebgl1.cpp
g++ opengl1.cpp -o opengl1 -lGL -lstdc++ -lc -lm
and then get this :
/tmp/ccCJBuIl.o: In function `MyInit()':
opengl1.cpp:(.text+0x12d): undefined reference to `gluOrtho2D'
/tmp/ccCJBuIl.o: In function `main':
opengl1.cpp:(.text+0x14a): undefined reference to `glutInit'
opengl1.cpp:(.text+0x156): undefined reference to `glutInitDisplayMode'
opengl1.cpp:(.text+0x16d): undefined reference to `glutInitWindowSize'
opengl1.cpp:(.text+0x181): undefined reference to `glutInitWindowPosition'
opengl1.cpp:(.text+0x18d): undefined reference to `glutCreateWindow'
opengl1.cpp:(.text+0x19e): undefined reference to `glutDisplayFunc'
opengl1.cpp:(.text+0x1a3): undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status
So what do I really need to start working with opengl in Ubuntu?
Add "-lstdc++ -lGL" to your linker flags.
Or try to compile it like this:
g++ opengl1.cpp -o opengl1 -lGL -lGLU -lc -lm
(edit: added -lGLU, removed -lstdc++)
You should link it with glut and GLU as well:
g++ opengl1.cpp -o opengl1 -lGL -lstdc++ -lc -lm -lglut -lGLU
Files ended with .cpp must be compiled with g++. The rest of the errors are related to the linking process, and they should not happen if you build your application with the command I suggested above. If they do, make sure you have installed libglut and libglu.
Make sure you are using g++ to build your C++ files to avoid the linker errors pertaining to the C++ standard library.
To resolve the GLUT symbols you probably just need to add -lglut to your final build command.
While compiling the code you must mention some parameters according to your includes.
You already used -lGL, -lm etc.
To use gluOrtho2D the parameter to be used is -lGLU
and for other functions that begin with glut use -lglut