Search code examples
ceclipsebuildlinker-flags

Linker Option at the very end in Eclipse CDT


I am trying to build a C program in Eclipse CDT that uses Opus and Alsa libraries. I normally compile the program in command line as follows:

cc prog.c -o prog.exe -lopus -lasound

but I couldn't achieve the same in eclipse CDT. I add the linker flags at

Project > Properties > C/C++ Build > Settings > Tool Settings > GCC C Linker > Miscellaneous

resulting command during build by Eclipse is :

gcc -lopus -lasound -o "prog" ./src/prog.o

How can I make Eclipse put the linker flags at the very end? Otherwise, the code doesn't compile.


Solution

  • Don't add libraries as -lopus under Miscellaneous. Rather, add them under Project > Properties > C/C++ Build > Settings > Tool Settings > GCC C Linker > Libraries, in the Libraries (-l) listbox. In there, just put the name of the library without the -l.

    Alternatively, you can list your libraries in Project > Properties > C/C++ General > Paths and Symbols > Libraries.