问题
I'm trying to compile a .cpp code in ubuntu. It uses a library called "Voxelyze". This is what happen when I compile it in GCC.
$ g++ -Wall -o testeo testeo.cpp -I./Voxelyze-master/include -L./Voxelyze-master/lib -lvoxelyze.0.9
/usr/bin/ld: ./Voxelyze-master/lib/libvoxelyze.0.9.a(VX_LinearSolver.o): in function `CVX_LinearSolver::CVX_LinearSolver(CVoxelyze*)':
VX_LinearSolver.cpp:(.text+0x123): undefined reference to `pardisoinit'
/usr/bin/ld: ./Voxelyze-master/lib/libvoxelyze.0.9.a(VX_LinearSolver.o): in function `CVX_LinearSolver::solve()':
VX_LinearSolver.cpp:(.text+0x2a13): undefined reference to `pardiso'
/usr/bin/ld: VX_LinearSolver.cpp:(.text+0x2b17): undefined reference to `pardiso'
/usr/bin/ld: VX_LinearSolver.cpp:(.text+0x2c26): undefined reference to `pardiso'
/usr/bin/ld: VX_LinearSolver.cpp:(.text+0x2e30): undefined reference to `pardiso'
collect2: error: ld returned 1 exit status
Ok, it seems that there's some "pardiso" thing causing problems. if I go check the VX_LinearSolver.h function I see this:
#ifdef PARDISO_5
#ifdef _WIN32
#pragma comment (lib, "libpardiso500-WIN-X86-64.lib") //link to the Pardiso library
#endif
extern "C" void pardisoinit (void* pt, int* mtype, int* solver, int* iparm, double* dparm, int* error);
extern "C" void pardiso (void* pt, int* maxfct, int* mnum, int* mtype, int* phase, int* n, double* a, int* ia, int* ja, int* perm, int* n>
#endif
If I go to VX_LinearSolver.cpp I see this: (And another one but its kinda long)
#ifdef PARDISO_5
pardisoinit(pt, &mtype, &solver, iparm, dparm, &error); //initialize pardiso
#endif
And if I go to the makefile I see this code line:
FLAGS = -O3 -std=c++11 -DPARDISO_5=1 -Wall $(INCLUDE)
Those are all the pardiso references I could find (so far).
Ok, if I go to the pardiso website, I can download all these files:
libpardiso600-GNU720-X86-64.so
libpardiso600-GNU800-X86-64.so
libpardiso600-WIN-X86-64.dll
libpardiso600-WIN-X86-64.exp
libpardiso600-WIN-X86-64.lib
The last one is similar to the one in the #pragma comment in VX_LinearSolver.h, but its 600 instead of 500. And, on the other hand, I understand that you can't link .lib in ubuntu, it has to be .a or .so.
All that said, my questions are: How do I link pardiso600 in a library that requires a pardiso500? Do I have to change every "PARDISO_5" for "PARDISO_6"? Do I have to move all these pardiso600 files to some specific directory (like /usr/local/lib or so)? Do I have to change the #pragma comment so that it recognizes the .so library instead of a .lib?
I've spent almost a week studing how to compile and link in GCC, but nothing I try works.
来源:https://stackoverflow.com/questions/64174369/how-do-i-link-libpardiso600-in-a-library-that-requires-a-libpardiso500