From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5929 invoked by alias); 11 Dec 2002 12:06:45 -0000 Mailing-List: contact gsl-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gsl-discuss-owner@sources.redhat.com Received: (qmail 5847 invoked from network); 11 Dec 2002 12:06:43 -0000 Received: from unknown (HELO escudo.nhh.no) (158.37.96.28) by sources.redhat.com with SMTP; 11 Dec 2002 12:06:43 -0000 Received: from nhh.no (for-02144.valuta.nhh.no [158.37.102.1]) by escudo.nhh.no (8.12.6/8.12.6) with ESMTP id gBBC6feK044092 for ; Wed, 11 Dec 2002 13:06:42 +0100 (CET) Message-ID: <3DF72A20.600133EF@nhh.no> Date: Wed, 11 Dec 2002 04:25:00 -0000 From: Trond Mathias =?iso-8859-1?Q?D=F8skeland?= Organization: NHH X-Accept-Language: en MIME-Version: 1.0 To: gsl-discuss@sources.redhat.com Subject: Linking error in MSVC 6.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2002-q4/txt/msg00219.txt.bz2 This code I compile with GCC without any errors. When I use MSVC I get 18 errors. This although I have added ligsl.lib and libgslcblas.lib to the list of libraries and compiled the DLLs with /MD. Errors: Compiling... oppg51dny.cpp c:\program files\gsl\include\gsl\gsl_precision.h(56) : error C2201: 'gsl_prec_eps' : must have external linkage in order to be exported/imported c:\program files\gsl\include\gsl\gsl_precision.h(56) : error C2734: 'gsl_prec_eps' : const object must be initialized if not extern c:\program files\gsl\include\gsl\gsl_precision.h(56) : error C2133: 'gsl_prec_eps' : unknown size c:\program files\gsl\include\gsl\gsl_precision.h(57) : error C2201: 'gsl_prec_sqrt_eps' : must have external linkage in order to be exported/imported c:\program files\gsl\include\gsl\gsl_precision.h(57) : error C2734: 'gsl_prec_sqrt_eps' : const object must be initialized if not extern c:\program files\gsl\include\gsl\gsl_precision.h(57) : error C2133: 'gsl_prec_sqrt_eps' : unknown size c:\program files\gsl\include\gsl\gsl_precision.h(58) : error C2201: 'gsl_prec_root3_eps' : must have external linkage in order to be exported/imported c:\program files\gsl\include\gsl\gsl_precision.h(58) : error C2734: 'gsl_prec_root3_eps' : const object must be initialized if not extern c:\program files\gsl\include\gsl\gsl_precision.h(58) : error C2133: 'gsl_prec_root3_eps' : unknown size c:\program files\gsl\include\gsl\gsl_precision.h(59) : error C2201: 'gsl_prec_root4_eps' : must have external linkage in order to be exported/imported c:\program files\gsl\include\gsl\gsl_precision.h(59) : error C2734: 'gsl_prec_root4_eps' : const object must be initialized if not extern c:\program files\gsl\include\gsl\gsl_precision.h(59) : error C2133: 'gsl_prec_root4_eps' : unknown size c:\program files\gsl\include\gsl\gsl_precision.h(60) : error C2201: 'gsl_prec_root5_eps' : must have external linkage in order to be exported/imported c:\program files\gsl\include\gsl\gsl_precision.h(60) : error C2734: 'gsl_prec_root5_eps' : const object must be initialized if not extern c:\program files\gsl\include\gsl\gsl_precision.h(60) : error C2133: 'gsl_prec_root5_eps' : unknown size c:\program files\gsl\include\gsl\gsl_precision.h(61) : error C2201: 'gsl_prec_root6_eps' : must have external linkage in order to be exported/imported c:\program files\gsl\include\gsl\gsl_precision.h(61) : error C2734: 'gsl_prec_root6_eps' : const object must be initialized if not extern c:\program files\gsl\include\gsl\gsl_precision.h(61) : error C2133: 'gsl_prec_root6_eps' : unknown size Error executing cl.exe. oppg51dny.exe - 18 error(s), 0 warning(s) Code: #include #include #include #include #include #include using namespace std; struct my_f_params {double a, b, c; }; double my_f (double x, void *params); double my_f_deriv (double x, void *params); void my_f_fdf (double x, void *params, double *y, double *dy); int fdfsolver(gsl_root_fdfsolver* s); int main (void) { double x_lo = -2.0, x_hi = 2.0, x = -1.0; struct my_f_params params = { 0.0 , 0.0, 0.0}; //define functions gsl_function_fdf Ffdf; Ffdf.f = &my_f; Ffdf.df = &my_f_deriv; Ffdf.fdf = &my_f_fdf; Ffdf.params = ¶ms; //define solver types const gsl_root_fdfsolver_type **Tfdf; const gsl_root_fdfsolver_type *fdfsolvertypes[4]; fdfsolvertypes[0] = gsl_root_fdfsolver_newton; fdfsolvertypes[1] = gsl_root_fdfsolver_secant; fdfsolvertypes[2] = gsl_root_fdfsolver_steffenson; fdfsolvertypes[3] = 0; Tfdf = fdfsolvertypes; //define solver gsl_root_fdfsolver *sfdf; // FDFSOLVER while (*Tfdf !=0) { sfdf = gsl_root_fdfsolver_alloc (*Tfdf); gsl_root_fdfsolver_set (sfdf, &Ffdf, x); if (fdfsolver(sfdf)) cout << "Error" << endl; Tfdf = Tfdf + 1; } return 0; }; int fdfsolver(gsl_root_fdfsolver* s) { int status, iter = 0, max_iter = 100; double x=2, x0; double epsabs=0.01, epsrel=0.001; do { iter++; status = gsl_root_fdfsolver_iterate (s); x0 = x; x = gsl_root_fdfsolver_root (s); status = gsl_root_test_delta (x, x0, epsabs, epsrel); if(status == GSL_SUCCESS) { printf ("Converges:\n"); printf("using %s method\n", gsl_root_fdfsolver_name (s)); printf("%5s %10.7f \n", "iter", "x"); }; printf ("%5d %10.7f \n", iter, x); } while (status == GSL_CONTINUE && iter a; double b = p->b; double c = p->c; return sin(2*M_PI*x)-2*x; } double my_f_deriv (double x, void * params) { struct my_f_params *p = (struct my_f_params *)params; double a = p->a; double b = p->b; double c = p->c; return cos(2*M_PI*x)*2*M_PI-2; } void my_f_fdf (double x, void * params, double * y, double * dy) { struct my_f_params *p = (struct my_f_params *)params; double a = p->a; double b = p->b; double c = p->c; *dy = cos(2*M_PI*x)*2*M_PI-2; *y = sin(2*M_PI*x)-2*x; } Trond Døskeland