how to find location of missing library - c++

I have installed the mysql connector for c++. I am writing a c++ cgi app. The cgi page has been compiling. I rebooted yesterday and it stopped compiling. g++ -o sales.cgi sales.cpp -lcgicc -lmysqlcppcon. Gives the following error. /usr/bin/ld cannot find -lmysqlcppcon
apt-get tells me I have the latest version of libmysqlcppconn7v5 and i have the latest version of libmyqlcppconn-dev. How do I find the library. I checked /usr/lib/ but I have no idea what I should be looking for.

Since you installed with apt-get, then you can use dpkg to determine which files were installed.
EXAMPLE (you would substitute "mysqlcppcon"):
dpkg -l|grep -i mysql
ii php-mysql 1:7.2+60ubuntu1 all MySQL module for PHP [default]
... <= Search for the exact package name (here, "php-mysql")
dpkg -L php-mysql
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/php-mysql
/usr/share/doc/php-mysql/copyright
/usr/share/doc/php-mysql/changelog.gz
<= List files installed to your system from that package
You can also use find
EXAMPLE:
find / -name "*mysqlcppcon*" -print 2> /dev/null
The *xxx* syntax let's you do a wildcard search; 2> /dev/null filters out irrelevant"noise" from your wildcard search, like "find: ‘/run/lvm’: Permission denied".

Thanks for all of the help. Huge typo on my side. I needed g++ -o sales.cgi sales.cpp -lcgicc -lmysqlcppconn

Related

Tensorflow Op: how to include libtensorflow_framework.so?

I followed the instructions of this tutorial:
https://www.tensorflow.org/extend/adding_an_op#implement_the_gradient_in_python.
There is this comment provided: g++ -std=c++11 -shared zero_out.cc -o zero_out.so -fPIC -I$TF_INC -I$TF_INC/external/nsync/public -L$TF_LIB -ltensorflow_framework -O2
But the linker cannot find -ltensorflow_framework (it should be a tensorflow_frameowork.so file!?)
After some research, I found following links:
https://github.com/tensorflow/tensorflow/issues/1569
https://github.com/eaplatanios/tensorflow_scala/issues/26 --> I downloaded the .jar and linked it via -l/pathto/tensorflow_framework.so, still the fatal error: tensorflow/core/framework/op_kernel.h: No such file or directory is not found.
https://github.com/tensorflow/tensorflow/issues/1270 last comment does not work and so does not help me.
I tried to search for sudo find /usr/. -name "tensorflow_framework.so" recursively but I could not find anything. Tensorflow is installed for sure via anaconda and I also cloned and compiled the repository from source.
How to find a way to include the -ltensorflow_framework?
One answer, I have found:
I have installed my python via anaconda2 and I always tried to find out TF_INC and TF_LIB when I activated my repository source activate <env>. and the could not found any ~/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow
*.so files
This time I went out every python environment with the shell command source deactivate and I typed the following command
python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())'
Now, I got a different path: ~/anaconda2/lib/python2.7/site-packages/tensorflow, where the lib libtensorflow_framework.so is located.
In my case, the file libtensorflow_framework.so.1 existed inside my TF_LIB directory instead of libtensorflow_framework.so. In order to solve this issue, I had to create a symbolic link as follows:
ln -s libtensorflow_framework.so.1 libtensorflow_framework.so
Source: Tensorflow NotFoundError: libtensorflow_framework.so: cannot open shared file or directory
tensorflow_framework is not used before Tensorflow 1.4.1
When you call python from the shell make sure you are calling the right one:
TF_LIB = $(shell python -c 'import tensorflow; print(tensorflow.sysconfig.get_lib())')
or
TF_LIB = $(shell python3 -c 'import tensorflow; print(tensorflow.sysconfig.get_lib())')
To be more clear:
Get the path from python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())', and there is a libtensorflow_framework.so.1 inside the directory. Say /home/.../lib/python3.7/site-packages/tensorflow_core/libtensorflow_framework.so.1
Run ln -s /home/.../lib/python3.7/site-packages/tensorflow_core/libtensorflow_framework.so.1 /home/.../lib/python3.7/site-packages/tensorflow_core/libtensorflow_framework.so

Linking boost::asio using terminal

I am trying to link boost::asio using terminal (I'm also using a text editor).
What I tried
I did some researches on Internet (I didn't found nothing about my distro) - I found I must install that library by executing the following command on the terminal:
sudo pacman -S libboost-all-dev
This is the output I get:
error: the following package was not found: libboost-all-dev
Final question
How can I install and link correctly boost::asio with my .cpp file?
Notes:
I'm using Archlinux
To find a package in Arch Linux, do:
sudo pacman -Ss boost
This will list packages with the string boost. Or, you can look up on the package website: https://www.archlinux.org/packages/extra/x86_64/boost/
One thing you should understand about boost is that a majority of its modules are header-only; if the linker complains about undefined references then you would have to link the required files. To link boost-asio, you would do
g++ -lboost-system <source> <exe>
How to install boost in Arch Linux
You cannot link libraries inside your *.cpp files. You should enumerate required libraries using the -l option in the g++ command line.
g++ -lboos-asio -lboost-system myfile.cpp -o myapp

Boost librairies not found but compilation is ok

I am trying to use filesystem from boost in c++
It seems the compilation is ok when using
"c++ -c Analyse.c -o Analyse.o -g -W -Wall -L/usr/local/lib -lboost_filesystem -lboost_system"
However I have the following error when trying to execute my code :
"error while loading shared libraries: libboost_filesystem.so.1.54.0: cannot open shared object file: No such file or directory", a find / -iname "libboost_system.so.1.54.0
I had some issues to install boost (I first installed the 1.49 and after that 1.54) so I was wondering if there could be any conflict between the 2 version ?
P.S : btw a "find / -iname "libboost_system.so.1.54.0" gave me the following
/usr/include/boost/boost_1_54_0/bin.v2/libs/system/build/gcc-4.7/release/threading-multi/libboost_system.so.1.54.0
/usr/local/lib/libboost_system.so.1.54.0
Try to add the directory before execution. For example:
LD_LIBRARY_PATH="/usr/local/lib/" ./Analyse.o
I encountered this issue very recently, after a fresh installation of boost. In my case, the solution was to simply run
sudo ldconfig
The explanation is that the system keeps a cache of the installed shared libraries (located in /usr/lib, /lib, /usr/local/lib). When the libraries are changed, or new ones are added, the cache is not updated until ldconfig is run. More details can be found in the ldconfig manual.

G++ cannot find library unless it is full path

After installing boost from EPEL 5 on 64-bit CentOS 5.8 I run insto strange problem. I cannot link in other way then providing full path. I.e this works:
g++ ... /usr/lib64/libboost_python.so.5
But this cannot find -lboost_python
g++ ... -L/usr/lib64/ -lboost_python
What could be wrong?
PS. LD_LIBRARY_PATH does not help. It do finds some libraries but even symlinking into /usr/lib does not help. I am building 64-version of program (checked by file *.o).
Try to add a symlink : ln -s /usr/lib64/liboost_python.so /usr/lib64/libboost_python.so.5, then try again.

Linking error : undefined reference to `avahi_alternative_service_name'

in know i need to locate this symbol in library.. I am trying to compile avahi based test code to view services. But i am getting undefined reference toavahi_alternative_service_name'`.. I don't know which library contain this,I am running UBUNTU 12.04. I tried to install several packages but no success.. Any idea
Thanks..
I have following packages installed
dpkg --get-selections | grep avahi
avahi-autoipd install
avahi-daemon install
avahi-utils install
libavahi-cil-dev install
libavahi-client-dev install
libavahi-client3 install
libavahi-client3:i386 install
libavahi-common-data install
libavahi-common-data:i386 install
libavahi-common-dev install
libavahi-common3 install
libavahi-common3:i386 install
libavahi-core7 install
libavahi-glib-dev install
libavahi-glib1 install
libavahi-gobject0 install
libavahi-ui-dev install
libavahi-ui-gtk3-0 install
libavahi-ui0 install
libavahi1.0-cil install
command
gcc -fpermissive testAvahi.c -o testAvahi
Actually needed to locate libraries and then needed to pass them to linker, So follwing command did work for me
gcc -fpermissive testAvahi.c -o testAvahi -L/usr/lib/x86_64-linux-gnu/ -lavahi-client -lavahi-common
if you have a common folder where you place your c++ libraries you can check search for the function using the nm command
something like
cd /usr/lib
nm -AC * | grep avahi_alternative_service_name
The nm utility is available in binutils(sudo apt-get install binutils)