I have attached SFML files in my main.cpp file for writing some games in c++. I wanted to add some images so, I included SFML files with the help of following includes:
#include <SFML/Graphics.hpp>
#include <time.h>
using namespace sf;
When I compiled my source code then linker errors like
undefined reference to __imp occurred.
Following are the errors:
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x2b6): undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x2e1): undefined reference to `__imp__ZN2sf9VideoModeC1Ejjj'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x335): undefined reference to `__imp__ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x374): undefined reference to `__imp__ZN2sf7TextureC1Ev'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x38e): undefined reference to `__imp__ZN2sf7TextureC1Ev'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x3a8): undefined reference to `__imp__ZN2sf7TextureC1Ev'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x418): undefined reference to `__imp__ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x4ad): undefined reference to `__imp__ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x542): undefined reference to `__imp__ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x588): undefined reference to `__imp__ZN2sf6SpriteC1ERKNS_7TextureE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x5ca): undefined reference to `__imp__ZN2sf6SpriteC1ERKNS_7TextureE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x615): undefined reference to `__imp__ZN2sf5ClockC1Ev'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x634): undefined reference to `__imp__ZNK2sf5Clock14getElapsedTimeEv'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x655): undefined reference to `__imp__ZNK2sf4Time9asSecondsEv'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x670): undefined reference to `__imp__ZN2sf5Clock7restartEv'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x6a7): undefined reference to `__imp__ZN2sf6Window5closeEv'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x713): undefined reference to `__imp__ZN2sf6Window9pollEventERNS_5EventE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0x730): undefined reference to `__imp__ZN2sf8Keyboard12isKeyPressedENS0_3KeyE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xd5c): undefined reference to `__imp__ZN2sf5Color5WhiteE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xd71): undefined reference to `__imp__ZN2sf12RenderTarget5clearERKNS_5ColorE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xd81): undefined reference to `__imp__ZN2sf12RenderStates7DefaultE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xda0): undefined reference to `__imp__ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xe76): undefined reference to `__imp__ZN2sf6Sprite14setTextureRectERKNS_4RectIiEE'
[Linker error] C:\Users\BILAWA~1\AppData\Local\Temp\ccYKolqi.o:main.cpp:(.text+0xec0): undefined reference to `__imp__ZN2sf13Transformable11setPositionEff'
collect2: ld returned 1 exit status
There are many other errors like this.
In SFML you need to compile with some flags :
g++ -o ... -lsfml-graphics -lsfml-window -lsfml-system
if you are using an IDE, you i'd want to do something like this:
(right click on your project, click build options, and then click linker settings)
if not do like sanka said
Related
Does anyone on this community have experience with compiling linking the CUDD package for manipulating BDDs? Seems like a great resource if I can only compile something simple... Getting a lot of following.
I am a novice with C, mainly Py guy, so any help would be highly appreciated. (I've tried using tulip-dd in Py, but that is a limited experience). Thanks in advance.
[glarangeira#login1 cudd3]$ gcc basicDD.c
/tmp/cc5v0zuv.o: In function `main':
basicDD.c:(.text+0x2a): undefined reference to `Cudd_Init'
basicDD.c:(.text+0x3a): undefined reference to `Cudd_bddNewVar'
basicDD.c:(.text+0x4a): undefined reference to `Cudd_Ref'
basicDD.c:(.text+0x56): undefined reference to `Cudd_Quit'
collect2: error: ld returned 1 exit status
[glarangeira#login1 cudd3]$ gcc basicDD.c /gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a -o bdd
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAPI.o): In function `Cudd_ExpectedUsedSlots':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAPI.c:1835: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAPI.c:1844: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAPI.c:1850: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddCache.o): In function `cuddCacheProfile':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddCache.c:816: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddUtil.o): In function `Cudd_CountMinterm':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddUtil.o): In function `Cudd_LdblCountMinterm':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:729: undefined reference to `powl'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddUtil.o): In function `Cudd_CountMinterm':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-epd.o): In function `EpdNormalizeDecimal':
/gpfs/software/dd/cudd-3.0.0/epd/epd.c:834: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-epd.o):/gpfs/software/dd/cudd-3.0.0/epd/epd.c:834: more undefined references to `pow' follow
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAnneal.o): In function `siftBackwardProb':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAnneal.c:671: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAnneal.c:671: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAnneal.o): In function `cuddAnnealing':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAnneal.c:229: undefined reference to `log'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAnneal.c:229: undefined reference to `log'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAnneal.o): In function `siftBackwardProb':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAnneal.c:671: undefined reference to `exp'
collect2: error: ld returned 1 exit status
I am trying to cross compile ALSA Lib application for linux-arm based processor. I am using eclipse to do the build for me. The build phase of the application is successful but I get errrors when the gcc linker tries to complete.
I get the following errors
Building target: sound
Invoking: Cross GCC Linker
arm-linux-gnueabihf-gcc -L/proc/asound -L/srv/nfs/rootfs/usr/lib -Wl,-rpath-link,/srv/nfs/rootfs/usr/lib -L/srv/nfs/rootfs/lib -Wl,-rpath-link,/srv/nfs/rootfs/lib -o "sound" ./play.o
./play.o: In function main':
/home/neonws/sound/Debug/../play.c:13: undefined reference tosnd_pcm_open'
makefile:29: recipe for target 'sound' failed
/home/neonws/sound/Debug/../play.c:14: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:20: undefined reference tosnd_pcm_hw_params_malloc'
/home/neonws/sound/Debug/../play.c:21: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:26: undefined reference tosnd_pcm_hw_params_any'
/home/neonws/sound/Debug/../play.c:27: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:32: undefined reference tosnd_pcm_hw_params_set_access'
/home/neonws/sound/Debug/../play.c:33: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:38: undefined reference tosnd_pcm_hw_params_set_format'
/home/neonws/sound/Debug/../play.c:39: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:44: undefined reference tosnd_pcm_hw_params_set_rate_near'
/home/neonws/sound/Debug/../play.c:45: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:50: undefined reference tosnd_pcm_hw_params_set_channels'
/home/neonws/sound/Debug/../play.c:51: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:56: undefined reference tosnd_pcm_hw_params'
/home/neonws/sound/Debug/../play.c:57: undefined reference to snd_strerror'
/home/neonws/sound/Debug/../play.c:62: undefined reference tosnd_pcm_hw_params_free'
/home/neonws/sound/Debug/../play.c:64: undefined reference to snd_pcm_prepare'
/home/neonws/sound/Debug/../play.c:65: undefined reference tosnd_strerror'
/home/neonws/sound/Debug/../play.c:71: undefined reference to snd_pcm_writei'
/home/neonws/sound/Debug/../play.c:72: undefined reference tosnd_strerror'
/home/neonws/sound/Debug/../play.c:78: undefined reference to `snd_pcm_close'
collect2: error: ld returned 1 exit status
make: *** [sound] Error 1
11:15:58 Build Finished (took 75ms)
I am using the Sample Playback Program from ASLA-LIB api.
I am wondering what is causing the linker to fail?
You're missing an asound library linkage, add -lasound to your linking flags (see this question which tells where to do that properly in Eclipse). And probably remove -L/proc/asound, I don't think you have your libraries there.
I've been going a bit crazy trying to figure out the issue here. My project builds fine on Fedora with it's native gcc and pkg-config flags but when cross-compiling or using MingW on Windows it gives me undefined references. The oddest thing was, I remember getting it to compile once or twice on Windows but I have no idea how. As far as I know, all the libraries are accessible, so I can't figure out what's wrong.
With this input:
mingw32-gcc -std=c99 -g -LC:/MinGW/lib -mwindows -lSDL -lSDLmain -lfreetype -lmingw32 -lglu32 -lopengl32 -o bin/gltris.exe gltris.o graphics.o input.o game.o block.o timer.o text.o
I get this output: (sorry for the weird formatting)
C:/MinGW/lib/libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `WinMain#16'
gltris.o: In function `gltris_init':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/gltris.c:24: undefined reference to `SDL_Init'
gltris.o: In function `SDL_main':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/gltris.c:110: undefined reference to `SDL_Quit'
graphics.o: In function `graphics_init':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:31: undefined reference to `SDL_SetVideoMode'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:34: undefined reference to `glClearColor#16'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:35: undefined reference to `glClear#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:36: undefined reference to `glViewport#16'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:38: undefined reference to `glMatrixMode#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:39: undefined reference to `glLoadIdentity#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:40: undefined reference to `glDisable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:41: undefined reference to `glBlendFunc#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:42: undefined reference to `glPixelStorei#8'
graphics.o: In function `graphics_begin_frame':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:50: undefined reference to `glMatrixMode#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:51: undefined reference to `glLoadIdentity#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:52: undefined reference to `glClear#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:54: undefined reference to `gluOrtho2D#32'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:56: undefined reference to `glMatrixMode#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:57: undefined reference to `glLoadIdentity#0'
graphics.o: In function `graphics_end_frame':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:62: undefined reference to `SDL_GL_SwapBuffers'
graphics.o: In function `graphics_render_block':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:68: undefined reference to `glPushMatrix#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:70: undefined reference to `glTranslatef#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:71: undefined reference to `glScalef#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:74: undefined reference to `glColor4ub#16'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:76: undefined reference to `glColor3ubv#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:78: undefined reference to `glEnable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:81: undefined reference to `glBegin#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:82: undefined reference to `glVertex2i#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:83: undefined reference to `glVertex2i#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:84: undefined reference to `glVertex2i#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:85: undefined reference to `glVertex2i#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:86: undefined reference to `glEnd#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:88: undefined reference to `glDisable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:90: undefined reference to `glPopMatrix#0'
graphics.o: In function `render_textured_quad':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:165: undefined reference to `glPushMatrix#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:167: undefined reference to `glEnable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:168: undefined reference to `glEnable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:169: undefined reference to `glBindTexture#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:171: undefined reference to `glTranslatef#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:173: undefined reference to `glBegin#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:175: undefined reference to `glTexCoord2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:176: undefined reference to `glVertex2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:178: undefined reference to `glTexCoord2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:179: undefined reference to `glVertex2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:181: undefined reference to `glTexCoord2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:182: undefined reference to `glVertex2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:184: undefined reference to `glTexCoord2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:185: undefined reference to `glVertex2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:187: undefined reference to `glEnd#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:189: undefined reference to `glDisable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:190: undefined reference to `glDisable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:192: undefined reference to `glPopMatrix#0'
graphics.o: In function `surface_to_texture':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:212: undefined reference to `glGenTextures#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:213: undefined reference to `glBindTexture#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:214: undefined reference to `glTexParameteri#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:215: undefined reference to `glTexParameteri#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:216: undefined reference to `glTexImage2D#36'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:221: undefined reference to `SDL_FreeSurface'
input.o: In function `handle_input':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/input.c:13: undefined reference to `SDL_PollEvent'
timer.o: In function `add_timer':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:20: undefined reference to `SDL_GetTicks'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:36: undefined reference to `SDL_GetTicks'
timer.o: In function `do_timers':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:65: undefined reference to `SDL_GetTicks'
timer.o: In function `pause_timer':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:84: undefined reference to `SDL_GetTicks'
timer.o: In function `resume_timer':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:90: undefined reference to `SDL_GetTicks'
timer.o:C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:98: more undefined references to `SDL_GetTicks' follow
text.o: In function `text_init':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:24: undefined reference to `_imp__FT_Init_FreeType'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:28: undefined reference to `_imp__FT_New_Face'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:32: undefined reference to `_imp__FT_Set_Char_Size'
text.o: In function `text_gen_texture':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:70: undefined reference to `glGenTextures#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:71: undefined reference to `glBindTexture#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:72: undefined reference to `glTexParameteri#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:73: undefined reference to `glTexParameteri#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:77: undefined reference to `glTexImage2D#36'
text.o: In function `text_print':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:92: undefined reference to `_imp__FT_Set_Char_Size'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:97: undefined reference to `_imp__FT_Load_Char'
text.o: In function `get_text_size':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:115: undefined reference to `_imp__FT_Set_Char_Size'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:119: undefined reference to `_imp__FT_Load_Char'
text.o: In function `print_game_info':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:138: undefined reference to `glColor3f#12'
collect2.exe: error: ld returned 1 exit status
EDIT:I got it to build by compiling and linking in one go, with the linker flags "-lmingw32 -lopengl32 -lSDLmain -lSDL -lfreetype -mwindows"
It seems like your compiler cannot find libSDL.a and other library files. Check if libSDL.a is present in C:/MinGW/lib. You will need a libSDL.a that is specifically made for mingw.
Also, try compiling a simple "Hello World" SDL program. That will make it easier to find what the error is.
I have a problem with linking while runing my Makefile. I have
installed freeglut on cygwin and tried to build my project. It works
OK in MSVS, but I get following errors:
g++ -static obj/MatrixDistortion.o obj/LookAt.o obj/MatrixT.o obj/Matrix2d.o obj/Camera.o obj/Grid.o obj/s_w_project.o obj/Scene.o -o SWproject -L/usr/lib -L/usr/X11/lib -L/lib/cygwin -L/usr/local/lib -lglut -lopengl32 -lglu32
obj/Grid.o:Grid.cpp:(.text+0xa36): undefined reference to `_glPushMatrix'
obj/Grid.o:Grid.cpp:(.text+0xa87): undefined reference to `_glMultMatrixd'
obj/Grid.o:Grid.cpp:(.text+0xaac): undefined reference to `_glTranslatef'
obj/Grid.o:Grid.cpp:(.text+0xab8): undefined reference to `_glClear'
obj/Grid.o:Grid.cpp:(.text+0xad7): undefined reference to `_glColor3f'
obj/Grid.o:Grid.cpp:(.text+0xae3): undefined reference to `_glBegin'
obj/Grid.o:Grid.cpp:(.text+0xb2c): undefined reference to `_glVertex3f'
obj/Grid.o:Grid.cpp:(.text+0xb4f): undefined reference to `_glVertex3f'
obj/Grid.o:Grid.cpp:(.text+0xbb4): undefined reference to `_glVertex3f'
obj/Grid.o:Grid.cpp:(.text+0xbd7): undefined reference to `_glVertex3f'
obj/Grid.o:Grid.cpp:(.text+0xc1e): undefined reference to `_glColor3f'
obj/Grid.o:Grid.cpp:(.text+0xc3d): undefined reference to `_glVertex3f'
obj/Grid.o:Grid.cpp:(.text+0xc5c): undefined reference to `_glVertex3f'
obj/Grid.o:Grid.cpp:(.text+0xc7b): undefined reference to `_glColor3f'
obj/Grid.o:Grid.cpp:(.text+0xc9a): undefined reference to `_glVertex3f'
obj/Grid.o:Grid.cpp:(.text+0xcb9): undefined reference to `_glVertex3f'
obj/Grid.o:Grid.cpp:(.text+0xcd8): undefined reference to `_glColor3f'
obj/Grid.o:Grid.cpp:(.text+0xcf7): undefined reference to `_glVertex3f'
obj/Grid.o:Grid.cpp:(.text+0xd16): undefined reference to `_glVertex3f'
obj/Grid.o:Grid.cpp:(.text+0xd1b): undefined reference to `_glEnd'
obj/Grid.o:Grid.cpp:(.text+0xd20): undefined reference to `_glPopMatrix'
obj/Grid.o:Grid.cpp:(.text+0xd25): undefined reference to `_glFlush'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: obj/Grid.o: bad reloc address 0xd in section `.text$_ZNSt4listIP6CameraSaIS1_EED1Ev[std::list<Camera*, std::allocator<Camera*> >::~list()]'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: final link failed: Invalid operation
collect2: ld returned 1 exit status
Makefile:14: recipe for target `SWproject' failed
I have passed the libraries to g++ as can be seen in the compiler invocation.
Do I have to install GL separately, but in that case why don't I get an error on #include <GL/gl.h>?
I'm trying to compile the zpipe.c example in my Linux(Ubuntu 8.04) with gcc, but I'm getting some errors, take a look:
[ubuntu#eeepc:~/Desktop] gcc zpipe.c
/tmp/ccczEQxz.o: In function `def':
zpipe.c:(.text+0x65): undefined reference to `deflateInit_'
zpipe.c:(.text+0xd3): undefined reference to `deflateEnd'
zpipe.c:(.text+0x150): undefined reference to `deflate'
zpipe.c:(.text+0x1e8): undefined reference to `deflateEnd'
zpipe.c:(.text+0x27b): undefined reference to `deflateEnd'
/tmp/ccczEQxz.o: In function `inf':
zpipe.c:(.text+0x314): undefined reference to `inflateInit_'
zpipe.c:(.text+0x382): undefined reference to `inflateEnd'
zpipe.c:(.text+0x3d7): undefined reference to `inflate'
zpipe.c:(.text+0x44b): undefined reference to `inflateEnd'
zpipe.c:(.text+0x4c1): undefined reference to `inflateEnd'
zpipe.c:(.text+0x4f6): undefined reference to `inflateEnd'
collect2: ld returned 1 exit status
[ubuntu#eeepc:~/Desktop]
Remember that I've installed zLib-dev correctly, but why i'm getting this errors?
You need to link it with the zlib library as well. Just add -lz to near end of your command line.