link to boost library - c++

I am trying to build a project using Boost's Asio , but I am getting linking error:
g++ -o homework main.o -L/usr/lib64/qt-3.3/lib -L/usr/X11R6/lib64 -L/home/student/boost_1_46_1/libs -lboost_system -lqt-mt -lXext -lX11 -lm
/usr/bin/ld: cannot find -lboost_system
collect2: ld returned 1 exit status
make: *** [homework] Error 1
How can I resolve the problem?

I think it's a typo. You said -l boost_system in command line, while it should be -lboost_system.
Update:
Nope! I get my answer back. Just found that it's OK to pass -l <libname>. In fact it's equal to -l<libname>. As others said, double-check paths.

Related

Unable to compile of C++ in JGrasp

I am trying to compile a simple Hello World program in C++ on jGrasp but I am getting the following error
----jGRASP exec: g++ -g -o jGHello.exe jGHello.cpp -lglu32 -lfreeglut -lopengl32
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lfreeglut
collect2.exe: error: ld returned 1 exit status
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
I suppose that jGrasp is unable to compile the program due to -lfreeglut being missing. But I am unable to find any mention of it on the internet.
Compiler cant find -lfreeglut, its could be cause two reasons:
It doesnt exits (look if its already install)
Its not on libs path, then u ve to install it on libs path, or tell C++ compiler where is this lib, u can do it like -L /pathToLib
Ej: g++ -g -o jGHello.exe jGHello.cpp -lglu32 -lfreeglut -lopengl32 -L /pathToLib

ITpp ld cannot find -lfftw3 -llapack and -lblas

I install all the external directories required for ITPP compilation(cmake, Itpp-external, Itpp-4.3.0), but still currently facing an error as following:
administrator#ubuntu:~/Desktop/EEP_CC4B9_SBSD3B4_SP_DSTS_2$ make
`itpp-config --cflags`
g++ itpp_ctrl.o rsc_code.o Rayleigh.o irreg_conv_code.o punctured_nsc_code.o dsts.o conv_code.o puncturer.o sphere_packing.o rayleigh_channel.o fileser.o punctured_rsc_code.o softbit.o nsc_code.o robprob.o softsource.o repeater.o ITpp.o -o EEP_CC4B9_SBSD3B4_SP_DSTS.exe -l fftw3 -l lapack -l blas -litpp
/usr/bin/ld: cannot find -lfftw3
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
Makefile:50: recipe for target 'EEP_CC4B9_SBSD3B4_SP_DSTS.exe' failed
make: *** [EEP_CC4B9_SBSD3B4_SP_DSTS.exe] Error 1
Install the external directories with Fortran compiler. Your response will be highly appreciated.

How to eliminate ld errors in ubuntu

I'm getting following errors after running make command:
/usr/bin/ld: cannot find -lGLESv2
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -lEGL
/usr/bin/ld: cannot find -lGLESv2
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -lEGL
/usr/bin/ld: cannot find -lGLESv2
/usr/bin/ld: cannot find -lepoxy
/usr/bin/ld: cannot find -lEGL
/usr/bin/ld: cannot find -laio
/usr/bin/ld: cannot find -lcurl
/usr/bin/ld: cannot find -lssh2
/usr/bin/ld: cannot find -lncursesw
/usr/bin/ld: cannot find -lSDL
collect2: error: ld returned 1 exit status
main/CMakeFiles/esesc.dir/build.make:163: recipe for target 'main/esesc' failed
make[2]: *** [main/esesc] Error 1
CMakeFiles/Makefile2:1041: recipe for target 'main/CMakeFiles/esesc.dir/all' failed
make[1]: *** [main/CMakeFiles/esesc.dir/all] Error 2
Makefile:75: recipe for target 'all' failed
make: *** [all] Error 2
I have tried to search online in these links:
ld cannot find an existing library
usr/bin/ld: cannot find -l<nameOfTheLibrary>
Here I see that every library has to be linked symbolically with the existing library but I'm unsure of doing that. Can anyone please suggest me any technique for doing this?
I know locate <library> and ln commands. Now how to eliminate the above errors using this? Can anyone please elaborate on this? Thanks in advance.
it means you didn't install needed dependencies.
did you install at least libs from this manual? https://github.com/masc-ucsc/esesc/blob/master/docs/Usage.md
sudo apt-get install libepoxy0 libepoxy-dev
should remove epoxy warning, for example
Your link command probably needs a -L to precede those -l.
Search your system for those libnames, for example GLESv2.
I use "locate GLESv2". (Note: locate uses what "sudo updatedb" updates)
On my Unbuntu, the following lines are reported by locate.
> /usr/lib/x86_64-linux-gnu/libGLESv2.so
> /usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so
> /usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2
> /usr/lib/x86_64-linux-gnu/mesa-egl/libGLESv2.so.2.0.0
For the so (the shared object library) found in the first dir, you might try adding the following to your build command.
-L/usr/lib/x86_64-linux-gnu
And repeat for any library name not yet resolved.
Here is an example from my Makefile - note the relative path to a collection of libraries I wrote in a directory "bag"
R01: dtb_acs.cc
rm -f dtb_acs
g++ -m64 -O3 -ggdb -std=c++14 -Wall-Wextra -Wshadow -Wnon-virtual-dtor
-pedantic -Wcast-align -Wcast-qual -Wconversion -Wpointer-arith -Wunused
-Woverloaded-virtual
-O0 dtb_acs.cc -o dtb_acs
-L../../bag -lbag_i686 -lposix_i686 -lrt -pthread
^^^^^^^^^^^ three -l<libname> are in the -L dir
If needed (because the effort did not resolve anything), try adding -l and a specific library, such as -llibGLESv2.so (or .a, as the case may be)
Good luck.

/usr/bin/ld: cannot find -lboost_thread-mt

I am trying to link a project with the following command:
g++ build/test.o -o bin/test -pthread -L lib -L /home/alexander/opt/lib -lboost_thread-mt
which results in the following errors:
/usr/bin/ld: cannot find -lboost_thread-mt
collect2: error: ld returned 1 exit status
However, the boost libraries are installed in the directory /home/alexander/opt/lib. Why does the linker do not find the boost libraries? I also tried to link with -I instead if -L with the same outcome...
Content of /home/alexander/opt/lib is /home/alexander/opt/lib/boost_1_57_0.
change libboost_thread-mt to libboost_thread, first find the address of libboost_thread.so and libboost_thread.a then make softlinks to these files in the same address,
so it should be:
ln -s /...libboostSourceFiles.../libboost_thread.so /..RequestTOmtFiles.../libboost_thread-mt.so
it works for other libboost -mt files too, like serialization , iostreams, programoptions

Libpqxx complaining about missing references

So I have the following problem:
g++ -std=c++0x -O3 -I/usr/include/scip main.cpp locations/locationreader.cpp locations/locationassigner.cpp scheduler.o optimizer.o dbmanager.o scheduleData.o exam.o -o main -L/usr/lib -lscip -lreadline -lgmp -lz -llpispx -lsoplex -lobjscip -lnlpi.cppad -lscipopt -lzimpl -lpqxx -lpq -pthread
/usr/lib/../lib64/libpqxx.so: undefined reference to `PQescapeIdentifier'
collect2: error: ld returned 1 exit status
make: *** [main] Error 1
And I cannot figure out why it cannot find the reference because I have libpq installed and its right there in /usr/lib64
$ ls | grep pq
libpq.so
libpq.so.5
libpq.so.5.2
libpqxx-4.0.so
libpqxx.so
So if I could get any help with this that would be lovely
PQescapeIdentifier appeared in PostgreSQL 9.0, which corresponds to libpq.so.5.3
9.0 release notes have this entry:
Add libpq functions PQescapeLiteral() and PQescapeIdentifier() (Robert
Haas)
You seem to use client libraries from PostgreSQL-8.4 (libpq.so.5.2), that would be why it lacks this function.