bebops_lost
February 29th, 2008, 10:43 AM
(please pardon the repeat post, I put this up in another section and was advised it was more appropriate here.)
I have done a fair bit of programming in c++, but I am pretty much a nube at Linux.
I've written a c++ code that has dependencies on gsl (gnu scientific library) and I had thought that setting the compiler to include the path to link with your libraries involves adding a simple line to the .bashrc file. For me it has not been so simple.
I've run it several times on other computers, so I know the code itself is bug-free, but it won't link when I try to compile it at home using this:
$ g++ program.cpp -o executable.x
(I also tried using -lgsl, and a few others at the end of this)
my .cpp file starts off like this:
#include <gsl/gsl_sf_log.h>
#include <gsl/gsl_sf_airy.h>
// plus a few other "includes" let's just use these 2 as an example
int main(int argc, char *argv[])
{
double x = gsl_sf_log(3.5);
double y = gsl_sf_airy(2.9);
return 0;
}
//--------------------------------------------------
and then I edited my .bashrc file to include the following 2 lines:
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/ include/
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/include
// I also tried putting ~ symbols before the :
so then I saved copies of all of the header files such as " gsl_sf_log.h" and "gsl_sf_airy.h" in a folder (gsl) i created :
/usr/local/include/gsl
and I also saved libgsl.a, and libgslcblas.a, in that same folder as well as the corresponding .def, and .dll.a files.
Just to be redundant I also tried saving copies of all the above files in /usr/local/include itself as well as /usr/local/lib . I also saved copies of all these files in the directory that I'm working in, and I also tried replacing the #include <> commands with #include ""
then, of course I restarted my terminal program to reload the .bashrc file and tried to compile it as above; I got :
error
undefined reference to `gsl_sf_log'
undefined reference to `gsl_sf_airy_Ai'
anybody know what I'm doing wrong?
-B
__________________
I have done a fair bit of programming in c++, but I am pretty much a nube at Linux.
I've written a c++ code that has dependencies on gsl (gnu scientific library) and I had thought that setting the compiler to include the path to link with your libraries involves adding a simple line to the .bashrc file. For me it has not been so simple.
I've run it several times on other computers, so I know the code itself is bug-free, but it won't link when I try to compile it at home using this:
$ g++ program.cpp -o executable.x
(I also tried using -lgsl, and a few others at the end of this)
my .cpp file starts off like this:
#include <gsl/gsl_sf_log.h>
#include <gsl/gsl_sf_airy.h>
// plus a few other "includes" let's just use these 2 as an example
int main(int argc, char *argv[])
{
double x = gsl_sf_log(3.5);
double y = gsl_sf_airy(2.9);
return 0;
}
//--------------------------------------------------
and then I edited my .bashrc file to include the following 2 lines:
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/ include/
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/include
// I also tried putting ~ symbols before the :
so then I saved copies of all of the header files such as " gsl_sf_log.h" and "gsl_sf_airy.h" in a folder (gsl) i created :
/usr/local/include/gsl
and I also saved libgsl.a, and libgslcblas.a, in that same folder as well as the corresponding .def, and .dll.a files.
Just to be redundant I also tried saving copies of all the above files in /usr/local/include itself as well as /usr/local/lib . I also saved copies of all these files in the directory that I'm working in, and I also tried replacing the #include <> commands with #include ""
then, of course I restarted my terminal program to reload the .bashrc file and tried to compile it as above; I got :
error
undefined reference to `gsl_sf_log'
undefined reference to `gsl_sf_airy_Ai'
anybody know what I'm doing wrong?
-B
__________________