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)
{
  sin(0);
}

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 8DMonteCarloIntegration.cc

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

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

$ make 8DMonteCarloIntegration
g++     8DMonteCarloIntegration.cc   -o 8DMonteCarloIntegration
/cygdrive/c/Users/DEFAUL~1.DIL/AppData/Local/Temp/ccNuQcib.o:8DMonteCarloIntegration.cc:(.text+0x99):
undefined reference to `_gsl_rng_default'
/cygdrive/c/Users/DEFAUL~1.DIL/AppData/Local/Temp/ccNuQcib.o:8DMonteCarloIntegration.cc:(.text+0xa1):
undefined reference to `_gsl_rng_alloc'
/cygdrive/c/Users/DEFAUL~1.DIL/AppData/Local/Temp/ccNuQcib.o:8DMonteCarloIntegration.cc:(.text+0xaf):
undefined reference to `_gsl_rng_uniform'
/cygdrive/c/Users/DEFAUL~1.DIL/AppData/Local/Temp/ccNuQcib.o:8DMonteCarloIntegration.cc:(.text+0xbd):
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 
INCLUDE    = -I$(GSL_INC) -I$(FFTW_INC)
LIBS       = -lgsl -lgslcblas -lfftw3  
RM         = /bin/rm -f

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

# Define the source code modules for the library:

SOURCE = \
	constants.cc\
	null.cc\
	string_util.cc\
	file_util.cc\
	vector_util.cc\
	gslint_random.cc\
	getopt_pp.cc

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

cavlib.a: $(SOURCE:.cc=.o)
	ar rv cavlib.a $(SOURCE:.cc=.o)	

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

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

clean:
	$(RM) $(SOURCE:.cc=.o) cavlib.a
	$(RM) test.exe cavlib.tar vec3_test.exe 

tar:
	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: http://old.nabble.com/Cygwin-%2B-Windows-7-%2B-%28C%2B%2B%29-%2B-GNU-Science-Library-%28GSL%29-Not-Working-tp30986807p30986807.html
Sent from the Cygwin list mailing list archive at Nabble.com.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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