keep getting "undefined reference to" linker error

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

 



Hello,

I have been trying to solve this one without much success. I was under
the impression that I am missing some little thing but I just cannot
find where I am going wrong.

I am trying to make a small program to use the Taucs library (it is a C
library for solving sparse linear system,
http://www.tau.ac.il/~stoledo/taucs/, tgz with external libs). The
example program I am trying is this:
--------------------------------------------------------------
#define TAUCS_CORE_DOUBLE

#include <taucs.h>

//extern taucs_ccs_matrix* taucs_ccs_create(int m,int n,int nnz,int flags);
//extern void taucs_ccs_free(taucs_ccs_matrix* matrix);

int main(){
    int C,R,k;
    C=20;
    R=20;
    k=4;
    taucs_ccs_matrix *taucAsigmaIMat;
    taucAsigmaIMat = taucs_ccs_create(C, R, (k+1)*C,
				      TAUCS_DOUBLE|TAUCS_SYMMETRIC);

    //cleanup
    taucs_ccs_free(taucAsigmaIMat);
    return 0;
}
-----------------------------------------------------------------

I downloaded the Taucs library in /home/hs/tmp/taucs and compiled it. I
am using the following command to compile my example program above and I
get:
$> make
g++ -g -Wall -c -ansi -Wno-deprecated -I./
-I/home/hs/tmp/taucs/build/linux -I/home/hs/tmp/taucs/src  spmat.cc  -o
spmat.o
g++ spmat.o -o spmat /home/hs/tmp/taucs/lib/linux/libtaucs.a
-L/home/hs/tmp/taucs/lib/linux -ltaucs
-L/home/hs/tmp/taucs/external/lib/linux -latlas  -llapack -lf77blas
-lcblas -latlas  -lmetis -lm -lg2c
spmat.o: In function `main':
/home/hs/tmp/spmat/spmat.cc:15: undefined reference to
`taucs_ccs_create(int, int, int, int)'
/home/hs/tmp/spmat/spmat.cc:18: undefined reference to
`taucs_ccs_free(taucs_ccs_matrix*)'
collect2: ld returned 1 exit status
make: *** [spmat] Error 1


I checked libtaucs.a with nm and found that the two symbols exist:
$> nm lib/linux/libtaucs.a | grep taucs_ccs_create
00000000 T taucs_ccs_create
$> nm lib/linux/libtaucs.a | grep taucs_ccs_free
         U taucs_ccs_free
000000e0 T taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free
         U taucs_ccs_free


So, why is the linker giving the "undefined reference to" error? Any
advice on how to solve this?

thanks,
->HS



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux