delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/02/22/10:36:29

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=BAYES_00,FORGED_HOTMAIL_RCVD2,FREEMAIL_FROM,TW_CV,TW_LC,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Message-ID: <30986807.post@talk.nabble.com>
Date: Tue, 22 Feb 2011 07:36:11 -0800 (PST)
From: Dilan Shah <mario_fan AT hotmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Cygwin + Windows 7 + (C++) + GNU Science Library (GSL) Not Working
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019