Adding GSL Library on Eclipse with the help from MinGW

  1. Download MinGW installer from the official website http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/
  2. Install MinGW with the latest version
  3. Follow the instruction on the guide Getting Started http://mingw.org/wiki/Getting_Started so as to download and set up the gcc and g++ compiler
  4. Download and unzip GSL library source from the offical website ftp://ftp.gnu.org/gnu/gsl/
  5. Copy the GSL source folder to the MinGW installation path, for example, C:\MinGW\msys\1.0\home, which is equivalent to /home in the GNU system
  6. Read the INSTALL in GSL source folder. If you want to have a quick set up, read the instruction under "The simplest way to compile this package is"
  7. Write the code which invokes function in GSL by following the example of GSL in the offical web site

    http://www.gnu.org/software/gsl/manual/html_node/Compiling-and-Linking.html

    http://www.gnu.org/software/gsl/manual/html_node/Linking-programs-with-the-library.html

  8. Download Eclipse IDE for C/C++ Developers (includes Incubating components) from the offical website. http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers-includes-incubating-components/indigor
  9. Unzip and open the eclipse.exe inside.
  10. Follow the instruction to do the initial set up for the IDE.
  11. After that, start a new project and choose MinGW as the toolchain for the project. Then click finish.
  12. Right click your project in the Project Explorer then click Properties.
  13. We need to construct the commands as shown in the GSL example with the steps. below.
  14. Under C/C++ Build –> Settings –> GCC C++ Compiler –> Includes, add the following paths: (supposing your MinGW installation path is C:\MinGW)
    "C:\MinGW\include"
    "C:\MinGW\msys\1.0\local\include"
    "C:\MinGW\msys\1.0\local\include\gsl"
    "C:\MinGW\msys\1.0\include"
    "C:\MinGW\lib\gcc\mingw32\4.5.2\include"
  15. Repeat the previous step under C/C++ Build –> Settings –> GCC C Compiler –> Includes
  16. In MinGW C++ Linker –> Libraries –> Libraries (-l), add the followings:
    gsl
    gslcblas
    m
  17. In MinGW C++ Linker –> Libraries –> Library search path (-L), add the foolowing paths:
    "C:\MinGW\msys\1.0\lib"
    "C:\MinGW\msys\1.0\local\lib"
  18. Create a new C++ file and copy the example of GSL to the editor.
  19. Click Run Configuration, add a new configuration under C/C++ Application and press OK
  20. Rebuild the whole project to see the results

    發佈留言

    發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *