Usr/Bin/Ld: Cannot Find -L≪Nameofthelibrary≫

Which missing library results in the message '/usr/bin/ld: cannot find -lglib-2.0'?

It turns out it was the libglib2.0-0:i386 package. It was already installed earlier, but it had not been fully configured.

It was present in the /lib/i386-linux directory and I had to create a symlink to it include it to the fpc.cfg configuration file used by Free Pascal.

locate libglib | grep ^/lib produced:

/lib/i386-linux-gnu/libglib-2.0.so.0
/lib/i386-linux-gnu/libglib-2.0.so.0.4002.0
/lib/x86_64-linux-gnu/libglib-2.0.so.0
/lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0

I symlinked it with the expected name:

ln -s /lib/i386-linux-gnu/libglib-2.0.so.0 /lib/i386-linux-gnu/libglib-2.0.so

then added to the Lazarus installations fpc.cfg file

#ifdef cpui386
-Fl/usr/lib32
-Fl/lib/i386-linux-gnu
#endif

Cannot find a link library (lNrrdIO)

This answer was given by @Tsyvarev:

By making a link named ld you are removing the original linker (ld). Without the linker you definitely cannot build any library. What you need is to make a link named lNrrdIO.a, so it will point to the actual library location: sudo ln -sfn /home/subham/Downloads/NrrdIO-1.9.0-src/lNrrdIO.a lNrrdIO.a (run this command from /usr/lib directory). And restore original /usr/bin/ld file.

Cygwin Gcc error while loading shared libraries?

I have the same problem and I found the solution.

According to the FAQ of Cygwin

Q: Why is C:\cygwin\usr\bin invisible from windows?

A: Because it does not really exist. In cygwin, /usr/bin is just a link to /bin.

So trying to add "C:\cygwin\usr\bin" to PATH will be in vain.

Add "C:\cygwin64\bin" to PATH instead. Hope this helps :)

C++ linux: dlopen can't find .so library

Read the dlopen(3) man page (e.g. by typing man dlopen in a terminal on your machine):

If filename contains a slash ("/"), then it
is interpreted as a (relative or absolute) pathname. Otherwise, the
dynamic linker searches for the library as follows (see ld.so(8) for
further details):

   o   (ELF only) If the executable file for the calling program
contains a DT_RPATH tag, and does not contain a DT_RUNPATH tag,
then the directories listed in the DT_RPATH tag are searched.

o If, at the time that the program was started, the environment
variable LD_LIBRARY_PATH was defined to contain a colon-separated
list of directories, then these are searched. (As a security
measure this variable is ignored for set-user-ID and set-group-ID
programs.)

o (ELF only) If the executable file for the calling program
contains a DT_RUNPATH tag, then the directories listed in that
tag are searched.

o The cache file /etc/ld.so.cache (maintained by ldconfig(8)) is
checked to see whether it contains an entry for filename.

o The directories /lib and /usr/lib are searched (in that order).

So you need to call dlopen("./libLibraryName.so", RTLD_NOW) -not just dlopen("libLibraryName.so", RTLD_NOW) which wants your plugin to be in your $LD_LIBRARY_PATH on in /usr/lib/ etc .... - or add . to your LD_LIBRARY_PATH (which I don't recommend for security reasons).

As Jhonnash answered you should use and display the result of dlerror when dlopen (or dlsym) fails:

  void* dlh = dlopen("./libLibraryName.so", RTLD_NOW);
if (!dlh)
{ fprintf(stderr, "dlopen failed: %s\n", dlerror());
exit(EXIT_FAILURE); };

You might want to read some books like Advanced Linux Programming to get some knowledge about Linux system programming in general.

Linking an external pre-built library in CMake [duplicate]

add_library would mean that you are building the library.

I don't think add_library is what you want, if this is the prebuilt library as you say.

It looks like you just need link_directories and include_directories for the client to be able to find library and header files.



Related Topics



Leave a reply



Submit