gpt4 book ai didi

c - 如何在 Makefile 中链接共享库

转载 作者:太空宇宙 更新时间:2023-11-03 23:29:46 25 4
gpt4 key购买 nike

我正在尝试在 olaris SPARC 上制作以下 makefile

CC=/usr/sfw/bin/gcc

INCPATH=/export/home/compkvar/compile/inc
LIBPATH=/export/home/compkvar/compile/lib
SOURCEPATH=/export/home/compkvar/compile/src

.c.o:
$(CC) -c $< $(INCPATH) -I.


PSOURCE = driver.c

driver : driver.o
$(CC) -I$(INCPATH) -L$(LIBPATH) -o driver driver.c -lprivate

all : driver

clean :
rm driver.o driver

但是我得到以下错误;

/usr/sfw/bin/gcc -I/export/home/compkvar/compile/inc -L/export/home/compkvar/compile/lib -o driver driver.c -lprivate 
Undefined first referenced
symbol in file
isinf /export/home/compkvar/compile/lib/libprivate.so
ld: fatal: Symbol referencing errors. No output written to driver
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `driver'

libprivate.so 共享库存在于“/export/home/compkvar/compile/lib”路径下,但找不到:

bash-3.00$ pwd
/export/home/compkvar/compile/lib
bash-3.00$ ls -latr
total 14116
drwxr-xr-x 2 compkvar other 512 Sep 12 15:34 .
drwxr-xr-x 5 compkvar other 512 Sep 12 15:34 ..
-rwxrwxrwx 1 compkvar other 761180 Sep 12 15:43 libprivate.so
-rwxrwxrwx 1 compkvar other 2275492 Sep 12 15:43 libPricingFunctions.so
-rwxrwxrwx 1 compkvar other 1104576 Sep 12 15:43 libprfUtilities.a
-rwxrwxrwx 1 compkvar other 2275492 Sep 12 15:43 libPricingFunctions.so.1
-rwxrwxrwx 1 compkvar other 761180 Sep 12 15:43 libprivate.so.1
bash-3.00$

提前致谢。

最佳答案

isinf 是数学库的一部分。尝试包括 -lm。

$(CC) -I$(INCPATH) -L$(LIBPATH) -o driver driver.c -lprivate -lm

关于c - 如何在 Makefile 中链接共享库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18765997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com