0

我正在尝试编译最短路径问题的实现(代码:http ://www.dis.uniroma1.it/challenge9/code/ch9-1.1.tar.gz )。但是,我收到错误:

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
4

1 回答 1

0

编辑 Makefile 以更改 -lm 位置。将 -lm 放在命令行末尾,因为取决于 gcc/binutils,顺序很重要*。

[1] 库可能需要出现在需要它们的对象之后。

于 2013-08-01T19:06:30.447 回答