error while loading shared libraries: libtre.so.5: cannot open shared object file: No such file or directory
Hi there, thanks for this amazing library. I am used to work with third-party APIs that expose TRE, but for the first time I will need to use it directly from within C++.
So, here is what I did. I downloaded a copy of the repository and followed the build instructions:
./configure
make
make check
At that point, all checks seemed to work without any errors until the agrep test stage, where only one test is passed - all the rest fail. In the test log, I see many many identical errors:
error while loading shared libraries: libtre.so.5: cannot open shared object file: No such file or directory
For the purpose of further testing, I then continued:
make install
Everything else seems to proceed wit no additional errors. Next, I tried to compile a small test code from a file called test.cpp, located in the root folder, that contains merely:
extern "C" {
#include "tre/lib/tre.h"
}
int main()
{
regex_t tgt;
tre_regcomp(&tgt, "First Try", REG_EXTENDED);
return 0;
}
When I compile with g++ test.cpp -ltre, still no error thrown. However, when I then try ./a.out, I get the error:
./a.out: error while loading shared libraries: libtre.so.5: cannot open shared object file: No such file or directory
How could I solve such issues?
Some tips:
ldd ./a.outwill should you what libraries files the binary requires. But this will probably saylibtre.so.5, duh, not too helpful here.find -name '*.so*'. For me this prints:./lib/.libs/libtre.so.5 ./lib/.libs/libtre.so.5.0.0 ./lib/.libs/libtre.so- Your final
g++ test.cpp -ltreassumes it got installed in the standard system locations. Didmake installactually put it there? Default prefix should put it at/usr/local/lib/libtre.so.5.0.0. Maybe you neededsudo make install(though it should have failed if permissions are the issue). - Look at output of
make check(maybemake clean; makefirst) for compilation commands, what it's linking to. Specifically, search forlibtre. For me, it links to../lib/.libs/libtre.so:libtool: link: gcc -g -O2 -Wall -o .libs/test-str-source test-str-source.o ../lib/.libs/libtre.so -lm -Wl,-rpath -Wl,/usr/local/lib
However, if I rm lib/.libs/libtre.so*, then make check fails with same error as you wrote (in tests/agrep/test-suite.log).
And then, even make && make check doesn't help, the lib is not re-built.
=> So maybe your dir is stuck in some broken state. Try make clean; make; make check.