[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] Solution: Setting up GSL on Windows with VisualStudio
From: |
Andrew Moroz |
Subject: |
[Help-gsl] Solution: Setting up GSL on Windows with VisualStudio |
Date: |
Mon, 05 Apr 2004 00:18:28 -0400 |
It has taken me several hours to figure out how to compile an example program
with Microsoft Visual C++ (.NET 2003), a.k.a. MSVC, and GSL. Since others on
this list have expressed their frustration at the task, I'll describe my
solution, which is probably only one of many. This is done in detail for those
who may not have used MSVC before. Also keep in mind that I am new at this
myself.
1. Download and install
http://umn.dl.sourceforge.net/sourceforge/gnuwin32/gsl-1.0-1.exe
(For more info, see http://gnuwin32.sourceforge.net/packages/gsl.htm)
2. Within VisualStudio, go to File->New->Project, then "Visual C++ Projects,"
then "Win32," then "Win32 Console Application." Enter a name and click "OK." On
the next screen click "Finish."
3. In the "Solution Explorer," right click on the name of your project and go
to "Properties."
4. Under Configuration Properties->Linker->General->Additional Library
Directories, type in "C:\Program Files\GnuWin32\lib"
5. Under Configuration Properties->Linker->Input->Additional Dependencies, type
in "libgslcblas.a libgsl.a"
6. Under Configuration Properties->C/C++->General->Additional Include
Directories, type in "C:\Program Files\GnuWin32\include"
7. Under Configuration Properties->C/C++->Code Generation->Runtime Library,
select "Multi-threaded DLL"
8. Replace the main .cpp file with something like the following:
(Adapted from http://www.gnu.org/software/gsl/manual/gsl-ref_6.html#SEC53)
--------------------------------------------------------------------
#include "stdafx.h"
#include <gsl/gsl_poly.h>
int _tmain(int argc, _TCHAR* argv[])
{
int i;
/* coefficient of P(x) = -1 + x^5 */
double a[6] = { -1, 0, 0, 0, 0, 1 };
double z[10];
gsl_poly_complex_workspace * w
= gsl_poly_complex_workspace_alloc (6);
gsl_poly_complex_solve (a, 6, w, z);
gsl_poly_complex_workspace_free (w);
for (i = 0; i < 5; i++)
{
printf ("z%d = %+.18f %+.18f\n",
i, z[2*i], z[2*i+1]);
}
return 0;
}
-----------------------------------------------------------------
9. Hit F7 to build your program. You should now be able to run it from the
command line. You'll get a result like the following:
z0 = -0.809016994374947670 +0.587785252292473360
z1 = -0.809016994374947670 -0.587785252292473360
z2 = +0.309016994374947510 +0.951056516295152980
z3 = +0.309016994374947510 -0.951056516295152980
z4 = +0.999999999999999890 +0.000000000000000000
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Help-gsl] Solution: Setting up GSL on Windows with VisualStudio,
Andrew Moroz <=