加载共享库时出错:libcrfpp.so.0

时间:2014-09-17 07:07:47

标签: java linux shared-libraries filenotfoundexception

我检查了所有以前的主题,设置

LD_LIBRARY_PATH并相应地遵循。但仍然没有问题。

我正在尝试执行cherrypicker软件并以这种方式执行:

./cherrypicker.sh input.txt

错误讯息:

/root/Desktop/karim/software/cherrypicker1.01/tools/crf++/.libs/lt-crf_test: error while loading shared libraries: libcrfpp.so.0: cannot open shared object file: No such file or directory
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
    at java.util.Vector.get(Vector.java:744)
    at CreateNPSpan.<init>(CreateNPSpan.java:30)
    at CreateNPSpan.main(CreateNPSpan.java:81)
creating feature file....
java.io.FileNotFoundException: input.txt.npspan (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at java.io.FileInputStream.<init>(FileInputStream.java:101)
    at java.io.FileReader.<init>(FileReader.java:58)
    at CherryPick.LoadManualEntities(CherryPick.java:111)
    at CherryPick.LoadEntities(CherryPick.java:139)
    at CherryPick.<init>(CherryPick.java:30)
    at CherryPick.main(CherryPick.java:2188)
Exception in thread "main" java.lang.NullPointerException
    at CherryPick.SortEntityMentions(CherryPick.java:171)
    at CherryPick.LoadEntities(CherryPick.java:141)
    at CherryPick.<init>(CherryPick.java:30)
    at CherryPick.main(CherryPick.java:2188)
classifying clusters using cr joint model.....
creating output.....
Gotcha creating entities : java.lang.NumberFormatException: For input string: "no"

我查了usr/lib但是没有这样的文件。

在目录中:cherrypicker1.01/tools/crf++/.libs我找到了以下文件

crf_learn        feature_index.o  libcrfpp.lai       lt-crf_test  tagger.o
crf_test         feature.o        libcrfpp.o         node.o
encoder.o        lbfgs.o          libcrfpp.so.0.0.0  param.o
feature_cache.o  libcrfpp.a       lt-crf_learn       path.o

对此有何建议?

2 个答案:

答案 0 :(得分:4)

请按照以下步骤操作

  1. 转到http://taku910.github.io/crfpp/#download并下载CRF ++ - 0.58.tar.gz
  2. 解压文件并执行./configuremake install
  3. 在父目录中查找文件sudo find ./ | grep libcrfpp.so.0,从那里您将获得丢失文件所在的位置
  4. 将该文件复制到/usr/libcherrypicker1.01/tools/crf++/.libs/
  5. 现在它应该工作

答案 1 :(得分:2)

库所在的路径取决于传递给--prefixconfigure脚本的值。如果未传递,则根据源代码,默认路径为/usr/local/

实际上,默认情况下/usr/local/lib不存在系统搜索动态库的路径。因此,人们可以这样做:

echo "/usr/local/lib/" | sudo tee /etc/ld.so.conf.d/CRF.conf
sudo rm -f /etc/ld.so.cache
sudo ldconfig

现在,执行:

ldd $(which crf_test)

输出应类似于:

linux-vdso.so.1 (0x00007ffefc1f0000)
libcrfpp.so.0 => /usr/local/lib/libcrfpp.so.0 (0x00007f6b715b4000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f6b71398000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f6b71016000)
libm.so.6 => /lib64/libm.so.6 (0x00007f6b70d0e000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f6b70af7000)
libc.so.6 => /lib64/libc.so.6 (0x00007f6b70737000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6b717f3000)

CRF开发人员可能希望使用RPATH/usr/local/lib/$PREFIX/lib硬编码为二进制文件中要搜索的目录之一。要检查二进制文件是否包含RPATH,请执行以下操作:

objdump -x $binary | grep RPATH