我正在尝试使用lpsolve外部库编译用C ++编写的程序。 我在.cpp中写了以下这一行:
#include</var/lib/lpsolve/lp_lib.h>
然而,当我尝试使用g ++编译时,我得到了这个奇怪的消息:
/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
我尝试了很多不同的东西......甚至尝试手动安装库,从sourceforge下载它来处理正确的版本(在我的情况下是dev-ux64),似乎没有我找到的解决方案在互联网上工作......
顺便说一句,我使用以下命令编译我的程序:
g++ prog.cpp -llpsolve55 -lcolamd -ldl -o MyExe
编辑:明确指定了librairies的路径后,我得到了这个:
/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
它看起来好像没有加载库,因为上面列出的每个函数都是库的一部分......