Install and configure GSL in Windows

Source: Internet
Author: User

1. Download and install GSL

: Http://download.csdn.net/detail/diyoosjtu/5164893,http://download.csdn.net/detail/diyoosjtu/5164899 download two EXE files

Install two files, gsl-1.8.exeand gsl-1.8-src.exe, as shown in the Directory D: \ GSL \.

Ii. Set the compiling environment

(1) For vs2010:

1. Generate the Lib file. The libgsl. lib and libgslcblas. Lib files are not found in the installation directory Lib, but there are two files with the extension def and A (File package format in Linux). Therefore, the files must be converted.

Start Menu: run the command line with cmd in vs. It cannot be run in Windows !!!

Enter the lib directory of The GSL library and enter the following two statements in sequence:
LIB/machine: i386/DEF: libgsl. Def
LIB/machine: i386/DEF: libgslcblas. Def

Look at the lib directory and find the libgsl. lib and libgslcblas. Lib files.

2. Set .. \ gnuwin32l \ libgsl in Bin. DLL and libgslcblas. DLL to D: \ Program Files \ Microsoft Visual Studio 10.0 \ Vc \ bin; copy \ include the entire GSL directory to D: \ Program Files \ Microsoft Visual Studio 10.0 \ Vc \ include; all. copy all lib files to D: \ Program Files \ Microsoft Visual Studio 10.0 \ Vc \ Lib.

(If the first two files specified below are added in this way, they are not required because these files are already available in the system, but we do not recommend using this method, this will make things in the System VC library very messy. We strongly recommend that you use the following method to specify the path !!)

Add the header file path to project> tracking> Configuration Properties> C/C ++> General> additional include directories.

Add the library file path to project> tracking> Configuration Properties> C/C ++> General> additional library directories.

 

Add the dependent library files libgsl. lib and libgslcblas. Lib in project-> tracking-> Configuration properties-> linker-> input-> additional dependencies.

If the developed program uses the GSL library through dynamic connection, you must add:

# DefineGsl_dll

Otherwise, a running error occurs in the program.

Iii. Test The GSL Library

#define GSL_DLL#include <gsl/gsl_spline.h>#include <cstdio>#include <cstdlib>#include <cmath>#include <gl/glut.h>#include <gl/gl.h>void Display(){    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);    const size_t n = 4;    double x[] = {0,0.333336,0.666666,1};    double y[] = {0,0.5,0.9,0};    gsl_interp* interps[3] = {NULL,NULL,NULL};    interps[0] = gsl_interp_alloc(gsl_interp_linear,n);    interps[1] = gsl_interp_alloc(gsl_interp_polynomial,n);    interps[2] = gsl_interp_alloc(gsl_interp_cspline,n);    gsl_interp_init(interps[0],x,y,n);    gsl_interp_init(interps[1],x,y,n);    gsl_interp_init(interps[2],x,y,n);    gsl_interp_accel* acc = gsl_interp_accel_alloc();    glBegin(GL_LINE_STRIP);        for(double t=0.0; t<=1.025; t+=0.025)        {            glColor3f(1,0,0);            glVertex3f(t,gsl_interp_eval(interps[0],x,y,t,acc),0.0);        }    glEnd();    glBegin(GL_LINE_STRIP);        for(double t=0.0; t<=1.025; t+=0.025)        {            glColor3f(0,1,0);            glVertex3f(t,gsl_interp_eval(interps[1],x,y,t,acc),0.0);        }    glEnd();    glBegin(GL_LINE_STRIP);        for(double t=0.0; t<=1.025; t+=0.025)        {            glColor3f(0,0,1);            glVertex3f(t,gsl_interp_eval(interps[2],x,y,t,acc),0.0);        }    glEnd();    gsl_interp_accel_free(acc);    gsl_interp_free(interps[0]);    gsl_interp_free(interps[1]);    gsl_interp_free(interps[2]);    glutSwapBuffers();}int main(int argc, char** argv){    glutInit(&argc,argv);    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);    glutInitWindowSize(512,512);    glutCreateWindow("GSL Interpolation");    glutDisplayFunc(Display);    glClearColor(1,1,1,1);    glMatrixMode(GL_MODELVIEW);    glLoadIdentity();    glTranslatef(-1,-1,0);    glScalef(2,2,1);    glMatrixMode(GL_PROJECTION);    glLoadIdentity();    glViewport(0,0,512,512);    glLineWidth(4.0);    glutMainLoop();    return 0;}

Running result:

 

This indicates that the GSL function library is ready for use.

Http://blog.csdn.net/lxiaoxiaot/article/details/6255510

Http://blog.csdn.net/mooncircle/article/details/5545448

Http://www.foelin.com/2009/04/windows-%E7%8E%AF%E5%A2%83%E4%B8%8B%E4%BD%BF%E7%94%A8gsl.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.