编译错误:/usr/bin/ld: 找不到 -lclntsh

4
尝试使用makefile编译C程序时,我遇到了下面描述的链接错误。我知道这种问题在很多其他帖子中已经讨论过,但是我尝试了其中建议的解决方案,但它们都没有起作用。/usr/bin/ld:找不到-lclntsh libclntsh.so和libclntsh.so.10.1存在于oracle路径/u01/app/oracle/product/10.2.0/lib中,并在make file中以-L选项给出。但我仍然面临着这个问题:-
Linking yieldrpt ...
cc -v -g -D_HPUX_SOURCE -DPARETO -Wl,-aarchive -L/u01/app/oracle/product/10.2.0/lib/         yieldrpt.o  -lclntsh `cat /u01/app/oracle/product/10.2.0/lib/ldflags`   -lmalloc -ldl -lm   \
                -lmalloc -o yieldrpt
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-54)
/usr/libexec/gcc/i386-redhat-linux/4.1.2/collect2 --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 -o yieldrpt /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbegin.o -L/u01/app/oracle/product/10.2.0/lib/ -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.. -aarchive yieldrpt.o -lclntsh -lnbeq10 -lnhost10 -lnus10 -lnldap10 -lldapclnt10 -lnsslb10 -lntcp10 -lntcps10 -lnsslb10 -lntcp10 -lntns10 -lmalloc -ldl -lm -lmalloc -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i386-redhat-linux/4.1.2/crtend.o     /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o
/usr/bin/ld: cannot find -lclntsh
collect2: ld returned 1 exit status
make: *** [yieldrpt] Error 1

请告诉我是否需要其他信息。

谢谢。


可能是32位与64位的问题? - Erich Kitzmueller
1
请执行以下命令:ls -alg /u01/app/oracle/product/10.2.0/lib/*clntsh* - Werner Henze
1
/u01/app/oracle/product/10.2.0/lib/clntsh.map /u01/app/oracle/product/10.2.0/lib/libclntsh.so -> libclntsh.so.10.1 /u01/app/oracle/product/10.2.0/lib/libclntsh.so.10.1 - Bharath
@ ammoq:令人惊讶的是,在我的Oracle 10.2安装中,lib和lib32指向同一个文件夹。这真的会成为问题吗? - Bharath
4个回答

0

您正在将-aarchive传递给链接器。这是一个HP/UX兼容选项,与-Bstatic同义,指示链接器不链接动态库。因此,您的libclntsh.so被忽略了。请参见文档

如果您不知道为什么需要此选项,则可以将其删除并重试。如果您知道它是必需的,则必须找到静态库,包括libclntsh.a进行链接。


0

对我来说,问题出在/usr/bin/ld: cannot find -lclntshcore。由于某种原因,以下符号链接丢失了。

libclntshcore.so -> /home/ubuntu/ora2pg/instantclient_12_2/libclntshcore.so.12.1


0

如果您已经安装了libclntsh.so.12.1或类似的库,您可以尝试使用以下命令将该库符号链接到libclntsh.so:ln -s /usr/lib/oracle/12.1/client64/lib/libclntsh.so.12.1 /usr/lib/oracle/12.1/client64/lib/libclntsh.so


-3
[oracle@em12c bin]$ pwd
/u01/em12c/middleware/oms/bin
[oracle@em12c bin]$ export ORACLE_HOME=/u01/em12c/middleware/oms
[oracle@em12c bin]$ ./genclntsh

[oracle@em12c bin]$ ls -l /u01/em12c/middleware/oms/lib32//libclntsh.so
lrwxrwxrwx. 1 oracle oinstall 17 Oct 23 22:16 /u01/em12c/middleware/oms/lib32//libclntsh.so -> libclntsh.so.11.1

虽然这个答案并不是很详细,但它告诉了我我的问题在于编译器找不到 libclntsh.so。我的问题是我需要一个软链接让编译器找到上述文件。一旦我做到了这一点,它就可以工作了 ==> ln -s libclntsh.so.11.1 libclntsh.so - Carlos

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接