Ubuntu 12.04下用g++编译cplex实例程序,配置、出现的问题,解决办法

比如我要编译的实例程序为ilomipex1.cpp。


编译:g++ -I/home/stan/cplex/opl/include -DIL_STD ilomipex1.cpp -c; 


-DIL_STD选项的作用是为了兼容旧版本的#include <iostream.h>出现的问题。


链接:g++ -L/home/stan/cplex/concert/lib/x86_sles10_4.1/static_pic -L/home/stan/cplex/cplex/lib/x86_sles10_4.1/static_pic ilomipex1.o -o ilomipex1 -lilocplex -lcplex -lconcert -lm -lpthread。。


Ubuntu g++编译cplex,加载链接库的顺序必须为: -lilocplex -lcplex -lconcert,而且要放在命令的最后部分,否则会提示undefined reference to cplexsomething。这点非常非常重要。。


至于网上有些人说链接不通过是因为g++版本太高,我的g++版本是4.5.2,链接没有问题。。


我也试着去安装过低版本的g++,如g++-3.3,版本太低,链接失败,同样出现以下错误:

/home/stan/workspace/libilocplex.a(ilocplex.o): In function `IloCplexI::IloCplexI[in-charge](IloEnvI*, bool, cpxenv* (*)(char const*, int, char const* const*, int*), char const*, int, char const* const*)':
ilocplex.cpp:(.text+0x1ea22): undefined reference to `__cxa_get_exception_ptr'
/home/stan/workspace/libilocplex.a(ilocplex.o): In function `IloCplexI::IloCplexI[not-in-charge](IloEnvI*, bool, cpxenv* (*)(char const*, int, char const* const*, int*), char const*, int, char const* const*)':
ilocplex.cpp:(.text+0x2d0b6): undefined reference to `__cxa_get_exception_ptr'
/home/stan/workspace/libilocplex.a(ilodeflpextr.o): In function `IloDefaultLPExtractor::applySetNames(IloSetNameArrayChange const*, void**)':
ilodeflpextr.cpp:(.text+0x8e8): undefined reference to `__cxa_get_exception_ptr'
/home/stan/workspace/libilocplex.a(ilodeflpextr.o): In function `IloDefaultLPExtractor::doextractObj(IloObjectiveI const*, double&)':
ilodeflpextr.cpp:(.text+0x55b1): undefined reference to `__cxa_get_exception_ptr'
/home/stan/workspace/libconcert.a(iloalg.o): In function `IloAlgorithmI::apply(IloChange const&, IloExtractableI const*)':
iloalg.cpp:(.text+0x6637): undefined reference to `__cxa_get_exception_ptr'
/home/stan/workspace/li

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值