1) gcc -O3 -lrt -lm serial2DMultigrid.c -o a.out /usr/bin/ld: /tmp/ccQNdgA3.o: in function `residualNorm': serial2DMultigrid.c:(.text+0xd5c): undefined reference to `sqrt' /usr/bin/ld: /tmp/ccQNdgA3.o: in function `main': serial2DMultigrid.c:(.text.startup+0x70): undefined reference to `log2' /usr/bin/ld: serial2DMultigrid.c:(.text.startup+0x9c): undefined reference to `pow' 2) gcc -O3 serial2DMultigrid.c -o a.out -lm 就ok了 不明白所以 3) gcc -O3 serial2DMultigrid.c -o a.out -lm -lrt 这个也没有问题 4)出错 gcc -O3 serial2DMultigrid.c -o a.out /usr/bin/ld: /tmp/ccl3TQ95.o: in function `residualNorm': serial2DMultigrid.c:(.text+0xd5c): undefined reference to `sqrt' /usr/bin/ld: /tmp/ccl3TQ95.o: in function `main': serial2DMultigrid.c:(.text.startup+0x70): undefined reference to `log2' /usr/bin/ld: serial2DMultigrid.c:(.text.startup+0x9c): undefined reference to `pow' collect2: error: ld returned 1 exit status 5) gcc -O3 serial2DMultigrid.c -lm -o a.out 也OK 7) gcc -O3 -lm serial2DMultigrid.c -o a.out /usr/bin/ld: /tmp/ccZwmz48.o: in function `residualNorm': serial2DMultigrid.c:(.text+0xd5c): undefined reference to `sqrt' /usr/bin/ld: /tmp/ccZwmz48.o: in function `main': serial2DMultigrid.c:(.text.startup+0x70): undefined reference to `log2' /usr/bin/ld: serial2DMultigrid.c:(.text.startup+0x9c): undefined reference to `pow' collect2: error: ld returned 1 exit status 库要放到源文件后面? |
说点什么...