I'm trying to compile this simple (and useless) C++ program with g++ (GCC version 4.8.3), and I'm having problems when linking against a library from SuiteSparse:
#include "ldl.h"
int main() {
int a = 3;
ldl_symbolic(a, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
return 0;
}
When I launch
g++ -c -I<path>/LDL/Include -I<path>/SuiteSparse_config main.cpp
g++ -L<path>/LDL/Lib main.o -lldl
The same happens if the for linking I use gcc instead of g++:
gcc -L<path>/LDL/Lib main.o -lldl
I get this error:
main.o: In function `main':
main.cpp:(.text+0x4a): undefined reference to `ldl_symbolic(int, int*, int*, int*, int*, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status
But if I inspect libldl.a with nm it looks like the symbol is present in the static library:
ldl.o:
U _GLOBAL_OFFSET_TABLE_
0000000000000560 T ldl_dsolve
00000000000004e0 T ldl_lsolve
0000000000000610 T ldl_ltsolve
0000000000000180 T ldl_numeric
00000000000006a0 T ldl_perm
00000000000006d0 T ldl_permt
0000000000000000 T ldl_symbolic
00000000000007b0 T ldl_valid_matrix
0000000000000700 T ldl_valid_perm
U memset
ldll.o:
U _GLOBAL_OFFSET_TABLE_
0000000000000480 T ldl_l_dsolve
0000000000000420 T ldl_l_lsolve
0000000000000530 T ldl_l_ltsolve
0000000000000160 T ldl_l_numeric
00000000000005b0 T ldl_l_perm
00000000000005e0 T ldl_l_permt
0000000000000000 T ldl_l_symbolic
00000000000006c0 T ldl_l_valid_matrix
0000000000000610 T ldl_l_valid_perm
U memset
Any idea on when such a problem may occur?