This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL 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]

Linking error in MSVC 6.0


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 <iostream>
#include <stdio.h>
#include <math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_roots.h>

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 = &params;

//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 <max_iter);
 return status;
 };


 double my_f (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 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


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