* Linking error in MSVC 6.0
@ 2002-12-11 4:25 Trond Mathias Døskeland
2002-12-13 6:19 ` Brian Gough
2003-03-29 22:13 ` Linking error problem related to #includes Gaurav Bansal
0 siblings, 2 replies; 4+ messages in thread
From: Trond Mathias Døskeland @ 2002-12-11 4:25 UTC (permalink / raw)
To: gsl-discuss
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 = ¶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 <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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Linking error in MSVC 6.0
2002-12-11 4:25 Linking error in MSVC 6.0 Trond Mathias Døskeland
@ 2002-12-13 6:19 ` Brian Gough
2003-03-29 22:13 ` Linking error problem related to #includes Gaurav Bansal
1 sibling, 0 replies; 4+ messages in thread
From: Brian Gough @ 2002-12-13 6:19 UTC (permalink / raw)
To: Trond Mathias Døskeland; +Cc: gsl-discuss
Trond Mathias Døskeland writes:
> 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.
>
I could not reproduce the problem.
I created an empty "Win32 Console Application" using the new project
wizard and added the code as test.cpp. I set the runtime library to
"Multithreaded DLL" and put libgsl.lib, libgslcblas.lib in the link
library modules option. It compiled and ran.
Brian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Linking error problem related to #includes
2002-12-11 4:25 Linking error in MSVC 6.0 Trond Mathias Døskeland
2002-12-13 6:19 ` Brian Gough
@ 2003-03-29 22:13 ` Gaurav Bansal
2003-03-29 22:30 ` Kevin S D Beach
1 sibling, 1 reply; 4+ messages in thread
From: Gaurav Bansal @ 2003-03-29 22:13 UTC (permalink / raw)
To: Gaurav Bansal; +Cc: gsl-discuss
Hello
I have a program that uses gnu-gsl eigen value library.
Here is the file structure.
WORKING DIRECTORY CONSIST OF
*******************************
gsl - sub folder
deletethis.cpp (driver)
makefile
matrix.cpp
-----
-----
*******************************
gsl SUB DIRECTORY CONSISTS OF (3rd party library)
*******************************
gsl_block.h
gsl_block_complex_long_double.h
gsl_eigen.h
---
---
----
*******************************
deletethis.cpp (driver)
**************************
// deletethis.cpp : Defines the entry point for the console
application.
#include <gsl_eigen.h> // third party library file
#include "matrix.h" // file that i created
int main(int argc, char* argv[]){
---
--
}
***************************
gsl_eigen.h
**********************
#include <gsl_vector.h> //internally 3rd party library includes its
header files as <>
#include <gsl_matrix.h>
----
----
************************
Makefile I am using is
***********************
VPATH = gsl
objects = deletethis.o matrix.o vector_ops.o utility.o symm.o qrstep.o
deletethis : $(objects)
g++ -Igsl $(objects) -o deletethis
deletethis.o: deletethis.cpp
g++ -Igsl -o deletethis.o -c deletethis.cpp
utility.o : utility.cpp
g++ -Igsl -o utility.o -c utility.cpp
vector_ops.o : vector_ops.cpp vector_ops.h
g++ -Igsl -o vector_ops.o -c vector_ops.cpp
matrix.o : matrix.cpp matrix.h vector_ops.h
g++ -Igsl -o matrix.o -c matrix.cpp
symm.o : symm.c qrstep.o gsl_math.h gsl_vector.h gsl_matrix.h
gsl_linalg.h gsl_eigen.h
g++ -Igsl -o symm.o -c symm.c
qrstep.o : qrstep.c
g++ -Igsl -o qrstep.o -c qrstep.c
************************
I am using I switch to make sure gsl sub folder is searched for header
files.
If i try to compile this program, i can get object files created but
there is problem with linking. Here is the output
*************************
$ make
g++ -Igsl -o deletethis.o -c deletethis.cpp
g++ -Igsl -o matrix.o -c matrix.cpp
g++ -Igsl -o vector_ops.o -c vector_ops.cpp
g++ -Igsl -o utility.o -c utility.cpp
g++ -Igsl -o qrstep.o -c qrstep.c
g++ -Igsl -o symm.o -c symm.c
g++ -Igsl deletethis.o matrix.o vector_ops.o utility.o symm.o qrstep.o
-o delete
this
deletethis.o(.text+0x17d):deletethis.cpp: undefined reference to
`_gsl_matrix_vi
ew_array'
deletethis.o(.text+0x18c):deletethis.cpp: undefined reference to
`_gsl_vector_al
loc'
deletethis.o(.text+0x21a):deletethis.cpp: undefined reference to
`_gsl_vector_ge
t'
symm.o(.text+0x5b7):symm.c: undefined reference to `_gsl_error'
symm.o(.text+0x5fc):symm.c: undefined reference to `_gsl_error'
symm.o(.text+0x649):symm.c: undefined reference to `_gsl_error'
symm.o(.text+0x693):symm.c: undefined reference to `_gsl_error'
symm.o(.text+0x7a0):symm.c: undefined reference to `_gsl_error'
symm.o(.text+0x7df):symm.c: more undefined references to `_gsl_error'
follow
symm.o(.text+0x875):symm.c: undefined reference to
`_gsl_vector_view_array'
symm.o(.text+0x892):symm.c: undefined reference to
`_gsl_vector_view_array'
symm.o(.text+0x8b2):symm.c: undefined reference to
`_gsl_vector_view_array'
symm.o(.text+0x8ca):symm.c: undefined reference to
`_gsl_linalg_symmtd_decomp'
symm.o(.text+0x8e3):symm.c: undefined reference to
`_gsl_linalg_symmtd_unpack_T'
symm.o(.text+0xa05):symm.c: undefined reference to
`_gsl_vector_view_array'
symm.o(.text+0xa1d):symm.c: undefined reference to
`_gsl_vector_memcpy'
symm.o(.text$gsl_vector_set+0x3d):symm.c: undefined reference to
`_gsl_error'
symm.o(.text$gsl_matrix_get+0x30):symm.c: undefined reference to
`_gsl_error'
symm.o(.text$gsl_matrix_get+0x66):symm.c: undefined reference to
`_gsl_error'
collect2: ld returned 1 exit status
make: *** [deletethis] Error 1
*********************************
Can someone tell me where i am going wrong. Sorry for the long post. I
tried being as concise as possible.
Thank you in advance.
Gaurav
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Linking error problem related to #includes
2003-03-29 22:13 ` Linking error problem related to #includes Gaurav Bansal
@ 2003-03-29 22:30 ` Kevin S D Beach
0 siblings, 0 replies; 4+ messages in thread
From: Kevin S D Beach @ 2003-03-29 22:30 UTC (permalink / raw)
To: Gaurav Bansal; +Cc: gsl-discuss
On Sat, 2003-03-29 at 17:13, Gaurav Bansal wrote:
> Hello
>
> I have a program that uses gnu-gsl eigen value library.
> $ make
> g++ -Igsl -o deletethis.o -c deletethis.cpp
> g++ -Igsl -o matrix.o -c matrix.cpp
> g++ -Igsl -o vector_ops.o -c vector_ops.cpp
> g++ -Igsl -o utility.o -c utility.cpp
> g++ -Igsl -o qrstep.o -c qrstep.c
> g++ -Igsl -o symm.o -c symm.c
> g++ -Igsl deletethis.o matrix.o vector_ops.o utility.o symm.o qrstep.o
You need to tell the linker which gsl libraries you're using and to
specify the directory using the -L flag. For example, on my machine I
might compile with something like
g++ -I/mit/gnusl/include test.cc -L/mit/gnusl/lib -lgsl -lgslcblas -lm
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-03-29 22:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-11 4:25 Linking error in MSVC 6.0 Trond Mathias Døskeland
2002-12-13 6:19 ` Brian Gough
2003-03-29 22:13 ` Linking error problem related to #includes Gaurav Bansal
2003-03-29 22:30 ` Kevin S D Beach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).