I'm trying to build a C++ program for the Renesas RL78/G13 series of MCUs. I was previously using the IAR toolchain without a problem but now I want to use the GNU RL78 toolchain so I can use some Renesas libraries.
My problem is that I now cannot get the program to link, seemingly because of missing symbols. Any advice would be really appreciated.
Here's the console output from the linker:
'Invoking: Linker'
'Building target:'
rl78-elf-ld -o "firmware_2.x" -T"C:\Projects\ms_monitor\firmware_2\HardwareDebug\firmware_2_HardwareDebug_auto.gsi" -T"C:\Projects\ms_monitor\firmware_2\HardwareDebug\LinkerSubCommand.tmp" libfirmware_2.a -M=firmware_2.map -e_PowerON_Reset -L"C:\Projects\ms_monitor\firmware_2\lib" -L"C:\Projects\ms_monitor\firmware_2\HardwareDebug" -L"C:\Renesas\e2studio\GNURL7~1.01-\rl78-elf\rl78-elf\lib" -L"C:\Renesas\e2studio\GNURL7~1.01-\rl78-elf\lib\gcc\rl78-elf\4.8-GNURL78_v13.01" --start-group -lstdc++ -lfirmware_2 -lgcc --end-group
rl78-elf-ld: section .vects loaded at [00000004,0000007f] overlaps section .vec loaded at [00000000,00000005]
libfirmware_2.a(gcrt0.o): In function `start':
(.text+0x2): undefined reference to `_stack'
libfirmware_2.a(gcrt0.o): In function `start':
(.text+0x9): undefined reference to `_datastart'
libfirmware_2.a(gcrt0.o): In function `start':
(.text+0xc): undefined reference to `_romdatastart'
libfirmware_2.a(gcrt0.o): In function `start':
(.text+0x11): undefined reference to `_romdatacopysize'
libfirmware_2.a(gcrt0.o): In function `start':
(.text+0x29): undefined reference to `_bssstart'
libfirmware_2.a(gcrt0.o): In function `start':
(.text+0x31): undefined reference to `_bsssize'
libfirmware_2.a(gcrt0.o): In function `start':
(.text+0x4c): undefined reference to `etext'
libfirmware_2.a(gcrt0.o): In function `start':
(.text+0x65): undefined reference to `exit'
libfirmware_2.a(gcrt0.o): In function `rl78_run_preinit_array':
(.text+0x69): undefined reference to `_preinit_array_start'
libfirmware_2.a(gcrt0.o): In function `rl78_run_preinit_array':
(.text+0x6c): undefined reference to `_preinit_array_end'
libfirmware_2.a(gcrt0.o): In function `rl78_run_init_array':
(.text+0x74): undefined reference to `_init_array_start'
libfirmware_2.a(gcrt0.o): In function `rl78_run_init_array':
(.text+0x77): undefined reference to `_init_array_end'
libfirmware_2.a(gcrt0.o): In function `rl78_run_fini_array':
(.text+0x7f): undefined reference to `_fini_array_start'
libfirmware_2.a(gcrt0.o): In function `rl78_run_fini_array':
(.text+0x82): undefined reference to `_fini_array_end'
./src/utilities/csv_loader.o: In function `CsvLoader_Create':
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:75:(.text+0xe): relocation truncated to fit: R_RL78_DIR16S against `.LC0'
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:75:(.text+0x18): relocation truncated to fit: R_RL78_DIR16S against `CsvLoader_Create::__PRETTY_FUNCTION__'
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:75:(.text+0x1d): relocation truncated to fit: R_RL78_DIR16S against `.LC1'
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:76:(.text+0x31): relocation truncated to fit: R_RL78_DIR16S against `.LC0'
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:76:(.text+0x3b): relocation truncated to fit: R_RL78_DIR16S against `CsvLoader_Create::__PRETTY_FUNCTION__'
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:76:(.text+0x40): relocation truncated to fit: R_RL78_DIR16S against `.LC2'
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:77:(.text+0x56): relocation truncated to fit: R_RL78_DIR16S against `.LC0'
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:77:(.text+0x60): relocation truncated to fit: R_RL78_DIR16S against `CsvLoader_Create::__PRETTY_FUNCTION__'
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:77:(.text+0x65): relocation truncated to fit: R_RL78_DIR16S against `.LC3'
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:78:(.text+0x79): relocation truncated to fit: R_RL78_DIR16S against `.LC0'
C:\Projects\ms_monitor\firmware_2\HardwareDebug/../src/utilities/csv_loader.cpp:78:(.text+0x83): additional relocation overflows omitted from the output
libfirmware_2.a(mcount.o): In function `_monstartup':
(.text+0x67b): undefined reference to `ffs'
libfirmware_2.a(printf.o): In function `_printf_r':
(.text+0x30): undefined reference to `_vfprintf_r'
libfirmware_2.a(printf.o): In function `printf':
(.text+0x75): undefined reference to `_vfprintf_r'
libfirmware_2.a(snprintf.o): In function `_snprintf_r':
(.text+0x8d): undefined reference to `_svfprintf_r'
libfirmware_2.a(snprintf.o): In function `snprintf':
(.text+0x165): undefined reference to `_svfprintf_r'
libfirmware_2.a(sprintf.o): In function `_sprintf_r':
(.text+0x4f): undefined reference to `_svfprintf_r'
libfirmware_2.a(sprintf.o): In function `sprintf':
(.text+0xbf): undefined reference to `_svfprintf_r'
libfirmware_2.a(vfiprintf.o): In function `_vfiprintf_r':
(.text+0x1bed): undefined reference to `_free_r'
libfirmware_2.a(vfiprintf.o): In function `_vfiprintf_r':
(.text+0x1c83): undefined reference to `_free_r'
libfirmware_2.a(wsetup.o): In function `__swsetup_r':
(.text+0xf8): undefined reference to `_free_r'
libfirmware_2.a(calloc.o): In function `calloc':
(.text+0x16): undefined reference to `_calloc_r'
libfirmware_2.a(fflush.o): In function `__sflush_r':
(.text+0x324): undefined reference to `_free_r'
libfirmware_2.a(findfp.o): In function `__sfmoreglue':
(.text+0xf2): undefined reference to `_malloc_r'
libfirmware_2.a(fvwrite.o): In function `__sfvwrite_r':
(.text+0x25e): undefined reference to `_malloc_r'
libfirmware_2.a(fvwrite.o): In function `__sfvwrite_r':
(.text+0x2de): undefined reference to `_realloc_r'
libfirmware_2.a(fvwrite.o): In function `__sfvwrite_r':
(.text+0x2ff): undefined reference to `_free_r'
libfirmware_2.a(makebuf.o): In function `__smakebuf_r':
(.text+0x1a2): undefined reference to `_malloc_r'
libfirmware_2.a(malloc.o): In function `malloc':
(.text+0x10): undefined reference to `_malloc_r'
libfirmware_2.a(malloc.o): In function `free':
(.text+0x26): undefined reference to `_free_r'
libfirmware_2.a(reent.o): In function `cleanup_glue':
(.text+0x3c): undefined reference to `_free_r'
libfirmware_2.a(reent.o): In function `_reclaim_reent':
(.text+0xb1): undefined reference to `_free_r'
libfirmware_2.a(reent.o): In function `_reclaim_reent':
(.text+0xe6): undefined reference to `_free_r'
libfirmware_2.a(reent.o): In function `_reclaim_reent':
(.text+0x111): undefined reference to `_free_r'
libfirmware_2.a(reent.o):(.text+0x172): more undefined references to `_free_r' follow
C:\Projects\ms_monitor\firmware_2\HardwareDebug\libfirmware_2.a(realloc.o): In function `realloc':
(.text+0x16): undefined reference to `_realloc_r'
make: *** [firmware_2.x] Error 1
This question was answered after a lot of support from the KPIT GNU team.
I had incorrect linker files for the processor that I was trying to compile for (as in, the linker file was correct but its contents not). Not only that, some missing symbols depended on how the workspace was configured.
If you see this problem yourself, the first step is to contact KPIT GNU, as I would not have known that there was a problem with the files without asking them.
Related
I am taking a computer graphics course using opengl, and for the life of me, I've not been able to compile a single opengl program using the teacher's makefile without doing it on the school's server. I'm not an experience C programmer, so make files are a bit new to me. I've been spoiled by Eclipse compiler always making my build.xml file for me.
I am using cygwin since the teacher's make file is for linux/unix. I have also installed opengl on it via searching under the Graphics category on installation. This is my make file:
#!smake
# Project 1: Simple scene
#
MACHINE= $(shell uname -s)
ifeq ($(MACHINE),Darwin)
OPENGL_INC= -FOpenGL
OPENGL_LIB= -framework OpenGL -framework GLUT -framework Cocoa
else
OPENGL_INC= -I/usr/include
OPENGL_LIB= -L/usr/lib64
LLDLIBS = -lglut -lGL -lGLU -lGL -lXmu -lXext -lX11 -lm
endif
CXX=g++
COMPILER_FLAGS= -g
INCLUDE= $(OPENGL_INC)
While g++ doesn't complain about -lglut, -lGL, -lGLU, etc not existing (it was before), I still get this error message:
g++ -g -L/usr/lib64 -lglut -lGL -lGLU -lGL -lXmu -lXext -lX11 -lm MyCoolModel.o 01primitives.o 01primitivesUtil.o trackball.o model.o -o MyCoolModel
MyCoolModel.o: In function `init()':
/home/01primitives/MyCoolModel.c:48: undefined reference to `__imp_glClearColor'
/home/01primitives/MyCoolModel.c:48:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_glClearColor'
/home/01primitives/MyCoolModel.c:49: undefined reference to `__imp_glShadeModel'
/home/01primitives/MyCoolModel.c:49:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_glShadeModel'
/home/01primitives/MyCoolModel.c:54: undefined reference to `__imp_glGenLists'
/home/01primitives/MyCoolModel.c:54:(.text+0x41): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_glGenLists'
/home/01primitives/MyCoolModel.c:58: undefined reference to `__imp_glGenLists'
/home/01primitives/MyCoolModel.c:58:(.text+0x6a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_glGenLists'
MyCoolModel.o: In function `Display()':
/home/01primitives/MyCoolModel.c:71: undefined reference to `__imp_glClear'
/home/01primitives/MyCoolModel.c:71:(.text+0xa2): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_glClear'
/home/01primitives/MyCoolModel.c:73: undefined reference to `__imp_glPushMatrix'
/home/01primitives/MyCoolModel.c:73:(.text+0xab): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_glPushMatrix'
/home/01primitives/MyCoolModel.c:76: undefined reference to `__imp_glDisable'
/home/01primitives/MyCoolModel.c:76:(.text+0xbe): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_glDisable'
/home/01primitives/MyCoolModel.c:77: undefined reference to `__imp_glDisable'
/home/01primitives/MyCoolModel.c:77:(.text+0xcc): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_glDisable'
/home/01primitives/MyCoolModel.c:80: undefined reference to `__imp_glColor3f'
/home/01primitives/MyCoolModel.c:80:(.text+0xed): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_glColor3f'
/home/01primitives/MyCoolModel.c:82: undefined reference to `__imp_glBegin'
/home/01primitives/MyCoolModel.c:82:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_glBegin'
/home/01primitives/MyCoolModel.c:83: undefined reference to `__imp_glVertex3f'
/home/01primitives/MyCoolModel.c:83:(.text+0x114): additional relocation overflows omitted from the output
/home/01primitives/MyCoolModel.c:83: undefined reference to `__imp_glVertex3f'
/home/01primitives/MyCoolModel.c:83: undefined reference to `__imp_glVertex3f'
/home/01primitives/MyCoolModel.c:84: undefined reference to `__imp_glEnd'
/home/01primitives/MyCoolModel.c:85: undefined reference to `__imp_glColor3f'
/home/01primitives/MyCoolModel.c:86: undefined reference to `__imp_glBegin'
/home/01primitives/MyCoolModel.c:87: undefined reference to `__imp_glVertex3f'
/home/01primitives/MyCoolModel.c:87: undefined reference to `__imp_glVertex3f'
/home/01primitives/MyCoolModel.c:87: undefined reference to `__imp_glVertex3f'
/home/01primitives/MyCoolModel.c:88: undefined reference to `__imp_glEnd'
/home/01primitives/MyCoolModel.c:98: undefined reference to `__imp_glCallList'
/home/01primitives/MyCoolModel.c:99: undefined reference to `__imp_glPopMatrix'
/home/01primitives/MyCoolModel.c:102: undefined reference to `__imp_glCallList'
/home/01primitives/MyCoolModel.c:107: undefined reference to `glutSwapBuffers'
MyCoolModel.o: In function `Reshape(int, int)':
/home/01primitives/MyCoolModel.c:118: undefined reference to `__imp_glViewport'
/home/01primitives/MyCoolModel.c:119: undefined reference to `__imp_glMatrixMode'
/home/01primitives/MyCoolModel.c:120: undefined reference to `__imp_glLoadIdentity'
/home/01primitives/MyCoolModel.c:121: undefined reference to `gluPerspective'
/home/01primitives/MyCoolModel.c:122: undefined reference to `__imp_glMatrixMode'
/home/01primitives/MyCoolModel.c:123: undefined reference to `__imp_glLoadIdentity'
/home/01primitives/MyCoolModel.c:124: undefined reference to `__imp_glTranslatef'
MyCoolModel.o: In function `Mouse(int, int, int, int)':
/home/01primitives/MyCoolModel.c:133: undefined reference to `glutPostRedisplay'
MyCoolModel.o: In function `Motion(int, int)':
/home/01primitives/MyCoolModel.c:139: undefined reference to `glutPostRedisplay'
MyCoolModel.o: In function `Keyboard(unsigned char, int, int)':
/home/01primitives/MyCoolModel.c:158: undefined reference to `glutPostRedisplay'
MyCoolModel.o: In function `main':
/home/01primitives/MyCoolModel.c:166: undefined reference to `glutInit'
/home/01primitives/MyCoolModel.c:167: undefined reference to `glutInitWindowPosition'
/home/01primitives/MyCoolModel.c:168: undefined reference to `glutInitWindowSize'
/home/01primitives/MyCoolModel.c:169: undefined reference to `glutInitDisplayMode'
/home/01primitives/MyCoolModel.c:170: undefined reference to `glutCreateWindow'
/home/01primitives/MyCoolModel.c:174: undefined reference to `glutDisplayFunc'
/home/01primitives/MyCoolModel.c:175: undefined reference to `glutReshapeFunc'
/home/01primitives/MyCoolModel.c:176: undefined reference to `glutMouseFunc'
/home/01primitives/MyCoolModel.c:177: undefined reference to `glutMotionFunc'
/home/01primitives/MyCoolModel.c:178: undefined reference to `glutKeyboardFunc'
/home/01primitives/MyCoolModel.c:180: undefined reference to `glutMainLoop'
01primitivesUtil.o: In function `uMakeCoordList(unsigned int)':
/home/01primitives/01primitivesUtil.c:35: undefined reference to `__imp_glNewList'
/home/01primitives/01primitivesUtil.c:37: undefined reference to `__imp_glBegin'
/home/01primitives/01primitivesUtil.c:38: undefined reference to `__imp_glColor3f'
/home/01primitives/01primitivesUtil.c:38: undefined reference to `__imp_glVertex3f'
/home/01primitives/01primitivesUtil.c:38: undefined reference to `__imp_glVertex3f'
/home/01primitives/01primitivesUtil.c:39: undefined reference to `__imp_glColor3f'
/home/01primitives/01primitivesUtil.c:39: undefined reference to `__imp_glVertex3f'
/home/01primitives/01primitivesUtil.c:39: undefined reference to `__imp_glVertex3f'
/home/01primitives/01primitivesUtil.c:40: undefined reference to `__imp_glColor3f'
/home/01primitives/01primitivesUtil.c:40: undefined reference to `__imp_glVertex3f'
/home/01primitives/01primitivesUtil.c:40: undefined reference to `__imp_glVertex3f'
/home/01primitives/01primitivesUtil.c:41: undefined reference to `__imp_glEnd'
/home/01primitives/01primitivesUtil.c:42: undefined reference to `__imp_glEndList'
01primitivesUtil.o: In function `uMakeGroundList(unsigned int)':
/home/01primitives/01primitivesUtil.c:51: undefined reference to `__imp_glNewList'
/home/01primitives/01primitivesUtil.c:53: undefined reference to `__imp_glEndList'
trackball.o: In function `_tbStopMotion(int, unsigned int)':
/home/01primitives/trackball.c:83: undefined reference to `glutIdleFunc'
/home/01primitives/trackball.c:87: undefined reference to `glutIdleFunc'
trackball.o: In function `tbInit(unsigned int)':
/home/01primitives/trackball.c:105: undefined reference to `__imp_glPushMatrix'
/home/01primitives/trackball.c:106: undefined reference to `__imp_glLoadIdentity'
/home/01primitives/trackball.c:107: undefined reference to `__imp_glGetFloatv'
/home/01primitives/trackball.c:108: undefined reference to `__imp_glPopMatrix'
trackball.o: In function `tbMatrix()':
/home/01primitives/trackball.c:117: undefined reference to `__imp_glPushMatrix'
/home/01primitives/trackball.c:118: undefined reference to `__imp_glLoadIdentity'
/home/01primitives/trackball.c:119: undefined reference to `__imp_glRotatef'
/home/01primitives/trackball.c:120: undefined reference to `__imp_glMultMatrixf'
/home/01primitives/trackball.c:121: undefined reference to `__imp_glGetFloatv'
/home/01primitives/trackball.c:122: undefined reference to `__imp_glPopMatrix'
/home/01primitives/trackball.c:124: undefined reference to `__imp_glMultMatrixf'
trackball.o: In function `tbMouse(int, int, int, int)':
/home/01primitives/trackball.c:141: undefined reference to `glutGet'
/home/01primitives/trackball.c:143: undefined reference to `glutGet'
trackball.o: In function `tbMotion(int, int, int)':
/home/01primitives/trackball.c:181: undefined reference to `glutGet'
/home/01primitives/trackball.c:187: undefined reference to `glutPostRedisplay'
trackball.o: In function `tbZoom(float)':
/home/01primitives/trackball.c:199: undefined reference to `__imp_glMatrixMode'
/home/01primitives/trackball.c:200: undefined reference to `__imp_glLoadIdentity'
/home/01primitives/trackball.c:202: undefined reference to `__imp_glTranslatef'
trackball.o: In function `translate(float, float)':
/home/01primitives/trackball.c:208: undefined reference to `__imp_glMatrixMode'
/home/01primitives/trackball.c:209: undefined reference to `__imp_glLoadIdentity'
/home/01primitives/trackball.c:214: undefined reference to `__imp_glTranslatef'
model.o: In function `ModelHead()':
/home/01primitives/model.c:18: undefined reference to `__imp_glPushMatrix'
/home/01primitives/model.c:19: undefined reference to `__imp_glTranslatef'
/home/01primitives/model.c:21: undefined reference to `__imp_glPopMatrix'
model.o: In function `ModelTorso()':
/home/01primitives/model.c:26: undefined reference to `__imp_glPushMatrix'
/home/01primitives/model.c:27: undefined reference to `__imp_glTranslatef'
/home/01primitives/model.c:28: undefined reference to `__imp_glPopMatrix'
model.o: In function `ModelUpperBody()':
/home/01primitives/model.c:33: undefined reference to `__imp_glPushMatrix'
/home/01primitives/model.c:34: undefined reference to `__imp_glTranslatef'
/home/01primitives/model.c:35: undefined reference to `__imp_glPopMatrix'
model.o: In function `ModelLegsAndFeet()':
/home/01primitives/model.c:40: undefined reference to `__imp_glPushMatrix'
/home/01primitives/model.c:41: undefined reference to `__imp_glTranslatef'
/home/01primitives/model.c:42: undefined reference to `__imp_glPopMatrix'
model.o: In function `ModelLittleMario()':
/home/01primitives/model.c:69: undefined reference to `__imp_glRasterPos2f'
/home/01primitives/model.c:70: undefined reference to `__imp_glDrawPixels'
collect2: error: ld returned 1 exit status
Makefile:36: recipe for target 'MyCoolModel' failed
make: *** [MyCoolModel] Error 1
I've been hearing that this sort of problem lies with the linker, although I'm not exactly sure what that means. I am assuming that my header files were recognized, my binaries weren't, or were in the wrong directory.
My teacher's Makefile says that the opengl library files are in a directory called /usr/lib64, but checking my cygwin user directory, it does not exist. I can see the /usr/include folder, though. This could the the problem, but I have no idea how to resolve it. I though that installing opengl on cygwin would take care of this.
Assuming that this is the problem, could anyone help me locate these library files?
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've been trying to compile this OpenGL tutorial (originally purposed for Visual Studio) but I keep having 'undefined reference' errors. The compiler output is as follows:
Info: Internal Builder is used for build
g++ -o OpenGLTutorial.exe "src\\main.o" "src\\Camera.o" -lglew32 -lglu32 -lopengl32 -lfreeglut
src\main.o: In function `Z6InitGLiPPc':
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:75: undefined reference to `glutInit'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:76: undefined reference to `glutSetOption'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:77: undefined reference to `glutGet'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:78: undefined reference to `glutGet'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:80: undefined reference to `glutInitDisplayMode'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:82: undefined reference to `glutInitContextVersion'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:83: undefined reference to `glutInitContextProfile'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:84: undefined reference to `glutInitContextFlags'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:86: undefined reference to `glutInitWindowPosition'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:87: undefined reference to `glutInitWindowSize'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:89: undefined reference to `glutCreateWindow'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:91: undefined reference to `glutIdleFunc'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:92: undefined reference to `glutDisplayFunc'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:93: undefined reference to `glutKeyboardFunc'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:94: undefined reference to `glutKeyboardUpFunc'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:95: undefined reference to `glutSpecialFunc'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:96: undefined reference to `glutSpecialUpFunc'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:97: undefined reference to `glutMouseFunc'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:98: undefined reference to `glutMotionFunc'
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:99: undefined reference to `glutReshapeFunc'
src\main.o: In function `main':
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:236: undefined reference to `glutMainLoop'
src\main.o: In function `Z9ReshapeGLii':
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:249: undefined reference to `glutPostRedisplay'
src\main.o: In function `Z9DisplayGLv':
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:262: undefined reference to `glutSwapBuffers'
src\main.o: In function `Z6IdleGLv':
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:278: undefined reference to `glutPostRedisplay'
src\main.o: In function `Z10KeyboardGLhii':
C:\Users\jordanrich\Documents\programming\C++\GameDev\OpenGLTutorial\Debug/../src/main.cpp:313: undefined reference to `glutLeaveMainLoop'
collect2.exe: error: ld returned 1 exit status
21:39:05 Build Finished (took 1s.154ms)
Can anyone tell me what is wrong?
If you need any more information to help answer the question just ask.
Edit (Some additional info):
As you can see from the compiler output I have linked the library that these functions require and the compiler does not complain that it could not find said library. Also I placed the freeglut dll into the binary folder.
This problem was apparently mainly due to user error and was completely circumstantial. I'm posting this for the people of the future who might have this problem.
In my header file I defined FREEGLUT_STATIC. After changing this to another variable, the linker no longer produced errors. Though I can't actually check -- very easily at least -- somewhere in my freeglut library this variable was used in an ifndef statement to determine whether freeglut needed to be linked (in case it was already linked).
I am trying to compile a very simple OpenGL program that uses GLFW3. Despite linking everything I deem necessary, I'm getting a plethora of undefined references.
/usr/local/lib/libglfw3.a(x11_gamma.c.o): In function `_glfwInitGammaRamp':
x11_gamma.c:(.text+0x49): undefined reference to `XRRGetScreenResources'
x11_gamma.c:(.text+0x6a): undefined reference to `XRRGetCrtcGammaSize'
x11_gamma.c:(.text+0x81): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_gamma.c.o): In function `_glfwPlatformGetGammaRamp':
x11_gamma.c:(.text+0xce): undefined reference to `XRRGetCrtcGammaSize'
x11_gamma.c:(.text+0xf1): undefined reference to `XRRGetCrtcGamma'
x11_gamma.c:(.text+0x198): undefined reference to `XRRFreeGamma'
/usr/local/lib/libglfw3.a(x11_gamma.c.o): In function `_glfwPlatformSetGammaRamp':
x11_gamma.c:(.text+0x24c): undefined reference to `XRRAllocGamma'
x11_gamma.c:(.text+0x303): undefined reference to `XRRSetCrtcGamma'
x11_gamma.c:(.text+0x30f): undefined reference to `XRRFreeGamma'
/usr/local/lib/libglfw3.a(x11_init.c.o): In function `initExtensions':
x11_init.c:(.text+0x1a67): undefined reference to `XRRQueryExtension'
x11_init.c:(.text+0x1a91): undefined reference to `XRRQueryVersion'
x11_init.c:(.text+0x1b25): undefined reference to `XIQueryVersion'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwSetVideoMode':
x11_monitor.c:(.text+0x177): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x19c): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x1be): undefined reference to `XRRGetOutputInfo'
x11_monitor.c:(.text+0x3d0): undefined reference to `XRRSetCrtcConfig'
x11_monitor.c:(.text+0x3dc): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0x3e8): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x3f4): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwRestoreVideoMode':
x11_monitor.c:(.text+0x446): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x46b): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x4e0): undefined reference to `XRRSetCrtcConfig'
x11_monitor.c:(.text+0x4ec): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x4f8): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetMonitors':
x11_monitor.c:(.text+0x55a): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x577): undefined reference to `XRRGetOutputPrimary'
x11_monitor.c:(.text+0x5cf): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x5ea): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x659): undefined reference to `XRRGetOutputInfo'
x11_monitor.c:(.text+0x676): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0x682): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x703): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0x70f): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x733): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetMonitorPos':
x11_monitor.c:(.text+0x8a2): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x8c7): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0x8ff): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0x90b): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetVideoModes':
x11_monitor.c:(.text+0x9ad): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0x9cf): undefined reference to `XRRGetOutputInfo'
x11_monitor.c:(.text+0xb44): undefined reference to `XRRFreeOutputInfo'
x11_monitor.c:(.text+0xb50): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_monitor.c.o): In function `_glfwPlatformGetVideoMode':
x11_monitor.c:(.text+0xc28): undefined reference to `XRRGetScreenResources'
x11_monitor.c:(.text+0xc4d): undefined reference to `XRRGetCrtcInfo'
x11_monitor.c:(.text+0xca2): undefined reference to `XRRFreeCrtcInfo'
x11_monitor.c:(.text+0xcae): undefined reference to `XRRFreeScreenResources'
/usr/local/lib/libglfw3.a(x11_window.c.o): In function `createWindow':
x11_window.c:(.text+0x666): undefined reference to `XISelectEvents'
x11_window.c:(.text+0x6a8): undefined reference to `XRRSelectInput'
/usr/local/lib/libglfw3.a(x11_window.c.o): In function `processEvent':
x11_window.c:(.text+0x1711): undefined reference to `XRRUpdateConfiguration'
My linked CMake flags:
-I/usr/local/include -L/usr/local/lib -lglfw3 -lGLU -lGL -lGLEW
Should I be linking anything else?
I figured out the answer myself while writing the question.
I was misled into believing that I was linking everything necessary because of the output of
pkg-config --libs --cflags --print-requires glfw3
which was
-I/usr/local/include -L/usr/local/lib -lglfw3
The --print-requires flag was having no impact at all on the output, which seemed odd. I searched and printed the corresponding .pc file.
sudo find / | grep "glfw3\.pc"
cat /usr/local/lib/pkgconfig/glfw3.pc
There I found this.
Requires.private: x11 xrandr xi xxf86vm gl
Which indicates which libraries are required for static linking. I added their correponding flags to CMake and it worked. My mistake was that I missed the --print-requires-private flag when executing pkg-config.
I hope this helps someone save some time.
I'm writing a Qt application that uses Botan. For the Windows version I decided to use the precompiled DLL, so I downloaded the installer, installed Botan in C:\botan and added:
win32:INCLUDEPATH += C:/botan/include
win32:LIBS += -L"C:\botan" -lbotan
to my .pro file. However I'm getting linker errors (undefined reference to...) during the build process, and I can't see why - the correct .lib is specified in LIBS, the include path is fine.
I'm using MinGW.
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:52: undefined reference to `_imp___ZN5Botan17have_block_cipherERKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:58: undefined reference to `_imp___ZN5Botan16max_keylength_ofERKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:59: undefined reference to `_imp___ZN5Botan13block_size_ofERKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:61: undefined reference to `_imp___ZN5Botan14AutoSeeded_RNGC1Ej'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:63: undefined reference to `_imp___ZN5Botan7get_s2kERKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:64: undefined reference to `_imp___ZN5Botan3S2K14set_iterationsEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:65: undefined reference to `_imp___ZN5Botan3S2K15new_random_saltERNS_21RandomNumberGeneratorEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:67: undefined reference to `_imp___ZNK5Botan3S2K10derive_keyEjRKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:68: undefined reference to `_imp___ZNK5Botan3S2K10derive_keyEjRKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:69: undefined reference to `_imp___ZNK5Botan3S2K10derive_keyEjRKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:83: undefined reference to `_imp___ZN5Botan10MAC_FilterC1ERKSsRKNS_11OctetStringEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:83: undefined reference to `_imp___ZN5Botan14Base64_EncoderC1Ebjb'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:83: undefined reference to `_imp___ZN5Botan5ChainC1EPNS_6FilterES2_S2_S2_'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:83: undefined reference to `_imp___ZN5Botan10get_cipherERKSsRKNS_11OctetStringES4_NS_10Cipher_DirE'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:83: undefined reference to `_imp___ZN5Botan14Base64_EncoderC1Ebjb'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:83: undefined reference to `_imp___ZN5Botan5ChainC1EPNS_6FilterES2_S2_S2_'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:83: undefined reference to `_imp___ZN5Botan4ForkC1EPNS_6FilterES2_S2_S2_'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:83: undefined reference to `_imp___ZN5Botan4PipeC1EPNS_6FilterES2_S2_S2_'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:83: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:85: undefined reference to `_imp___ZN5Botan4Pipe9start_msgEv'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:83: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:86: undefined reference to `_imp___ZN5BotanrsERSiRNS_4PipeE'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:87: undefined reference to `_imp___ZN5Botan4Pipe7end_msgEv'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:89: undefined reference to `_imp___ZN5Botan4Pipe18read_all_as_stringEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:90: undefined reference to `_imp___ZN5Botan4Pipe18read_all_as_stringEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:90: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:90: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:142: undefined reference to `_imp___ZN5Botan17have_block_cipherERKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:148: undefined reference to `_imp___ZN5Botan16max_keylength_ofERKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:149: undefined reference to `_imp___ZN5Botan13block_size_ofERKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:151: undefined reference to `_imp___ZN5Botan7get_s2kERKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:152: undefined reference to `_imp___ZN5Botan3S2K14set_iterationsEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:153: undefined reference to `_imp___ZN5Botan3S2K11change_saltERKNS_12MemoryRegionIhEE'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:155: undefined reference to `_imp___ZNK5Botan3S2K10derive_keyEjRKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:156: undefined reference to `_imp___ZNK5Botan3S2K10derive_keyEjRKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:157: undefined reference to `_imp___ZNK5Botan3S2K10derive_keyEjRKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:164: undefined reference to `_imp___ZN5Botan10MAC_FilterC1ERKSsRKNS_11OctetStringEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:164: undefined reference to `_imp___ZN5Botan14Base64_EncoderC1Ebjb'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:164: undefined reference to `_imp___ZN5Botan5ChainC1EPNS_6FilterES2_S2_S2_'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:164: undefined reference to `_imp___ZN5Botan4ForkC1EPNS_6FilterES2_S2_S2_'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:164: undefined reference to `_imp___ZN5Botan10get_cipherERKSsRKNS_11OctetStringES4_NS_10Cipher_DirE'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:164: undefined reference to `_imp___ZN5Botan14Base64_DecoderC1ENS_16Decoder_CheckingE'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:164: undefined reference to `_imp___ZN5Botan4PipeC1EPNS_6FilterES2_S2_S2_'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:164: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:166: undefined reference to `_imp___ZN5Botan4Pipe9start_msgEv'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:164: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:167: undefined reference to `_imp___ZN5BotanrsERSiRNS_4PipeE'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:168: undefined reference to `_imp___ZN5Botan4Pipe7end_msgEv'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:170: undefined reference to `_imp___ZN5Botan4Pipe18read_all_as_stringEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:174: undefined reference to `_imp___ZN5Botan4Pipe18read_all_as_stringEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:174: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:174: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:195: undefined reference to `_imp___ZN5Botan14Base64_EncoderC1Ebjb'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:195: undefined reference to `_imp___ZN5Botan4PipeC1EPNS_6FilterES2_S2_S2_'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:196: undefined reference to `_imp___ZN5Botan4Pipe11process_msgERKNS_12MemoryRegionIhEE'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:197: undefined reference to `_imp___ZN5Botan4Pipe15DEFAULT_MESSAGEE'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:197: undefined reference to `_imp___ZN5Botan4Pipe18read_all_as_stringEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:197: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:197: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:202: undefined reference to `_imp___ZN5Botan14Base64_DecoderC1ENS_16Decoder_CheckingE'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:202: undefined reference to `_imp___ZN5Botan4PipeC1EPNS_6FilterES2_S2_S2_'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:203: undefined reference to `_imp___ZN5Botan4Pipe11process_msgERKSs'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:204: undefined reference to `_imp___ZN5Botan4Pipe15DEFAULT_MESSAGEE'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:204: undefined reference to `_imp___ZN5Botan4Pipe8read_allEj'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:204: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o:D:\Development\Qt\silverlock-build-desktop\silverlocklib/../../Silverlock/silverlocklib/databasecrypto.cpp:204: undefined reference to `_imp___ZN5Botan4PipeD1Ev'
./debug\databasecrypto.o: In function `LibraryInitializer':
c:/botan/include/botan/init.h:34: undefined reference to `_imp___ZN5Botan18LibraryInitializer10initializeERKSs'
./debug\databasecrypto.o: In function `~LibraryInitializer':
c:/botan/include/botan/init.h:36: undefined reference to `_imp___ZN5Botan18LibraryInitializer12deinitializeEv'
./debug\databasecrypto.o: In function `~Exception':
c:/botan/include/botan/exceptn.h:25: undefined reference to `_imp___ZTVN5Botan9ExceptionE'
c:/botan/include/botan/exceptn.h:25: undefined reference to `_imp___ZTVN5Botan9ExceptionE'
c:/botan/include/botan/exceptn.h:25: undefined reference to `_imp___ZTVN5Botan9ExceptionE'
./debug\databasecrypto.o: In function `~Format_Error':
c:/botan/include/botan/exceptn.h:110: undefined reference to `_imp___ZTVN5Botan12Format_ErrorE'
c:/botan/include/botan/exceptn.h:110: undefined reference to `_imp___ZTVN5Botan12Format_ErrorE'
c:/botan/include/botan/exceptn.h:110: undefined reference to `_imp___ZTVN5Botan12Format_ErrorE'
./debug\databasecrypto.o: In function `~Decoding_Error':
c:/botan/include/botan/exceptn.h:135: undefined reference to `_imp___ZTVN5Botan14Decoding_ErrorE'
c:/botan/include/botan/exceptn.h:135: undefined reference to `_imp___ZTVN5Botan14Decoding_ErrorE'
./debug\databasecrypto.o: In function `Exception':
c:/botan/include/botan/exceptn.h:21: undefined reference to `_imp___ZTVN5Botan9ExceptionE'
./debug\databasecrypto.o: In function `~RandomNumberGenerator':
c:/botan/include/botan/rng.h:78: undefined reference to `_imp___ZTVN5Botan21RandomNumberGeneratorE'
c:/botan/include/botan/rng.h:78: undefined reference to `_imp___ZTVN5Botan21RandomNumberGeneratorE'
c:/botan/include/botan/rng.h:78: undefined reference to `_imp___ZTVN5Botan21RandomNumberGeneratorE'
./debug\databasecrypto.o: In function `~AutoSeeded_RNG':
c:/botan/include/botan/auto_rng.h:37: undefined reference to `_imp___ZTVN5Botan14AutoSeeded_RNGE'
c:/botan/include/botan/auto_rng.h:37: undefined reference to `_imp___ZTVN5Botan14AutoSeeded_RNGE'
./debug\databasecrypto.o: In function `Algorithm_Not_Found':
c:/botan/include/botan/exceptn.h:102: undefined reference to `_imp___ZTVN5Botan19Algorithm_Not_FoundE'
./debug\databasecrypto.o: In function `~Algorithm_Not_Found':
c:/botan/include/botan/exceptn.h:102: undefined reference to `_imp___ZTVN5Botan19Algorithm_Not_FoundE'
c:/botan/include/botan/exceptn.h:102: undefined reference to `_imp___ZTVN5Botan19Algorithm_Not_FoundE'
./debug\databasecrypto.o: In function `Format_Error':
c:/botan/include/botan/exceptn.h:110: undefined reference to `_imp___ZTVN5Botan12Format_ErrorE'
./debug\databasecrypto.o: In function `Decoding_Error':
c:/botan/include/botan/exceptn.h:135: undefined reference to `_imp___ZTVN5Botan14Decoding_ErrorE'
collect2: ld returned 1 exit status
Since Botan is included in QtCreator (2.x branches), you could just recompile QtCreator (or take the relevant parts), and use that. No messing with any makefiles (mingw works out of the box), and since you mention Qt, this will probably work very well.
As far as I know, official binaries are compatible with MSVC only. I guess you should build Botan from source to use it with MinGW. According to docs it's relatively easy to do:
$ python configure.py
$ make
$ make check
$ make install
But for me compiler autodetection didn't work as expected, so I had to do few additional steps:
Autoconfiguration:
$ python configure.py --cc=gcc
Edit generated Makefile. Replace line
LINK_TO = -ladvapi32.lib -luser32.lib
with
LINK_TO = -ladvapi32 -luser32
Build
$ make
$ make check
$ make install
I've used this command to build botan using mingw32-make.exe, i've ran it in a console window with Qt support.
python configure.py --cc=gcc --cpu=x86 --os=mingw --without-stack-protector --amalgamation --minimized-build --disable-shared --enable-modules=aes,aes_ssse3,auto_rng,bigint,block,cbc,ctr,des,dh,dsa,ec_group,ecdh,ecdsa,entropy,filters,hmac,mode_pad,pubkey,rsa,sha1,sha1_sse2,sha1_x86,sha2_32,sha2_32_x86,sha2_64,simd,system_rng,emsa_pkcs1,pbes2,pbkdf2 --without-documentation
mingw32-make.exe
mingw32-make.exe install