Trying to compile and use OpenFST on Ubuntu 13.10 leads to link errors like "undefined references to dlopen". How does one fix this? Searching online suggests including -ldl
in the gcc command line, but that is not sufficient.
Trying to compile and use OpenFST on Ubuntu 13.10 leads to link errors like "undefined references to dlopen". How does one fix this? Searching online suggests including -ldl
in the gcc command line, but that is not sufficient.
Compile as follows:
To compile your
a.cpp
which uses the library, doIt is important the
-ldl
appears after-Wl,--no-as-needed
.Running your program works as you'd expect from the README provided by OpenFST, you just need to have
/usr/local/lib
in yourLD_LIBRARY_PATH
. For example,As can be seen in the Catalogue of Built-In Rules:
and Variables Used by Implicit Rules:
So in this case
-ldl
should be set or added to LDLIBS, not LDFLAGS.