[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: undefined reference to 'something'



Yinghong Zhou wrote:

> I also used rtc() in my program. The linker doesn't report error on this
> one. Following is how I declare the functions in my program:
> 
> extern "C" {
>         void wssmp( int* N, int* IA, int* JA, double* AVALS, double* DIAG,
>                 int* PERM, int* INVP, double* B, int *LDB,
>                 int* NRHS, double* AUX, int* NAUX, int* MRP, int* IPARM,
>                 double* DPARM );
>         double rtc();
>         void wsetmaxthrds(int*);
>         void wsetnobigmal();
> }

With functions having this sort of signature, I am guessing that the
library was written in FORTRAN?

> Here is how my Makefile looks: 
> all: 
> 	 g++ -o wgsmp wgsmp_ex1.cpp -L../lib/libgoto_opteron-64-r0.99-3.so
> -L../lib -lwsmp64 -lpthread -Wno-deprecated 
> 
> The author said it may have something to do with  the compiler inserting
> trailing underscores, etc.

G77 for reasons unknown likes to add an underscore to the end of the
names of functions defined in FORTRAN.  So in your code, you probably
need to declare and use wssmp_() instead of wssmp(), etc., everywhere.
To avoid the need for the ugly underscore, you can

#define wssmp wssmp_

(etc.) at the top of the file where you declare the functions.

regards,

-- 
Kevin B. McCarty <kmccarty@princeton.edu>   Physics Department
WWW: http://www.princeton.edu/~kmccarty/    Princeton University
GPG: public key ID 4F83C751                 Princeton, NJ 08544



Reply to: