GSL Vectors

Hello-- I am trying to use the GSL library in C++, and am having an issue with GSL vectors. As header files for other things that I'm using GSL for, I'm including--

# include <C:\cygwin64\usr\include\gsl\gsl_sf_gamma.h>
# include <C:\cygwin64\usr\include\gsl\gsl_sf_expint.h>

The functions that I'm using (like gsl_sf_gamma_inc for example) are working fine, so I seem to be setting up the header files correctly and getting the paths right.

When I try to use gsl vectors, though, I am including--

# include <C:\cygwin64\usr\include\gsl\gsl_vector.h>

When I compile the program, Cygwin appears to be recognizing it as a valid header file, but when I try to start using gsl_vectors in my code, for example--

gsl_vector *v = gsl_vector_alloc(3);

Visual studio is giving me--

Error: identifier "gsl_vector" is undefined

and

Error: identifier "gsl_vector_alloc" is undefined

How can I get this to work?

Thank you!
jt9812Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
Well, where to start? Well, maybe here:

>> so I seem to be setting up the header files correctly and getting the paths right.

Sorry, but to be blunt - a line like

# include <C:\cygwin64\usr\include\gsl\gsl_vector.h>

Open in new window


is gut-wrenching at best. Not only because one of the first 'best-practices' tip that you will get is 'never use an absolute path to include header files', but mainly because it is quite likely that you will run in trouble with gcc/g++ not correctly resolving the location because of a) the drive letter and b) the backslashes. You should use

#include <gsl_vector.h>

Open in new window


and compile your code providing the include path like

g++ -o sample -I/usr/include/gsl -lgsl -L/usr/lib/gsl sample.cpp 

Open in new window


Or, even simpler

#include <gsl/gsl_vector.h>

Open in new window


if you have '/usr/include' in your INCLUDE environment variable

'/usr/lib/gsl'is the path where the libraries should reside, please check it it's the correct one for your system/setup.

BTW, just in case you need them, you'll find examples at http://www.gnu.org/software/gsl/manual/html_node/Example-programs-for-vectors.html
0
sarabandeCommented:
I think you were using the c++ and not the c version of gsl vectors.

then the gsl is not  a prefix but a namespace and was used like

gsl::vector * v = gsl::vector_alloc(3);


see http://gslwrap.sourceforge.net/classgsl_1_1vector.html for a complete reference of the class.

Sara
0
jt9812Author Commented:
OK, well I deleted Cygwin, reinstalled, took the path names out of the header files, used the "-I" to include them from the command line (didn't even know you could do that-- pretty new with this), and all of a sudden the gsl_vectors started working... in Visual Studio, though, for some reason there are red squiggly lines showing up under gsl_vector, gsl_vector_alloc, gsl_vector_set, gsl_vector_get, and gsl_vector_free (almost as if they're misspelled words in MS Word and it's telling me that they're "spelled wrong"), even though functionally they're working fine... any idea why this would be?

Also, once I took the path names out of the header files, there are red squiggly lines under the "# include"s now too for each one...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sarabandeCommented:
for some reason there are red squiggly lines showing up under gsl_vector
visual studio editor makes a syntax check while you were editing by a tool that is called 'intellisense'. while this feature is nearly as clever as a precompiler + compiler, it is sometimes not able to resolve ambiguous definitions given by header files, especially when those headers exert excessive use of conditional macros what is often the case with portable sources of third party libraries.

you may ignore the red underlines as long as the compiler is happy with the code. sometimes "intellisense" is able to "learn" from a successful compilation but not for all cases.  

Sara
0
jt9812Author Commented:
It worked...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.