simonwunderlich / FFT_eval

FFT evaluation
62 stars 25 forks source link

compile failed due to gcc command order #1

Closed peiworld closed 11 years ago

peiworld commented 11 years ago

If the library is before the -o, then it will fail as below:

gcc -lSDL -lSDL_ttf -o fft_eval fft_eval.o fft_eval.o: In function graphics_init_sdl': fft_eval.c:(.text+0xc): undefined reference toSDL_Init' fft_eval.c:(.text+0x19): undefined reference to SDL_GetVideoInfo' fft_eval.c:(.text+0x53): undefined reference toSDL_WM_SetCaption' fft_eval.c:(.text+0x73): undefined reference to SDL_SetVideoMode' fft_eval.c:(.text+0x7d): undefined reference toTTF_Init' fft_eval.c:(.text+0x95): undefined reference to TTF_OpenFont' fft_eval.o: In functionrender_text': fft_eval.c:(.text+0x34d): undefined reference to TTF_RenderText_Solid' fft_eval.c:(.text+0x373): undefined reference toSDL_UpperBlit' fft_eval.c:(.text+0x37b): undefined reference to SDL_FreeSurface' fft_eval.o: In functiondraw_picture': fft_eval.c:(.text+0x3f7): undefined reference to SDL_CreateRGBSurface' fft_eval.c:(.text+0x695): undefined reference tolog10f' fft_eval.c:(.text+0x6a5): undefined reference to log10f' fft_eval.c:(.text+0x75c): undefined reference toSDL_UpperBlit' fft_eval.c:(.text+0x768): undefined reference to SDL_FreeSurface' fft_eval.c:(.text+0x775): undefined reference toSDL_Flip' fft_eval.o: In function graphics_main': fft_eval.c:(.text+0xac2): undefined reference toSDL_EnableKeyRepeat' fft_eval.c:(.text+0xb1c): undefined reference to SDL_PollEvent' fft_eval.c:(.text+0xb91): undefined reference toSDL_WaitEvent' fft_eval.c:(.text+0xbca): undefined reference to SDL_Quit' fft_eval.o: In functiongraphics_quit_sdl': fft_eval.c:(.text+0x171): undefined reference to `SDL_Quit' collect2: ld returned 1 exit status make: *\ [fft_eval] Error 1

have to change the library order to $(LD) -o $@ $(OBJ) $(LIBS) in the Makefile, and it works

ravens commented 11 years ago

Also, -lm might be needed for the LDFLAGS.

simonwunderlich commented 11 years ago

this has been fixed with Janusz' patches. I didn't include -lm though because it works for me without it. Thanks for reporting!

towolf commented 11 years ago

I need -lm too on x86_64 arch.

simonwunderlich commented 11 years ago

ok, i've added -lm to linker flags