Search code examples
cgsl

Trying to use the GNU Scientific Library, but weird linker errors occur


so i compiled the GSL from source with Cygwin. Everything went fine, i didnt get any errors. But when i try to compile some simple code, i get the following errors:

..\..\..\Programme\CodeBlocks\MinGW\lib\libgsl.a(error.o) In function `gsl_error':
\usr\include\gsl\err\error.c|43|undefined reference to `__getreent'
\usr\include\gsl\err\error.c|44|undefined reference to `__getreent'
\usr\include\gsl\err\error.c|45|undefined reference to `__getreent'
..\..\..\Programme\CodeBlocks\MinGW\lib\libgsl.a(stream.o) In function `gsl_stream_printf':
\usr\include\gsl\err\stream.c|37|undefined reference to `__getreent'
..\..\..\Programme\CodeBlocks\MinGW\lib\libgsl.a(stream.o) In function `gsl_set_stream':
\usr\include\gsl\err\stream.c|61|undefined reference to `__getreent'

I linked the libgsl.a and libgscblas.a libraries, and there are no complains about any other functions.

For future reference: Dont press cancel instead of Ok when you want to set up a toolchain in code::blocks


Solution

  • The error you're seeing is due to the fact that MinGW doesn't link the Cygwin DLL by default.

    MinGW- and Cygwin-compiled libraries don't play that well with each other - while it's possible to get it to work, it's not really a good idea.

    Choose one toolchain for your project, which, in this case, means either setting up Code::Blocks so it uses the Cygwin toolchain instead of the bundled MinGW distribution or compiling GSL with MinGW as well.