LD can't find libraries when building with cmake - linux

For my thesis work I will have to work with a project that was created with cmake. Therefore, I installed cmake on my PopOS! 21.04 laptop.
cmake --version
cmake version 3.21.3
dpkg doesn't find it though (I had build cmake myself, can I add it to dpkg somehow).
dpkg -l cmake
||/ Name Version Architecture Description
+++-==============-============-============-
===============================>
un cmake <none> <none> (no description
available)`
So I went ahead and downloaded the source code and extracted it on my Desktop. Inside the root source folder I entered:
mkdir build
cd build
sudo cmake ..
sudo cmake --build . --config Release --target install
which works until I get this:
/usr/bin/ld: cannot find -lXrandr /usr/bin/ld: cannot find -lXinerama
/usr/bin/ld: cannot find -lfontconfig /usr/bin/ld: cannot find
-lXrandr /usr/bin/ld: cannot find -lXinerama /usr/bin/ld: cannot find -lfontconfig collect2: error: ld returned 1 exit status gmake[2]: *** [EnvironmentSimulator/Libraries/esminiLib/CMakeFiles/esminiLib.dir/build.make:122:
EnvironmentSimulator/Libraries/esminiLib/libesminiLib.so] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:584:
EnvironmentSimulator/Libraries/esminiLib/CMakeFiles/esminiLib.dir/all]
Error 2 gmake: *** [Makefile:136: all] Error 2
For me it looks like ld cannot find the libraries, if I look if xrandr is in /usr/bin/ it is. I tried linking it with a LD_PATH sth which didnt work and writing to the ld config file.
So now I don't know what else I can try.

Related

Micronucleus does not update

I'm trying to upgrade my micronuclues to upload my code to digispark,but when I try to upgrade that happens:
Building command line tool: micronucleus...
gcc -Ilibrary -O -g -D LINUX -o micronucleus micronucleus.c micronucleus_lib.o littleWire_util.o -static -L/usr/lib/x86_64-linux-gnu -lusb
/usr/bin/ld: cannot find -lusb
collect2: error: ld returned 1 exit status
make: *** [Makefile:61: micronucleus] Error 1
I'm a little confused as to how you've gotten it compiling but not linking because, at least on Debian based distributions, the header file that would be needed during compiling is provided by the same package that provides the libusb.a that it is failing to link against.
If you are on a Debian based distro, try (re)installing libusb-dev:
sudo apt install libusb-dev
This is what I've built it against locally.
If you have a libusb.a and it's not in /usr/lib/x86_64-linux-gnu, then you'd need a different directory supplied to -L.

Installing Caffe on Linux Mint: /usr/bin/ld: cannot find -lhdf5_hl

Whenever I try installing caffe onto my linux mint machine, I keep getting this:
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: error: ld returned 1 exit status
Makefile:572: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1
Do any of you know what I might be doing wrong? Thank you for responding.
If you build caffe using make + Makefile.config, add the location of libhdf5.so (can be retrieved by locate libhdf5.so), for example
/usr/lib/x86_64-linux-gnu/hdf5/serial, to LIBRARY_DIRS variable.
If you use cmake based build, add this path to LD_LIBRARY_PATH and run ldconfig:
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/hdf5/serial:$LD_LIBRARY_PATH
sudo ldconfig

Caffe installation, linking issue

I have the following issue encoutering during caffe installation:
/usr/bin/ld: cannot find -lopencv_imgcodecs
I built opencv3.2, but I believe I have an issue with linking the cv2.cpython-36m-x86_64-linux-gnu.so library. I tried adding it to the LD_LIBRARY_PATH but it still fails with the same error.
Shall I make a link to the cv2.cpython-36m-x86_64-linux-gnu.so in the LD path? if yes, which path exactly shall I make the link in it.
Here is the last few lines of the output (the error msg):
CXX examples/mnist/convert_mnist_data.cpp
CXX .build_release/src/caffe/proto/caffe.pb.cc
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lopencv_imgcodecs
collect2: error: ld returned 1 exit status
Makefile:572: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1
It can't find the way to reach libopencv_imgcodecs.so, check where it is located & add same path in LIBRARY_DIRS of Makefile.config
Open your Makefile.config file, you'll find the following lines:
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
If you've found the location, for example /home/username/anaconda3/envs/env-name/lib, then add it to LIBRARY_DIRS.
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /home/<username>/anaconda3/envs/<env-name>/lib

/usr/bin/ld: cannot find -lxxx

I'm trying to install caffe in Ubuntu 15.04, but get stuck in the make execution. Here is my command and the results. Can anybody help me out?
chauvet#chauvet:~/caffe-master$ make all -j8
LD -o .build_release/lib/libcaffe.so.1.0.0-rc3
/usr/bin/ld: cannot find -lcudart
/usr/bin/ld: cannot find -lcublas
/usr/bin/ld: cannot find -lcurand
/usr/bin/ld: cannot find -lcudnn
collect2: error: ld returned 1 exit status
Makefile:563: recipe for target '.build_release/lib/libcaffe.so.1.0.0-rc3' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1
It seems like cuDNN is not installed in your system.
Try commenting out the line USE_CUDNN := 1 in Makefile.config. Do a make clean and build the project again.

error when trying to link libraries

I am trying to compile my c code on linux i386.
I have the sqlite3 library at:
/usr/lib/i386-linux-gnu/libsqlite3.so.0
/usr/lib/i386-linux-gnu/libsqlite3.so.0.8.6
but the linker does not find them. I even specified the path manually with the -L option which I suspect is not necessary:
cc -pthread -L/lib/i386-linux-gnu -L/usr/lib/i386-linux-gnu -L../i386/debug/lib/ ./bin/i386/debug/*.o -lsculib -lpthread -lsqlite3 -o ../i386/debug/bin/myProgram
/usr/bin/ld: cannot find -lsqlite3
collect2: error: ld returned 1 exit status
make: *** [../i386/debug/bin/core] Error 1
any ideas why it does not find them?
Presumably, you also need the header files.
$ sudo apt-get install libsqlite3-dev

Resources