C++ compiler cannot find Boost libraries even after installing them - c++

While compiling few test applications, I get the following error:
g++: error: −lboost_system: No such file or directory
g++: error: −lboost_filesystem: No such file or directory
while running the following command:
g++ -I/usr/include/boost/ -L/usr/lib/x86_64-linux-gnu/ aescuda.cpp -o test.o −lboost_system −lboost_filesystem
The libraries are installed and present in location as shown below:
<prompt>$ ll /usr/lib/x86_64-linux-gnu/libboost_system.*
-rw-r--r-- 1 root root 49178 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_system.a
lrwxrwxrwx 1 root root 25 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_system.so -> libboost_system.so.1.54.0
-rw-r--r-- 1 root root 14536 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0
<prompt>$ ll /usr/lib/x86_64-linux-gnu/libboost_filesystem.*
-rw-r--r-- 1 root root 217628 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_filesystem.a
lrwxrwxrwx 1 root root 29 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_filesystem.so -> libboost_filesystem.so.1.54.0
-rw-r--r-- 1 root root 88936 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.54.0
Can anyone suggest where am I going wrong :(

You have a wrong character in front of the l:
−lboost_system
It should be an ASCII hyphen:
-lboost_system
This causes the compiler driver to treat the whole string as an input file name (which obviously does not exist, hence the No such file or directory error), and not as an option to be passed to the linker.
(Perhaps consider switching the terminal font.)

Related

QUEX_PATH issue while using tokenizer

I'm trying to install trainable-tokenizer. I have installed all the dependencies as per the README. this is trainable-tokenizer https://github.com/jirkamarsik/trainable-tokenizer. i have installed quex.deb using installer from quex.org which is a dependency for trainable-tokenizer.
when i try to do sudo make install i get the following error
ThinkPad-T430:~/tmp/OpenFST/tokenizer/trainable-tokenizer/src$ sudo make install
[ 6%] Building FeaturesReader with quex
Environment variable QUEX_PATH has not been defined.
error: environment variable 'QUEX_PATH' is not defined.
error: your system is 'posix'.
error: if you are using bash-shell, append the following line
error: to your '~/.bashrc' file:
error:
error: export QUEX_PATH=directory-where-quex-has-been-installed
make[2]: *** [quex_files/trtok_read_features_FeaturesReader] Error 255
make[1]: *** [CMakeFiles/trtok.dir/all] Error 2
make: *** [all] Error 2
but i have already set up the QUEX_PATH.
ThinkPad-T430:~/tmp/OpenFST/tokenizer/trainable-tokenizer/src$ echo $QUEX_PATH
/opt/quex/quex-0.65.4/
ThinkPad-T430:~/tmp/OpenFST/tokenizer/trainable-tokenizer/src$ ll /opt/quex/quex-0.65.4/
total 68
drwxrwxr-x 5 root root 4096 May 25 17:42 ./
drwxrwxr-x 3 root root 4096 May 25 17:42 ../
-rw-r--r-- 1 root root 181 Oct 13 2013 COPYRIGHT.txt
drwxr-xr-x 5 root root 4096 May 25 17:42 demo/
-rw-r--r-- 1 root root 0 Feb 26 02:01 __init__.py
-rwxr-xr-x 1 root root 26424 Oct 13 2013 LGPL.txt*
drwxr-xr-x 2 root root 4096 May 25 17:42 manpage/
drwxr-xr-x 6 root root 4096 May 25 18:02 quex/
-rw-r--r-- 1 root root 3098 Oct 13 2013 quex.bat
-rwxrwxr-x 1 root root 2649 Feb 26 02:01 quex-exe.py*
-rw-r--r-- 1 root root 4074 Oct 13 2013 README
-rw-rw-r-- 1 root root 118 Mar 22 15:22 unit_test_results.txt
i also added export QUEX_PATH=/opt/quex/quex-0.65.4/ to the .bashrc
ThinkPad-T430:~/tmp/OpenFST/tokenizer/trainable-tokenizer/src$ vim ~/.bashrc
ThinkPad-T430:~/tmp/OpenFST/tokenizer/trainable-tokenizer/src$ echo $QUEX_PATH
/opt/quex/quex-0.65.4/
ThinkPad-T430:~/tmp/OpenFST/tokenizer/trainable-tokenizer/src$ sudo make install
[ 6%] Building FeaturesReader with quex
Environment variable QUEX_PATH has not been defined.
error: environment variable 'QUEX_PATH' is not defined.
error: your system is 'posix'.
but still i get the same error.
I fixed the issue using the -I flag. I had to use quex -I.
I would guess that the real problem is that your python is python 3.0+
and not python 2.7 as required for Quex.
Admittedly, the error message does not tell this directly.

Eclipse CDT Post-Build commands error

I have a C++ project and I´m using Eclipse CDT 3.8.1 as the IDE tool, with a workspace of 5 different projects...
One of my projects is a shared library, and at the end of compilation I want to copy its code to a test/bin directory for testing.
I´ve gone to Project Properties -> C/C++ Build -> Settings -> Build Steps and at "Post-build steps", "Command", I´ve added:
cp *.so ../../../bin
(OBS: ../../../bin is the correct path from the Debug folder - I´ve checked already).
What happens is that I get the following error on post build:
cp *.so ../../../bin
cp: cannot stat ‘*.so’: No such file or directory
I said: ok, this may be a permission problem, so I changed the post commands to:
whoami;ls -al; ls *.so;
And I got on Eclipse console:
whoami
aeidev
ls -al
total 264
drwxrwxr-x 3 aeidev aeidev 4096 Apr 25 15:55 .
drwxrwxr-x 5 aeidev aeidev 4096 Apr 22 16:27 ..
-rwxrwxr-x 1 aeidev aeidev 242556 Apr 25 15:55 libaeirtuaccess.so
-rw-rw-r-- 1 aeidev aeidev 1763 Apr 23 20:47 makefile
-rw-rw-r-- 1 aeidev aeidev 245 Apr 23 20:46 objects.mk
-rw-rw-r-- 1 aeidev aeidev 526 Apr 23 20:47 sources.mk
drwxrwxr-x 2 aeidev aeidev 4096 Apr 25 15:41 src
ls *.so
15:55:11 Build Finished (took 1s.80ms)
And them I changed again to ls *.so and I got:
ls -al *.so
ls: cannot access *.so: No such file or directory
15:57:50 Build Finished (took 715ms)
It´s a very strange behaviour. In the same workspace I have a different shared library and the original cp *.so works fine...
Any ideas of what´s going on here ?
Is it a known Eclipse bug ?
Thanks for helping...
I believe the commands are not executed in a shell by default, so wildcards are not evaluated. Try executing like /bin/sh -c 'cp *.so ../../../bin/'. Also you should use Eclipse's built-in variables to copy to the desired path.

Compiling Qt 4.8.3 from source with OpenGL support on CentOS

Trying to compile Qt 4.8.4 with opengl support for installing Visit. I run
./configure -opengl -verbose
The console gives me:
OpenGL auto-detection... ()
g++ -c -m64 -pipe -O2 -Wall -W -I../../../mkspecs/linux-g++-64 -I. -I/usr/include/GL -I/usr/X11R6/include -o opengl.o opengl.cpp
g++ -m64 -Wl,-O1 -o opengl opengl.o -L/usr/lib64/X11 -L/usr/lib64 -lGL -lXext -lX11 -lm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../libGL.so when searching for -lGL
/usr/bin/ld: skipping incompatible /usr/lib/libGL.so when searching for -lGL
/usr/bin/ld: cannot find -lGL
collect2: ld returned 1 exit status
gmake: *** [opengl] Error 1
OpenGL disabled.
OpenGL ES 2.x auto-detection... ()
g++ -c -m64 -pipe -O2 -Wall -W -I../../../mkspecs/linux-g++-64 -I. -I/usr/X11R6/include -o opengles2.o opengles2.cpp
opengles2.cpp:45:25: error: GLES2/gl2.h: No such file or directory
opengles2.cpp: In function ‘int main(int, char**)’:
opengles2.cpp:50: error: ‘GLfloat’ was not declared in this scope
opengles2.cpp:50: error: ‘glUniform1f’ was not declared in this scope
opengles2.cpp:51: error: ‘GL_COLOR_BUFFER_BIT’ was not declared in this scope
opengles2.cpp:51: error: ‘glClear’ was not declared in this scope
gmake: *** [opengles2.o] Error 1
OpenGL ES 2.x disabled.
OpenGL ES 1.x auto-detection... ()
g++ -c -m64 -pipe -O2 -Wall -W -I../../../mkspecs/linux-g++-64 -I. -I/usr/X11R6/include -o opengles1.o opengles1.cpp
opengles1.cpp:45:23: error: GLES/gl.h: No such file or directory
opengles1.cpp: In function ‘int main(int, char**)’:
opengles1.cpp:50: error: ‘GLfloat’ was not declared in this scope
opengles1.cpp:50: error: expected ‘;’ before ‘a’
opengles1.cpp:51: error: ‘a’ was not declared in this scope
opengles1.cpp:51: error: ‘glColor4f’ was not declared in this scope
opengles1.cpp:52: error: ‘GL_COLOR_BUFFER_BIT’ was not declared in this scope
opengles1.cpp:52: error: ‘glClear’ was not declared in this scope
gmake: *** [opengles1.o] Error 1
OpenGL ES 1.x disabled.
All the OpenGL functionality tests failed!
You might need to modify the include and library search paths by editing
QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in
/home/.../Downloads/qt-everywhere-opensource-src-4.8.3/mkspecs/linux-g++-64.
So, i look inside /mkspecs/linux-g++-64, there's only one file, qmake.conf
#
# qmake configuration for linux-g++
#
# Written for GNU/Linux platforms that have both lib and lib64 directories,
# like the AMD Opteron.
#
MAKEFILE_GENERATOR = UNIX
TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl gdb_dwarf_index
QT += core gui
QMAKE_INCREMENTAL_STYLE = sublib
QMAKE_CFLAGS = -m64
QMAKE_LFLAGS = -m64
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
QMAKE_LIBDIR_X11 = /usr/X11R6/lib64
QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib64
I don't have a /usr/X11R6 directory, but X_11 reports that everything is OK in the output.
I add the variables:
QMAKE_INCDIR_OPENGL = /usr/include/GL
QMAKE_LIBDIR_OPENGL = /usr/lib64
QMAKE_LIBS_OPENGL = -lGLU -lGL
Contents of /usr/include/GL:
drwxr-xr-x. 3 root root 4.0K Jun 29 14:26 .
drwxr-xr-x. 46 root root 12K Jun 29 16:07 ..
-rw-r--r--. 1 root root 7.7K Nov 12 2010 freeglut_ext.h
-rw-r--r--. 1 root root 681 Nov 12 2010 freeglut.h
-rw-r--r--. 1 root root 26K Nov 12 2010 freeglut_std.h
-rw-r--r--. 1 root root 710K Dec 13 2013 glext.h
-rw-r--r--. 1 root root 83K Dec 13 2013 gl.h
-rw-r--r--. 1 root root 126K Dec 13 2013 gl_mangle.h
-rw-r--r--. 1 root root 17K Dec 13 2013 glu.h
-rw-r--r--. 1 root root 3.3K Dec 13 2013 glu_mangle.h
-rw-r--r--. 1 root root 639 Nov 12 2010 glut.h
-rw-r--r--. 1 root root 44K Dec 13 2013 glxext.h
-rw-r--r--. 1 root root 17K Dec 13 2013 glx.h
-rw-r--r--. 1 root root 4.6K Feb 23 2013 glxint.h
-rw-r--r--. 1 root root 3.4K Dec 13 2013 glx_mangle.h
-rw-r--r--. 1 root root 2.1K Feb 23 2013 glxmd.h
-rw-r--r--. 1 root root 80K Feb 23 2013 glxproto.h
-rw-r--r--. 1 root root 12K Feb 23 2013 glxtokens.h
drwxr-xr-x. 2 root root 4.0K Jun 25 17:20 internal
contents of /usr/lib64
lrwxrwxrwx. 1 root root 15 Jun 25 17:20 libGLU.so -> libGLU.so.1.3.1
lrwxrwxrwx. 1 root root 15 Jun 25 15:59 libGLU.so.1 -> libGLU.so.1.3.1
-rwxr-xr-x. 1 root root 514K Dec 13 2013 libGLU.so.1.3.1
-rw-r--r--. 1 root root 656 Jun 25 16:20 libGL.la
lrwxrwxrwx. 1 root root 14 Jun 25 17:20 libGL.so -> libGL.so.1.2.0
lrwxrwxrwx. 1 root root 15 Jun 25 16:20 libGL.so.1 -> libGL.so.331.79
-rwxr-xr-x. 1 root root 1.2M Jun 25 16:20 libGL.so.331.79
lrwxrwxrwx. 1 root root 15 Jun 25 17:20 libGLU.so -> libGLU.so.1.3.1
lrwxrwxrwx. 1 root root 15 Jun 25 15:59 libGLU.so.1 -> libGLU.so.1.3.1
-rwxr-xr-x. 1 root root 514K Dec 13 2013 libGLU.so.1.3.1
./configure -opengl -verbose gives the same result
in addition
glxgears
works fine.
What am I doing wrong?
I guess you might install mesa driver that provides libGL.so.1.2.0 and changes the libGL.so symbolic link.
libGL.so -> libGL.so.1.2.0
libGL.so.1 -> libGL.so.331.79
libGL.so.331.79
In /usr/lib64,
rm libGL.so
ln -s libGL.so.1 libGL.so
will give you
libGL.so -> libGL.so.1 -> libGL.so.331.79

g++ link to shared library not being compiled

I have these shared library files in /usr/local/lib:
libopenbabel.so
libopenbabel.so.4
libopenbabel.so.4.0.2
libopenbabel.so is actually a link to libopenbabel.so.4 and libopenbabel.so.4 is actually a link to libopenbabel.so.4.0.2
when I compile my file with this command:
g++ test.cpp -L/usr/local/lib -lopenbabel
and then try to run a.out, I get this error:
./a.out: error while loading shared libraries: libopenbabel.so.4: cannot open shared object file: No such file or directory
Implying that the compiler is finding libopenbabel.so but running into an error when following that link to libopenbabel.so.4 which is in the exact same directory. Any ideas on why this is happening / how I can fix it?
Output of ls -l in /usr/local/lib:
total 33772
drwxr-xr-x 7 root root 4096 Mar 22 01:24 .
drwxr-xr-x 10 root root 4096 Aug 20 2013 ..
drwxr-xr-x 3 root root 4096 Mar 21 23:45 cmake
lrwxrwxrwx 1 root root 13 Mar 21 23:45 libinchi.so -> libinchi.so.0
lrwxrwxrwx 1 root root 17 Mar 21 23:45 libinchi.so.0 -> libinchi.so.0.4.1
-rw-r--r-- 1 root root 3315565 Mar 22 01:04 libinchi.so.0.4.1
lrwxrwxrwx 1 root root 17 Mar 21 23:45 libopenbabel.so -> libopenbabel.so.4
lrwxrwxrwx 1 root root 21 Mar 21 23:45 libopenbabel.so.4 -> libopenbabel.so.4.0.2
-rw-r--r-- 1 root root 31232420 Mar 22 01:04 libopenbabel.so.4.0.2
drwxr-xr-x 3 root root 4096 Mar 21 23:45 openbabel
drwxr-xr-x 2 root root 4096 Mar 22 01:24 pkgconfig
drwxrwsr-x 4 root staff 4096 Mar 3 12:57 python2.7
drwxrwsr-x 3 root staff 4096 Dec 22 18:25 python3.2
Either set your LD_LIBRARY_PATH environment variable to contain /usr/local/lib or add /usr/local/lib to /etc/ld.so.conf and run ldconfig as root.
Also, run ldd a.out to check that dynamic linking works well on your app.
Read ld-linux(8), ldconfig(8), ldd(1)

No OpenGL 3 headers in Arch Linux

I’m trying to compile a very simple “Hello world” OpenGL 3.3 program using FreeGLUT. In all the tutorials I found, they include an header “gl3.h”. The problem is, I don’t have such header file.
$ ls -l /usr/include/GL/
total 2164
-rw-r--r-- 1 root root 8797 20 janv. 17:44 freeglut_ext.h
-rw-r--r-- 1 root root 681 20 janv. 17:44 freeglut.h
-rw-r--r-- 1 root root 26181 20 janv. 17:44 freeglut_std.h
-rw-r--r-- 1 root root 837247 27 janv. 12:55 glew.h
-rw-r--r-- 1 root root 656589 21 mars 18:07 glext.h
-rw-r--r-- 1 root root 84468 21 mars 18:07 gl.h
-rw-r--r-- 1 root root 128943 21 mars 18:07 gl_mangle.h
-rw-r--r-- 1 root root 17255 21 mars 18:07 glu.h
-rw-r--r-- 1 root root 3315 21 mars 18:07 glu_mangle.h
-rw-r--r-- 1 root root 639 20 janv. 17:44 glut.h
-rw-r--r-- 1 root root 62741 27 janv. 12:55 glxew.h
-rw-r--r-- 1 root root 43887 21 mars 18:07 glxext.h
-rw-r--r-- 1 root root 17170 21 mars 18:07 glx.h
-rw-r--r-- 1 root root 4706 3 févr. 13:33 glxint.h
-rw-r--r-- 1 root root 3463 21 mars 18:07 glx_mangle.h
-rw-r--r-- 1 root root 2086 3 févr. 13:33 glxmd.h
-rw-r--r-- 1 root root 80979 3 févr. 13:33 glxproto.h
-rw-r--r-- 1 root root 11246 3 févr. 13:33 glxtokens.h
drwxr-xr-x 2 root root 4096 14 avril 14:03 internal
-rw-r--r-- 1 root root 8497 21 mars 18:07 osmesa.h
-rw-r--r-- 1 root root 51274 21 mars 18:07 vms_x_fix.h
-rw-r--r-- 1 root root 59403 27 janv. 12:55 wglew.h
-rw-r--r-- 1 root root 41377 21 mars 18:07 wglext.h
-rw-r--r-- 1 root root 4468 21 mars 18:07 wmesa.h
In /usr/include/ I only have GL, GLES and GLES2. There is no GL3 as I found in some tutorials.
I’m running on Arch Linux x86_64 with a NVIDIA graphic card (nvidia closed-source driver).
Here is how I included OpenGL and FreeGLUT APIs in my program:
#define GL3_PROTOTYPES 1
#include <GL/gl.h>
#include <GL/freeglut.h>
But the code doesn’t compile:
$ g++ -pipe -g -Wall -Wextra -pedantic -I. -IHeaders -c Sources/Main.cpp -o Temp/Objects/Main.o
Sources/Main.cpp: In function ‘int main(int, char**)’:
Sources/Main.cpp:107:59: error: ‘glVertexAttribPointer’ was not declared in this scope
Sources/Main.cpp:108:30: error: ‘glEnableVertexAttribArray’ was not declared in this scope
Sources/Main.cpp:114:35: error: ‘glUseProgram’ was not declared in this scope
Sources/Main.cpp:138:31: error: ‘glDisableVertexAttribArray’ was not declared in this scope
It seems I included the OpenGL 2 headers! But, again, I didn’t find any OpenGL 3 headers on my system, I looked at the Arch repository and AUR, unsuccessfully.
Thank you for your help!
You don't need a GL3.h, the GL3.h just got rid of all deprecated features. So just include gl.h instead of gl3.h. Downloading and manually copyieng into /usr/include/GL/ is not a real solution, it works yes, but what happens if the add to the mesa package the gl3.h? You're package manager will find conflicts. Better you add the gl3.h to your project or into your home directory and add it to the $PATh or use the -I flag.
If you grep for glVertexAttribPointer, glEnableVertexAttribArray, glUseProgram and glDisableVertexAttribArray, you will find that they are included in glext.h and glew.h. Try to include one of these headers and compile again.