Very strange linker behavior

后端 未结 8 2092
猫巷女王i
猫巷女王i 2020-12-07 17:56

This is strange because I was able to get the error below to go away by removing the reference to libm.

gcc -o example example.o -Wl -L/home/kensey/cdev/lib          


        
8条回答
  •  遥遥无期
    2020-12-07 18:10

    Hard to tell. Because there are custom library directories in the command line it's conceivable that -lm links an incompatible alternative version. Without -lm the linker could pull in another version of it because it's needed by one of the libraries you link.

    To make sure strace both invocations and see where libm.so is coming from in both cases.

    BTW, -Wl switch seems to do nothing and -L/usr/lib/x86_64-linux-gnu is mentioned twice.

提交回复
热议问题