【问题标题】:Compilation error: /usr/bin/ld: cannot find -lclntsh编译错误:/usr/bin/ld: 找不到 -lclntsh
【发布时间】:2014-08-17 00:57:29
【问题描述】:

在尝试使用 make 文件编译 C 程序时,我遇到了下面描述的以下链接错误。

我知道这类问题已经在许多其他帖子中讨论过,但我尝试了其中建议的解决方案,但都没有奏效。

/usr/bin/ld: 找不到-lclntsh

libclntsh.so 和 libclntsh.so.10.1 存在于 oracle 路径 /u01/app/oracle/product/10.2.0/lib 中,并且在 make 文件中作为 -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 位的问题?
  • ls -alg /u01/app/oracle/product/10.2.0/lib/*clntsh*
  • /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
  • @ ammoq:令人惊讶的是 lib 和 lib32 在我的 10.2 版本的 oracle 安装中指向同一个文件夹。这真的有问题吗?

标签: c compilation linker


【解决方案1】:

您正在将-aarchive 传递给链接器。这是一个 HP/UX 兼容性选项 这是-Bstatic 的同义词,它指示链接器不要链接动态 图书馆。因此,您的 libclntsh.so 将被忽略。见the documentation

如果您不知道为什么会出现此选项,您可以将其删除并重试。如果你 知道这是必要的那么你将不得不找到静态库,包括libclntsh.a 链接反对。

【讨论】:

    【解决方案2】:

    如果您已经安装了 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】:

      对我来说是/usr/bin/ld: cannot find -lclntshcore。由于某种原因,缺少以下符号链接。

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

      【讨论】:

        【解决方案4】:
        [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.
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-01-07
        • 1970-01-01
        • 1970-01-01
        • 2021-02-28
        • 1970-01-01
        • 1970-01-01
        • 2014-10-19
        相关资源
        最近更新 更多