简体   繁体   中英

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 ). 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. Put the -lm at the end of the command line because depending of the gcc/binutils the order matters*.

[1] Libraries may need to appear after the objects that need them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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