I have compiled and installed my boost library in '/media/data/bin' in ubuntu 9.10.
And I have setup the INCLUDE_PATH, LIBRARY_PATH env:
$ echo $INCLUDE_PATH
/media/data/bin/boost/include:
$ echo $LIBRARY_PATH
/media/data/bin/boost/lib:
But when I compile the asio example, I get the following error:
$ g++ blocking_tcp_echo_server.cpp
blocking_tcp_echo_server.cpp:13:26: error: boost/bind.hpp: No such file or directory
blocking_tcp_echo_server.cpp:14:31: error: boost/smart_ptr.hpp: No such file or directory
blocking_tcp_echo_server.cpp:15:26: error: boost/asio.hpp: No such file or directory
blocking_tcp_echo_server.cpp:16:28: error: boost/thread.hpp: No such file or directory
blocking_tcp_echo_server.cpp:18: error: ‘boost’ has not been declared
blocking_tcp_echo_server.cpp:22: error: ‘boost’ has not been declared
blocking_tcp_echo_server.cpp:22: error: expected initializer before ‘<’ token
blocking_tcp_echo_server.cpp:24: error: variable or field ‘session’ declared void
blocking_tcp_echo_server.cpp:24: error: ‘socket_ptr’ was not declared in this scope
What is wrong with
sudo apt-get install libboost-dev
after which you don't need to set any -I and -L flags. If you need Boost 1.40, you can still rebuild the current Debian unstable package.
To save everybody's time, here's the answer I gave to this question elsewhere:
http://permalink.gmane.org/gmane.comp.lib.boost.user/54626
Update 2016-02-11: It is necessary to specify the options directly:
g++ -I<prefix>/include -L <prefix>/lib
or use the right variables:
export CPLUS_INCLUDE_PATH=<prefix>/include
export LIBRARY_PATH=<prefix>/lib
try C_INCLUDE_PATH or use -I compiler option
BTW, use LD_LIBRARY_PATH to help find library
Check that headers is actually there:
/media/data/bin/boost/include/boost/bind.hpp
Also try using -I/media/data/bin/boost/include instead of env variable (notice no space after -I).
Related
I am trying to get the libmongocxx to run on Debian Jessie 64bit after compiling it according to the :
quickstartguide
I added the path the find command returned as the location for the libmongoc-1.0.pc file the compiler is complaining missing:
$: sudo find / -name "libmongoc-1.0.pc"
/opt/mongo-c-driver/src/libmongoc-1.0.pc
/opt/mongo-c/lib/pkgconfig/libmongoc-1.0.pc
I try to set the dependency specific in the pkg path declaration:
PKG_CONFIG_PATH=/opt/mongo-c/lib/pkgconfig c++ --std=c++11 main.cpp - o hellomongo $(pkg-config --cflags --libs libmongocxx)
But I keep getting this error given xx different tries:
Package libmongoc-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libmongoc-1.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libmongoc-1.0', required by 'libmongocxx', not found
c++: error: main.cpp: No such file or directory
c++: fatal error: no input files
compilation terminated.
I hope somebody can enligthen me.
I am new in this domain.
I am installing a library that links to another library (gsl) at run time as follows:
g++ x.cpp y.cpp z.cpp -o abc -lgsl -lm -lgslcblas
I am currently working on a server and hence do not have root privileges.
gsl is a dependency and therefore I did a local installation of gsl. Following are the steps I followed:
1) Downloaded the gsl-latest.tar.gz
2) tar -zxvf gsl-latest.tar.gz
3) From inside the gsl-1.16 (latest) folder I did:
a) ./configure --prefix=local-folder-path
b) make
c) make check
d) make install
Everything is successfully completed.
Now, since the main library links it as run time, I set the path to this bin in the LD_LIBRARY_PATH.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/a/b/c/gsl-1.16-bin/bin/
Now, when I go to the main library's folder and do a 'make' it still gives me the following errors such as:
error: gsl/gsl_vector.h: No such file or directory
error: ‘gsl_vector_get’ was not declared in this scope
error: ‘gsl_vector_set’ was not declared in this scope
error: ‘gsl_vector_get’ was not declared in this scope
error: ‘gsl_vector_set’ was not declared in this scope
error: ‘gsl_vector_memcpy’ was not declared in this scope
At global scope:
error: ISO C++ forbids declaration of ‘gsl_vector’ with no type
error: expected ‘,’ or ‘...’ before ‘*’ token
Do I need to set the path somewhere else too?
Any help would be appreciated.
Thank You
The problem is include paths. You need to add -I to compile line to find the directory.
Also maybe specify RPATH Wikipedia RPATH to specify where to find libraries
I am trying to write an application using c++. I have decided to use gtk3+ and the gtk opengl extensions. Bellow is the build command i am running
gcc -Wall `pkg-config --cflags "gtk+-3.0 gtkglext-1.2.0"` -c -o main.o main.c
This creates the bellow output error
Package gtkglext-1.2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkglext-1.2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkglext-1.2.0' found
If instead of using gtkglext-1.2.0 i use gtkglext-1.0 then this causes alot of compiler warnings.
How can i setup pkg-config properly?
Note: I have brew installed gtk3+ and gtkglext
UPDATE:
howbrew has installed gtkglext-1.2.0 but there is only gtkglext-1.0.pc & gtkglext-x11-1.0.pc available. Bellow is the new build command
gcc -Wall `pkg-config --cflags "gtk+-3.0 gtkglext-1.0 gtkglext-x11-1.0"` -c -o main.o main.c
This causes lots of compile errors, bellow is a sample
In file included from main.c:9: In file included from
/usr/local/Cellar/gtkglext/1.2.0/include/gtkglext-1.0/gtk/gtkgl.h:22:
In file included from
/usr/local/Cellar/gtkglext/1.2.0/include/gtkglext-1.0/gdk/gdkgl.h:34:
In file included from
/usr/local/Cellar/gtkglext/1.2.0/include/gtkglext-1.0/gdk/gdkglpixmap.h:25:
In file included from
/usr/local/Cellar/gtk+/2.24.25/include/gtk-2.0/gdk/gdkpixmap.h:35: In
file included from
/usr/local/Cellar/gtk+/2.24.25/include/gtk-2.0/gdk/gdkdrawable.h:35:
/usr/local/Cellar/gtk+/2.24.25/include/gtk-2.0/gdk/gdkgc.h:198:23:
error: a parameter list without
types is only allowed in a function definition GdkColormap *GSEAL (colormap);
^ /usr/local/Cellar/gtk+/2.24.25/include/gtk-2.0/gdk/gdkgc.h:198:16:
error: duplicate member 'GSEAL' GdkColormap *GSEAL (colormap);
^ /usr/local/Cellar/gtk+/2.24.25/include/gtk-2.0/gdk/gdkgc.h:193:8:
note: previous declaration is here gint GSEAL (clip_x_origin);
^ /usr/local/Cellar/gtk+/2.24.25/include/gtk-2.0/gdk/gdkgc.h:205:27:
error: unknown type name 'GdkGC' void (*get_values) (GdkGC
*gc,
^ /usr/local/Cellar/gtk+/2.24.25/include/gtk-2.0/gdk/gdkgc.h:207:27:
error: unknown type name 'GdkGC' void (*set_values) (GdkGC
*gc,
^ /usr/local/Cellar/gtk+/2.24.25/include/gtk-2.0/gdk/gdkgc.h:210:27:
error: unknown type name 'GdkGC' void (*set_dashes) (GdkGC
*gc,
^ /usr/local/Cellar/gtk+/2.24.25/include/gtk-2.0/gdk/gdkgc.h:225:1:
error: unknown type name 'GdkGC' GdkGC *gdk_gc_new
(GdkDrawable *drawable);
Brew is OSX, right? I don't know much about OSX dev, but in general the pkg-config files get dumped in $prefix/lib/pkgconfig, where prefix depends on what you passed to the configure script, cmake, our whatever underlying build system the package in question uses. Either you can reinstall with a different prefix option or you can modify the PKG_CONFIG_PATH environment variable when building your app like this:
PKG_CONFIG_PATH=$prefix/lib/pkgconfig:$ PKG_CONFIG_PATH gcc command here
Which prepends the correct location of the pkg-config files to PKG_CONFIG_PATH. Where these are I can't tell you, as I know not brew and OSX, but once you find it you're golden. The files should be named gtk+-3.0.pc and gtkglext-1.2.0.pc respectively.
I think I have boost installed properly so I am trying to use the test "first.cpp" found here:
#include<iostream>
#include<boost/any.hpp>
int main()
{
boost::any a(5);
a = 7.67;
std::cout<<boost::any_cast<double>(a)<<std::endl;
}
And I get the following:
Jason#ITHAKA-DB44CFE1 /home/jason
$ g++ -o first first.cpp
first.cpp:2:24: boost/any.hpp: No such file or directory
first.cpp: In function `int main()':
first.cpp:6: error: `boost' has not been declared
first.cpp:6: error: `any' undeclared (first use this function)
first.cpp:6: error: (Each undeclared identifier is reported only once for each
unction it appears in.)
first.cpp:6: error: expected `;' before "a"
first.cpp:7: error: `a' undeclared (first use this function)
first.cpp:8: error: `boost' has not been declared
first.cpp:8: error: `any_cast' undeclared (first use this function)
first.cpp:8: error: expected primary-expression before "double"
first.cpp:8: error: expected `;' before "double"
first.cpp:9:2: warning: no newline at end of file
Jason#ITHAKA-DB44CFE1 /home/jason
$
Where my boost library is in my ./home/Jason/
Obviously something is up. Also, all the boost libraries themselves use this "boost/..." so for some reason either:
1 - I did something wrong with Boost
2 - C++/gcc is not "seeing" my boost
any input?
You need to pass -I/home/Jason/include to gcc, and probably a -L/home/Jason/lib too, because the library is not installed in the standard path. Try:
g++ -I/home/Jason/include -L/home/Jason/lib -o first first.cpp
Also, once compiled, it will not run properly because the libraries are not in the standard path again. To run it, you need to add /home/Jason/lib to the environment variable LD_LIBRARY_PATH.
Edit: As Tony D pointed out, you can set CPLUS_INCLUDE_PATH to /home/Jason/include instead, which is equivalent to the compiler option I gave you.
Edit
If you only want to test your install, you can run the ~/bin/Boost.Test script (assuming you had --with-libraries=test enabled when you installed it). Otherwise there should be a bin directory in hour home (if you used that as prefix), if there is anything with the name Boost in it, try to run it (but remember to set the LD_LIBRARY_PATH before).
header files link to '/usr/include'
$ cd /usr/include
$ sudo ln -s /usr/local/boost_xxxx/boost boost
compile boost library, and copy the so files to '/usr/lib'
$ sudo cp /usr/local/lib/libboost_regex-gcc41-mt-xxxx.so.xxxx /usr/lib/
The packages I'm toying with here are rather unknown, but nevertheless the problem is rather generic. Basically, I'm trying to compile Python module (called rql) with C++ extension. The extension uses external framework called gecode, which contains several libraries. I compiled gecode and installed locally. Now, let the output speak for itself:
red#devel:~/build/rql-0.23.3$ echo $LD_LIBRARY_PATH
/home/red/usr/lib
red#devel:~/build/rql-0.23.3$ ls $LD_LIBRARY_PATH | grep libgecodeint
libgecodeint.so
libgecodeint.so.22
libgecodeint.so.22.0
red#devel:~/build/rql-0.23.3$ python setup.py build
running build
running build.py
package init file './test/__init__.py' not found (or not a regular file)
running build_ext
building 'rql_solve' extension
g++ -pthread -shared build/temp.linux-i686-2.5/gecode-solver.o -lgecodeint -lgecodekernel -lgecodesearch -o build/lib.linux-i686-2.5/rql_solve.so
/usr/bin/ld: cannot find -lgecodeint
collect2: ld returned 1 exit status
error: command 'g++' failed with exit status 1
LD_LIBRARY_PATH is for runtime linker/loader (same effect could be achieved with ldconfig ). What you need is the -L flag:
-L/home/red/usr/lib
on the compiler command line.
Edit:
And - thanks to #bjg for reminding me - you can use LIBRARY_PATH if you don't want to mess with compiler options.
You've apparently modified LD_LIBRARY_PATH to point to a non-standard location in your home directory. Do you know if LD_LIBRARY_PATH in the environment used to call g++ in setup.py matches your shell's environment?
See if you can pass arguments to setup.py to modify the library path or simply pass -L/home/red/usr/lib to g++.