1

I am trying to compile a program written in C++ using the lpsolve external library. I have written the following line in my .cpp :

#include</var/lib/lpsolve/lp_lib.h>

However, when I'm trying to compile this using g++, I get this weird message :

/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/liblpsolve55.so when searching for -llpsolve55
/usr/bin/ld: skipping incompatible /usr/lib/../lib/liblpsolve55.so when searching for -llpsolve55
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/../../../liblpsolve55.so when searching for -llpsolve55
/usr/bin/ld: skipping incompatible //usr/local/lib/liblpsolve55.so when searching for -llpsolve55
/usr/bin/ld: skipping incompatible //usr/local/lib/liblpsolve55.a when searching for -llpsolve55
/usr/bin/ld: skipping incompatible //usr/lib/liblpsolve55.so when searching for -llpsolve55
/usr/bin/ld: cannot find -llpsolve55
/usr/bin/ld: cannot find -lcolamd
collect2: error: ld returned 1 exit status 

I tried many different things... Even tried to install the library manually, by downloading it from sourceforge taking care of the right version (dev-ux64 in my case) and it seems like none of the solutions I've found on the internet are working ...

By the way, I am using the following command to compile my program :

g++ prog.cpp -llpsolve55 -lcolamd -ldl -o MyExe

EDIT : after specifying the path to the librairies explicitly, i get this :

/tmp/ccIvoPiS.o: In function `main':
flot_max.cpp:(.text+0x36): undefined reference to `make_lp'
flot_max.cpp:(.text+0xd7): undefined reference to `set_int'
flot_max.cpp:(.text+0x159): undefined reference to `set_maxim'
flot_max.cpp:(.text+0x16c): undefined reference to `set_obj_fn'
flot_max.cpp:(.text+0x1d6): undefined reference to `add_constraint'
flot_max.cpp:(.text+0x240): undefined reference to `add_constraint'
flot_max.cpp:(.text+0x2aa): undefined reference to `add_constraint'
flot_max.cpp:(.text+0x314): undefined reference to `add_constraint'
flot_max.cpp:(.text+0x37e): undefined reference to `add_constraint'
/tmp/ccIvoPiS.o:flot_max.cpp:(.text+0x3e8): more undefined references to `add_constraint' follow
/tmp/ccIvoPiS.o: In function `main':
flot_max.cpp:(.text+0x6a4): undefined reference to `solve'
flot_max.cpp:(.text+0x6bd): undefined reference to `get_objective'
flot_max.cpp:(.text+0x704): undefined reference to `get_variables'
collect2: error: ld returned 1 exit status

It just looks like the library isn't loaded as every function listed above are part of the library...

Guillaume Leseur
  • 140
  • 1
  • 1
  • 15

0 Answers0