This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cygwin + Windows 7 + (C++) + GNU Science Library (GSL) Not Working

I have a simple piece of C++ code below:

#include <iostream>
#include <cmath>
#include "gsl/gsl_rng.h"
#include "cavlib/constants.hh"

using namespace std;

// Random number generator (between 0 and 1)
double random_number()
  gsl_rng* rng = gsl_rng_alloc( gsl_rng_default );
  double random_number = gsl_rng_uniform( rng );
  gsl_rng_free( rng );
  return random_number;

// Function to estimate the integral using N points
double integral_estimate(int N)

int main(void)
  cout << random_number();
  return 0;

I am using the latest version of Cygwin on Windows 7, with everything that
could possibly be installed on Cygwin.

The cavlib is a library that is in a folder called cavlib with the source
code, which has filename

The cavlib is working fine and I don't think that this is any cause of the

Whenever I try to compile this code in Cygwin it gives the following error:

$ make 8DMonteCarloIntegration
g++   -o 8DMonteCarloIntegration
undefined reference to `_gsl_rng_default'
undefined reference to `_gsl_rng_alloc'
undefined reference to `_gsl_rng_uniform'
undefined reference to `_gsl_rng_free'
collect2: ld returned 1 exit status
make: *** [8DMonteCarloIntegration] Error 1

I am also using a Makefile:

.SUFFIXES: .cc .hh .o 

CC         = g++ -O2 -g -pedantic -Wall 
LIBS       = -lgsl -lgslcblas -lfftw3  
RM         = /bin/rm -f

%.o :
	$(CC) $(INCLUDE) -c -o $@ $<

# Define the source code modules for the library:

SOURCE = \\\\\\\

default: cavlib.a test.exe vec3_test.exe tar

cavlib.a: $(
	ar rv cavlib.a $(	

test.exe: cavlib.a
	$(CC) -o $@ cavlib.a $(LIBS)	

vec3_test.exe: cavlib.a
	$(CC) -o $@ cavlib.a $(LIBS)	

	$(RM) $( cavlib.a
	$(RM) test.exe cavlib.tar vec3_test.exe 

	tar cvf cavlib.tar *.cc *.hh Makefile

It appears there are some problems with using the GSL library, I have tried
to search for a solution here and several other places, but I cannot seem to
find a solution for this, information on this subject is very limited.  Any
kind of help to get this working would be appreciated, thanks.
View this message in context:
Sent from the Cygwin list mailing list archive at

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]