简体   繁体   English

C ++上的链接器错误

[英]Linker errors on c++

I am trying to compile the implementation of the shortest path problem (code: http://www.dis.uniroma1.it/challenge9/code/ch9-1.1.tar.gz ). 我正在尝试编译最短路径问题的实现(代码: http : //www.dis.uniroma1.it/challenge9/code/ch9-1.1.tar.gz )。 However, I am getting errors: 但是,我得到了错误:

le@le-Extensa-4630:~/Desktop/code/ch9-1.1$ make
cd ./gens;    make
make[1]: Entering directory `/home/le/Desktop/code/ch9-1.1/gens'
cd ./grid;    make
make[2]: Entering directory `/home/le/Desktop/code/ch9-1.1/gens/grid'
gcc -O6 -DNDEBUG -DPERMUTE_NODES  -I ../../lib -I ../../lib/ll-core/include -o spgrid.exe spgrid.c -lm         -I../../lib/ ../../lib/ll-core/src/*.c
../../lib/ll-core/src/LConnectivity.c: In function ‘_visitaDSFRicorsiva’:
../../lib/ll-core/src/LConnectivity.c:114:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ui4’ [-Wformat]
../../lib/ll-core/src/LFile_posix.c: In function ‘LFile_GetTempName’:
../../lib/ll-core/src/LFile_posix.c:171:11: warning: ignoring return value of ‘tmpnam’, declared with attribute warn_unused_result [-Wunused-result]
../../lib/ll-core/src/LSystem.c: In function ‘LSystem_GetString’:
../../lib/ll-core/src/LSystem.c:47:10: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
/tmp/ccGnQJPS.o: In function `LArray_ResizeBy':
LArray.c:(.text+0x354): undefined reference to `log'
LArray.c:(.text+0x38e): undefined reference to `pow'
LArray.c:(.text+0x402): undefined reference to `log'
LArray.c:(.text+0x43c): undefined reference to `pow'
/tmp/ccVDr0iU.o: In function `LGraphUtil_RandomUNM':
LGraphUtil.c:(.text+0x988): undefined reference to `sqrt'
LGraphUtil.c:(.text+0x997): undefined reference to `sqrt'
LGraphUtil.c:(.text+0x9a6): undefined reference to `sqrt'
collect2: ld returned 1 exit status
make[2]: *** [spgrid.exe] Error 1
make[2]: Leaving directory `/home/le/Desktop/code/ch9-1.1/gens/grid'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/le/Desktop/code/ch9-1.1/gens'
make: *** [code] Error 2

Edit the Makefile to change the -lm position. 编辑Makefile以更改-lm位置。 Put the -lm at the end of the command line because depending of the gcc/binutils the order matters*. 将-lm放在命令行末尾,因为顺序取决于gcc / binutils *。

[1] Libraries may need to appear after the objects that need them. [1]库可能需要出现在需要它们的对象之后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM