GSL installation and use methods: mingw, Vc, Borland C ++ builder, and Windows Development Environment

Source: Internet
Author: User

Source: http://hi.baidu.com/lihui880921/blog/item/5b39044e54ddc5d8d0c86a6c.html

It is very likely that you will need some functions in the program one day, such as gamma, beta, and common logarithm. What do you think, no # I nclude <math. h> right? After so many years of development in computer science, there have been many excellent scientific computing function libraries covering various aspects. All you have to do is import them, substitute parameters, and wait for the results, haha. Forget the big, slow, ugly, and difficult-to-Operate Matlab. (If software is developed like engineering or scientific software, it is just about functionality, regardless of the user's habits or discomfort, the computer industry has long been shut down ......)

By default, you have mastered various C ++ compilers, especially the command line compilation of mingw. Of course, if BS windows is easy to compile large-scale source code in Linux, then ......

Currently known as three major databases support scientific computing, they are gnu gsl, blitz ++ and MTL, we here to use gnu gsl for scientific computing GSL can be downloaded in the http://www.gnu.org, however, it is not a bin release, but it also needs to be compiled by itself, and it does not provide good support for Windows.
Here we can obtain the GSL of LIB used in mingw, which is:
Http://gnuwin32.sourceforge.net/packages/gsl.htm
Here, two files can be downloaded to support programming in windows. They are gsl-1.8-bin.zipand gsl-1.8-dev.zip (the version number may change in the future). The bin provides DLL and the dev header file and Lib (only available here. A format Lib, so VC does not support only mingw), copy the header file to the include directory of mingw, And put lib (two. file a: libgsl. A And libgslcblas. a) Put it under the same directory of your source code, and then you can call the GSL function in the program!
The following is an example
# I nclude <iostream>
# I nclude <GSL/gsl_sf.h>
Int main ()
{
STD: cout <gsl_sf_gamma_inc (1.5, 0.5) <STD: Endl;
STD: cout <gsl_sf_gamma_inc_q (1.5, 0.5) <STD: Endl;
STD: cout <gsl_sf_gamma_inc_p (1.5, 0.5) <STD: Endl;
}

If you want to use GSL in the VC compiler, You can also download the Lib library file here.
Http://www6.in.tum.de /~ Kiss/wingsl.htm
Wingsl
Windows vesrsion of the GNU Scientific Library
Description
Here you will find a MS-VC ++ adaptation of the GNU gsl-1.4 library. It's free in the sense of GNU licensing scheme.
You have the choice to download the complete set of source code and compile yourself or download just the precompiled static/dynamic libraries.
Versions
WinGsl-1.4.xx
Contain the complete set of free source code, help and samples based on gsl-1.4, necessary to compile and use the Scientific Library Under Windows with MS-VC ++ 6.0/7.0
WinGsl-1.4.01/09.07.2004 first release .(~ 3.6 MB)
WinGsl-1.4.02/11.08.2004 current version.
WinGsl-Lib-1.4.xx
Contains a ready-to-use set of static and dynamic libraries generated from WinGsl-1.4.xx.
 
WinGsl-Lib-1.4.01/09.07.2004 first release .(~ 16.8 MB, VC ++ 6.0)
WinGsl-Lib-1.4.02/11.08.2004 current version (VC ++ 6.0 ).
WinGsl-Lib-1.4.03/272138.2004 current version (. NET 2003 ).

Although the version is a little old, it should be enough.
 
With two reprinted articles, I would like to express my gratitude to the original author:
Bytes ---------------------------------------------------------------------------------------------------------------------
Porting GNU mathematical library GSL in Windows
1. gsl porting under Dev-C ++:
(1exe download gsl-1.8.exe:
Http://gnuwin32.sourceforge.net/packages/gsl.htm
(2) install gsl. After installation, the following directory will be available under the installation directory:
\ Contrib \ some gsl-1.8 instructions
\ Bin binary file
Libgsl. dll GSL dynamic link library (GCC-based official version)
Libgsl_d.dll GSL dynamic link library (GCC-based debugging Version)
Libgslcblas. dll cblas dynamic link library (GCC-based official version)
Dynamic Link Library (GCC-based debugging version) of libgce-blas_d.dll cblas)
Gsl-histogram.exe program for Calculating data histograms
The gsl-randist.exe is used to generate programs that obey the specified Distribution
\ Lib Library File
Libgsl. a gsl static link library (GCC-based official version)
Libgsl_d.a GSL static link library (GCC-based debugging Version)
Libgslcblas. A cblas static link library (GCC-based official version)
Libgce-blas_d.a cblas static link library (GCC-based debugging Version)
Libgsl_dll.a libgsl. dll GCC input Library
GCC input library of libgsl_d_dll.a libgsl_d.dll
GCC input library for libgce-blas_dll.a libgslcblas. dll
GCC input library for libgce-blas_d_dll.a libgce-blas_d.dll
Libgsl. Def output libgsl. dll Definition
Libgslcblas. Def output libgslcblas. dll Definition
\ Doc documentation
\ Info
\ Man1
\ Man3
GSL help files in various formats
\ Include \ GSL header file
GSL include files
The main files used are bin, Lib, include \ gsl.
(3) There are two ways to set the dev-C ++ compiling environment:
1. This is the easiest way to install libgsl under the bin directory of gsl. DLL, libgslcblas. copy the DLL file to the bin directory under the dev-C ++ installation directory and libgsl under Lib. a, libgslcblas. copy A to the lib directory under the dev-C ++ installation directory, and copy the entire GSL folder under the include directory to the include directory under the dev-C ++ installation directory. Open Dev-C ++, tool-compile option-compiler, select "Add the following command to the connector command line", and add-lgsl-lgslcblas (that is, libgsl is connected during connection. a, libgslcblas. a. GCC can automatically recognize the prefix lib and suffix. a)
# I nclude <stdio. h>
# I nclude <GSL/gsl_sf_bessel.h>
Int main (void)
{
Double X = 5.0;
Double Y = gsl_sf_bessel_j0 (X );
Printf ("J0 (% G) = %. 18en", x, y );
System ("pause ");
Return 0;
} Port
It can run normally.
2. Open Dev-C ++, the tool-compile option-directory, and add lib and include under the GSL installation directory to the path of the library and header file. Finally, in the compiler options, select "Add the following command to the connector command line" and add-lgsl-lgslcblas to ensure normal use of gsl.
2. gsl porting in Visual C ++ 6.0
(1)download wingsl-lib-1.4.02.zip
Http://www6.in.tum.de /~ Kiss/wingsl.htm
(2) decompress the package to the temporary directory. The library file extension in wingsl is. Lib, which can be used in the compiler of Visual C ++ 6.0.
(3) set the Visual C ++ 6.0 compiling environment in two ways:
1. Copy wingsl. dll and wingsld. dll in the temporary directory ~ \ Microsoft Visual Studio \ vc98 \ bin; copy the entire GSL directory ~ \ Microsoft Visual Studio \ vc98 \ include; all. Lib files under the lib directory are copied ~ \ Microsoft Visual Studio \ vc98 \ Lib. When using the GSL function, in the new project, add the library file you used to the object/library modules file, such as wingsl. lib and so on. Multiple strings can be separated by spaces.
2. Open VC, tools-options-directories, add lib and gsl in the decompressed directory to the search path of the library file and header file, and copy wingsl. dll and wingsld. DLL
~ \ Microsoft Visual Studio \ vc98 \ bin. Add the library file you used to the object/library modules in the new project.
Bytes ---------------------------------------------------------------------------------------------------------------------
GSL usage in Windows Development Environment
2005-9-11
GSL (GNU Scientific Library) is a very good scientific computing function library, which has been introduced in previous articles, this article describes how to use this software library in three different development environments on the Win32 platform.
First Download The GSL Win32 package. You need to download binaries and developer files at the address of gnuwin32 gsl. Download the package, decompress it to a directory D: \ Temp, and start the following steps.
The following describes three different development environments: mingw, Visual C ++ 7.0, and Borland C ++ builder.
I. mingw
First, link the two DLL libraries (libgsl. DLL and libgslcblas. DLL) to the bin directory of mingw (the GCC path must be in path) or to c: \ windows or c: \ windows \ system32, if the program runs, you must find these two dynamic link libraries.
Then copy the GSL directory under D: \ temp \ include \ To the include directory of mingw. These are all header files and must be used during development. Copy libgsl. A and libgslcblas. A under D: \ temp \ Lib to the lib directory of mingw.
Now that everything is ready, you can compile a test program to see if it runs normally. In this way, the entire development process is exactly the same as the development of GSL in Linux.
The compilation command is:
GCC test. C-o text.exe-lgsl

2) Visual C ++ 7.0
As mentioned above, copy the two dynamic link libraries to the directory in the path of path, and then copy D: the GSL directory under \ temp \ include \ is under the include directory of Visual C ++, and then libgsl under D: \ temp \ Lib. lib and ibgslcblas. copy lib to the lib directory of Visual C ++.
In this way, the preparation is complete and a simple program is used for testing:
The compilation command is:
When Cl test. c/link libgsl. Lib is used with IDE, you need to add these two lib files to the Link parameter.
Iii. Borland C ++ Builder
Before copying the two dynamic link libraries to the directory in the path, Copy D: the GSL directory under \ temp \ include \ is under the include directory of Borland C ++ builder.
The steps below are a little troublesome. Go to the directory where the two DLL files are located and use the implib tool in BCB to generate two lib files to be used. The command is as follows:
Implib-AF libgsl. Lib libgsl. dll
Implib-AF libgslcblas. Lib libgslcblas. dll and copy the two lib files to the lib directory of BCB. Libgsl-bcc.lib and libgslcblas-bcc.lib under D: \ teml \ Lib is not available in BCB compilation after my experiments. Only lib files generated by implib can be used.

Start testing now and compile the command:
Bcc32 test. c libgsl. Lib command line is like this. If you use the bcb ide, it will be easier to add these two lib file names to the compilation parameters.
The process is so simple.
The following is the source code of test. C.

# I nclude <stdio. h>
# I nclude <GSL/gsl_sf_bessel.h>
Int main (void)
{
Double X = 5.0;
Double Y = gsl_sf_bessel_j0 (X );
Printf ("J0 (% G) = %. 18en", x, y );
Return 0;
}


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.