Reputation: 286
EDIT: Apparantly ~ doesn't work here and only in the shell, replace ~ with '$HOME' and it should work, thanks for everybody who answered.
Trying to compile a project here but it seems it can't find the libraries even though they exist, here is the output of my line and proof that the libraries exist.
pi@raspberrypi ~/Car $ g++ Car.cpp -I~/git/robidouille/raspicam_cv -L~/git/robidouille/raspicam_cv -lraspicamcv -L~/git/userland/build/lib -lmmal_core -lmmal -lmmal_util -lvcos -lbcm_host -I/usr/include/opencv -lopencv_highgui -lopencv_core -lopencv_video -lopencv_imgproc -lpthread -lm
/usr/bin/ld: cannot find -lraspicamcv
/usr/bin/ld: cannot find -lmmal_core
/usr/bin/ld: cannot find -lmmal
/usr/bin/ld: cannot find -lmmal_util
/usr/bin/ld: cannot find -lvcos
/usr/bin/ld: cannot find -lbcm_host
collect2: ld returned 1 exit status
pi@raspberrypi ~/Car $ find ~/ -name libraspicamcv.so
/home/pi/git/robidouille/raspicam_cv/libraspicamcv.so
pi@raspberrypi ~/Car $ find ~/ -name libmmal_core.so
/home/pi/git/userland/build/lib/libmmal_core.so
pi@raspberrypi ~/Car $ find ~/ -name libmmal.so
/home/pi/git/userland/build/lib/libmmal.so
pi@raspberrypi ~/Car $
EDIT: Tried doing
ld -L~/git/userland/build/lib -lmmal_core --verbose
and it gave me
attempt to open ~/git/userland/build/lib/libmmal_core.so failed
but ~/git/userland/build/lib/libmmal_core.so does infact exist, so for some reason it can't seem to open the file while it exists.
Upvotes: 3
Views: 1178
Reputation: 66371
Expanding "~" to your home directory is a feature of the shell, and it is not expanded "inside" a parameter such as -I~/git/robidouille/raspicam_cv
.
When the linker goes looking for the library, it doesn't ask your shell where it is — it tries to find the literal path "~/git/robidouille/raspicam_cv", which doesn't exist.
Replace "~" with "$HOME", which will be expanded by the shell.
Upvotes: 5