gphoto2
gphoto2 copied to clipboard
building in non standard locations: undefined reference to symbol 'gp_log@@LIBGPHOTO2_5_0'
I am trying to build gphoto2 in a directory in my $HOME. My purpose is to be able to have a default gphoto2 version and one on which I could try to perform some tests and hopefully participate to the development of gphoto2.
My question is: how do I specify the path to both libgphoto2.so and libgphoto2_port.so when building gphoto2 locally? libgphoto2.so seems to be correctly found but not libgphoto2_port.so.
Steps:
- configure libgphoto2 with the --prefix option, pointing to my desired local install directory.
- build libgphoto2. Ok.
- configure gphoto2 to point to the local libgphoto2 lib directory
- make not ok I have the following error:
/usr/bin/ld: gphoto2-actions.o: undefined reference to symbol 'gp_log@@LIBGPHOTO2_5_0'
/home/ludovic/libs/libgphoto2_gphoto2/lib/libgphoto2_port.so.12: error adding symbols: DSO missing from command line
This is what I have tried:
./configure --help provides some hints:
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
So I thought I could pass the LDFLAGS environment variable to configure but if I do as:
./configure --with-libgphoto2=/home/ludovic/libs/libgphoto2_gphoto2 LDFLAGS=/home/ludovic/libs/libgphoto2_gphoto2/lib
Then I get this error:
configure: error: in `/home/ludovic/Programs/Photography/libgphoto2_gphoto2/gphoto2':
configure: error: C compiler cannot create executables
See `config.log' for more details
The relevant message in config.log tells me:
/usr/bin/ld: cannot find /home/ludovic/libs/libgphoto2_gphoto2/lib: File format not recognized
So this takes me to more research and another attempt, by exporting the LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/ludovic/libs/libgphoto2_gphoto2/lib
And I ran again ./configure but without the LDFLAGS variable. Result: same undefined reference to symbol 'gp_log@@LIBGPHOTO2_5_0' error.
Finally I tried to create a .conf file in /etc/ld.so.conf.d and run sudo ldconfig. Same error.
Hints could be found upon inspecting the output of liggphoto2 ./configure:
Libraries have been installed in:
/home/ludovic/libs/libgphoto2_gphoto2/lib/libgphoto2_port/0.12.0
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
I feel I'm not far from a solution but nothing of what I've tried succeeded! How to concretely put in practice the hint mentioned above?
Note that a related issue was reported here: https://github.com/gphoto/gphoto2/issues/206#issuecomment-473285087
I am experiencing the same error message(s) when trying to compile from source. Any traction on this?
Something is missing in the command that generates the final executable : the declaration of the libgphoto2_port library. Once I added "<customPrefix>/lib/libgphoto2_port.so", the file "gphoto2" was linked and worked like a charm.
I suppose the makefile and also the configure file should be modified.
configure --with-libgphoto2=/home/ludovic/libs/libgphoto2_gphoto2 looks incorrect, it needs libgphoto2 pointed to,.