Ubuntu 11.10: GCC/G++ won't link libraries

后端 未结 3 1037
执笔经年
执笔经年 2021-01-12 14:49

I went to compile a project of mine, which uses SDL, SDL_ttf, OpenAL, and GTK. All of which are outputting errors like the following:

TxtFunc.cpp:(.text+0x61         


        
相关标签:
3条回答
  • 2021-01-12 14:59

    Generally you need to have your -l options after the files that use the symbols on the command line. Perhaps try moving the sdl-config --libs --cflags to the end of the command? i.e. for your test program:

    g++ -o sdl-test ./sdl-test.cpp `sdl-config --libs --cflags`
    
    0 讨论(0)
  • 2021-01-12 15:11

    Gah, which pillock got the idea to change the compiler to rely now on the order of options in the command line?

    Well,that fixed my problem too, just moved ($CFLAGS) after ($OBJS) in my Makefile and all my linking problems with unknown references to SDL libs are gone >.<

    0 讨论(0)
  • 2021-01-12 15:12

    In case you use SDL_ttf, you need to

    g++ main.cpp -o sdl-test `sdl-config --libs --cflags` -lSDL_ttf
    
    0 讨论(0)
提交回复
热议问题