Error while loading shared library: libconfig++.so.9 - linux

While I compile the code in Makefile, I've put LINKPATH = -L/usr/local/lib in the g++ line. And of course "libconfig++.so.9" is under /usr/local/lib
But when I execute the executable file, it still says cannot find libconfig++.so.9.
Anyone knows why?? Appreciate any help.

You should define LD_LIBRARY_PATH.
For example:
export LD_LIBRARY_PATH=/usr/local/lib

or just use
sudo ldconfig -v

Related

glib-networking cannot find gio/gio.h

I am trying to build glib-networking-2.40.1. I am having trouble with the make step.
Configure step
~/gstreamer/plugins/recommended/good/glib-networking-2.40.1 $ sudo ./configure --disable-glibtest --host=arm-linux-gnueabi --prefix=$DISCIMAGE/usr/local/ --includedir=$DISCIMAGE/usr/include/glib-2.0 --libdir=$DISCIMAGE/usr/lib/arm-linux-gnueabi --libdir=$DISCIMAGE/usr/lib --exec-prefix=$DISCIMAGE/usr/local/ --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/include --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/glib --with-ca-certificates=/etc/ssl/ca-bundle.crt --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/good/gnutls-3.3.7/ --includedir=$DISCIMAGE/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/ --with-gnutls=/home/ubuntu/gstreamer/plugins/recommended/good/gnutls-3.3.7/ --libdir=/usr/lib/arm-linux-gnueabihf/ --libdir=/usr/lib --libdir=/usr/lib/arm-linux-gnueabi --libdir=/usr/lib/arm-linux-gnueabihf/ --libdir=/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/gio/.libs/
then I try
sudo make
and I get the error
CC gnutls-module.lo
gnutls-module.c:22:21: fatal error: gio/gio.h: No such file or directory
gio.h is located at
/home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/gio/
which is included in my configure step
also I have libgio-2.0.so located at
/usr/lib/libgio-2.0.so
and
/usr/lib/arm-linux-gnueabihf/gio/libgio-2.0.so.0
and
/usr/lib/libgio-2.0.so.0
all of which are included in configure
pkg-config gives
sudo pkg-config --libs --cflags gio-2.0
-pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgio-2.0 -lgobject-2.0 -lglib-2.0
Any help would be greatly appreciated
The --includedir and --libdir arguments to configure are supposed to tell your package where to install its own headers and libraries, not where to find other headers and libraries. You should not normally need to use those arguments.
Making that mistake when you compiled GLib is presumably why your gio.h is located at /home/ubuntu/gstreamer/plugins/recommended/gstreamer/glib-2.40.0/gio/ instead of at /usr/include or /usr/local/include.
Instead, the output of pkg-config should tell your program where to find headers and libraries. If you've installed your package properly, then pkg-config's output should be correct. The idea is that instead of you researching where all the libraries live and passing those paths to configure, each library installs a pkg-config file that has that information, so if you know where the pkg-config files are, then you don't need to know anything else.
So probably you should uninstall, recompile, and reinstall all the packages you've been compiling, reconfiguring them without the --include and --libdir arguments.

Compiler says uuid.h not found but apt-get says it is

When compiling my C++ project that includes uuid.h I get the compile error:
fatal error: uuid.h: No such file or directory
I'm not sure whats going wrong. It could be my compiler instructions are wrong or that I indeed dont have that file installed (but I don't think thats the problem).
sudo apt-get install uuid-dev
The above command outputs: uuid-dev is already the newest version
My makefile is simply this:
all:
g++ -o bin/myapplication src/main.cpp -std=c++11
Edit:
In .h file:
#include <uuid.h>
Any ideas what the issue could be?
The package's file list shows that it contains /usr/include/uuid/uuid.h. Since your default include path looks for files relative to /usr/include, you'd need to either write <uuid/uuid.h>, or add -I/usr/include/uuid to your compile options.
However, the package also provides a .pc file for use with pkg-config, which is meant to abstract the details of which compiler options you need to build a program against a library. If you run pkg-config --cflags uuid you get get the output -I/usr/include/uuid, and if you run pkg-config --libs uuid, you get the output -luuid. These are meant to be incorporated into your program's build.
Since it looks like you're using Make, you should add these lines to your Makefile:
CFLAGS += `pkg-config --cflags uuid`
LDFLAGS += `pkg-config --libs uuid`
That'll incoroporate the necessary -I and -l options into your compile commands automatically — and it'll also work on other systems where the UUID library might be installed in a different location.
I bielive in newer version of the uuid the header is <uuid/uuid.h>

Failure using configure of nccmp

I would like to install the nccmp program to compare netCDF files.
Checking the documentation, the installation follows the typical structure:
./configure
make
make check
make install
make clean
However, I'm stuck in the first step because the configure is not able to find my netCDF libraries. But I don't know why.
My libs are not in the default folder, I've installed them in /opt. But I've included the path of the netCDF libs in my LD_LIBRARY_PATH variable.
I tried also to create a link in the default lib folder to my netCDF libs
ln /opt/netcdf-4.2.1.1/lib/libnetcdf.so /usr/lib/libnetcdf.so
ln /opt/netcdf-4.2.1.1/lib/libnetcdff.so /usr/lib/libnetcdff.so
ln /opt/netcdf-4.2.1.1/lib/libnetcdf.a /usr/lib/libnetcdf.a
ln /opt/netcdf-4.2.1.1/lib/libnetcdff.a /usr/lib/libnetcdff.a
But it doesn't work either. I explicitly used the path in the call
./configure --libdir=/opt/netCDF/
I set LIBS and LDFLAGS to
LDFLAGS=-L/opt/netcdf-4.2.1.1/lib/
LIBS=/opt/netcdf-4.2.1.1/lib/
and execute configure then, but with the same bad results:
checking for nc_open in -lnetcdf... no
configure: error: in `/opt/nccmp':
configure: error: Required NetCDF library not found!
In the config.log I see:
configure:3763: gcc -o conftest -g -O2 conftest.c -lnetcdf -lm >&5
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libnetcdf.a(libnetcdf4_la-nc4file.o): In function nc4_rec_read_types':
/opt/NETCDF_BUILD/netcdf-4.2.1.1/libsrc4/nc4file.c:1850: undefined reference toH5Gget_create_plist'
and many more similar lines like that one...
I don't know what else to try, so any help would be really appreciated.
Thanks.
I already found the problem... I needed, as expected, to define LDFLAGS and CFLAGS in my shell and export them to allow the access of configure to those variables.

Cannot find -ly error

I am trying to run a lexx and yacc program and I got the following error:
/usr/bin/ld: cannot find -ly
collect2: error: ld returned 1 exit status
Plz tell me which libraries am I supposed to add?
Could you find liby.a in /lib dir? If you don't have the file, you can use apt-file liby.a to find the package which includes it. In my case, apt install libbison-dev works.
I would guess the problem is that you're using a version of yacc other than the old AT&T yacc which doesn't come with liby (the -ly you have). So you need to remove the -ly option from your command line, and provide your own implementations of main and yyerror.
What version of yacc and lex have the "-ly" parametr?
I used this command in my university:
gcc gram.c gram.h sem.c -ly -ll
or
cc gram.c gram.h sem.c -ly -ll
And works! But on my home komputer doesn't work..

Any way to make LD record shared library name only, no subdirs?

I am linking a Linux executable referencing a shared library:
g++ Debug/file.o Debug/MyLib.so -o Debug/MyApp -Wl,--rpath='$ORIGIN'
The problem is that the generated MyApp file references "Debug/MyLib.so" so if I run it from the Debug directory, it does not find it. Thus, specifying -Wl,--rpath='$ORIGIN' does not help.
Is there a way to tell the GNU LD to use the 'Debug/MyLib.so' file, but record it as just 'MyLib.so' inside the executable?
If don't want to change the name of your library, you can use the soname option when
you create it.
For example:
build the library
$> g++ -fpic -c mylib.cpp
$> g++ -shared -o subdir/mylib.so mylib.o -Wl,-soname=mylib.so
build the program
g++ -o subdir/main main.cpp -Lsubdir -l:mylib.so -Wl,-rpath='$ORIGIN'
(Don't forget the colon after the -l option)
You're linking inappropriately for a shared library. You should rename the library to libMyLib.so, and link your executable using:
g++ Debug/file.o -o Debug/MyApp -Wl,--rpath='$ORIGIN' -LDebug -lMyLib
What the -LDebug says is search in the Debug directory for libraries at link time, and then the -lMyLib says look for a library called libMyLib.so (or libMyLib.a) in the paths that -L specifies, plus the standard library search path.
The standard naming convention for libraries under linux/unix is libLibraryName, and the linker knows when you ask to link to a library using -l, that it should look for a file prefixed lib thatname
When you used it in the prior form, it actually recorded the absolute library that was used when linking, rather than the normal mechanism of just recording the name of the library, and relying on the runpath to resolve the path to the library.

Resources