Linking Math Library in GCC 4.6.1 (Ubuntu 11.10)

后端 未结 4 349
被撕碎了的回忆
被撕碎了的回忆 2021-01-22 01:24

I find a problem in the linking process of my application. I did not have the same with gcc 4.5. It tries to link math library with the following command.

gcc -W         


        
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-22 01:29

    recent gcc/ld uses the --as-needed linker flag as default. Practically, that means libraries have to be specified in the reverse order of dependencies on the command line. If the mems_internals library needs the sqrt function your -lm after -lmems_internals.

    gcc -Wall -Wno-unused -MD -o mems_seektest mems_seektest.o  -L. -g -DASSERTS  -I../src// -I../ -I../src//src -DDEBUG -lmems_internals -lm
    

提交回复
热议问题