链接我的项目C++的问题
Problems with Linking my Project C++
我必须编译并运行一个用C++编写的第三人称项目,不幸的是,我没有C++的经验,在解决了所有的com之后-打桩问题,我面临一系列的衔接问题。我的许多类和函数都会收到典型的链接错误"未定义的引用"。因为代码是真实的-巨大的,由许多不同的文件组成,我向您展示以下是我尝试使用编译和运行的非常小的主文件我有问题的一个函数,以及我在这个函数中遇到的问题小程序出现相同的链接错误。所以希望如果我能找到解决这段代码的方法,我会管理其余部分。在向您展示代码之前,让我在广告中说-在这种情况下,我试图从cplex.h和为了避免一些建议,我已经正确安装了cplex(我可以从以下事实中验证一件事:我可以使用一些cplec函数-没有问题的操作和命令),并且我还添加了cplex作为我的外部库(我使用EclipseIDE),而且我也体验到了同样的lin-其他非cplex函数的king错误。最后,我在过去的几天里对此进行了广泛的研究网站和一般关于链接错误而无法解决我一个人。因此,任何人的帮助都是非常感激的。这就是代码本身:
#include <iostream>
#include "/home/used/cplex/include/ilcplex/cplex.h"// that's my cplex.h path
using namespace std;
int main(){
double temp;
int a,c;
CPXENVptr env;// in these two uses of cplex variables I don't get any error
CPXNETptr net;//
CPXNETgetdj( env , net , &temp , c , a ); // when I try to use this or any function from cplex I get an linking error
return( 0 );
}
我还展示了用cplex.h编写的原始函数,以确保我能做到这一点函数的正确使用,这样我就不会将链接器与作用
CPXLIBAPI
int CPXPUBLIC
CPXNETgetdj (CPXCENVptr env, CPXCNETptr net, double *dj, int begin,
int end);
打印机错误本身是:
Building target: structures
Invoking: Cross G++ Linker
g++ -o "structures" ./src/div.o ./src/prod.o ./src/structures.o
./src/structures.o: In function `main':
/home/used/workspace/structures/Debug/../src/structures.cpp:21: undefined reference to `CPXNETgetdj'
collect2: error: ld returned 1 exit status
#include "/home/used/cplex/include/ilcplex/cplex.h"
只有在/
位于查找包含中时才能工作。此外,没有任何论点负责实际包括CPLEX库。
为了便于移植,我建议将其更改为#include "ilcplex/cplex.h"
,然后像一样运行
g++ -o "structures" ./src/div.o ./src/prod.o ./src/structures.o
-I/home/used/cplex/include -L/home/used/cplex/lib/x86-64_debian4.0_4.1/static_pic
-lcplex -lilocplex
尽管您必须确定库的实际路径(/home/used/cplex/lib/x86-64_debian4.0_4.1/static_pic
是否为正确路径),并可能将其更正为正确路径。
基于此处的文档。
- 警告处理为错误这里有什么问题
- 最小硬币更换问题(自上而下方法)
- 为"adjacent"变量赋值时出现问题
- 我的神经网络不起作用 [XOR 问题]
- 在Ubuntu 16.04上安装Cilk时出现问题
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 编译包含字符串的代码时遇到问题
- Project Euler问题4的错误解决方案
- 问题:什么是QAbstractItemView::NoEditTriggers的反面
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 在进程中对同一管道进行读取和写入时C++管道出现问题
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++ 雷神库 - 使用资源加载器类时出现问题(不命名类型)
- 一个关于在C++中重载布尔运算符的问题
- 首要问题的答案让值班员搞错了
- setlocale的C++土耳其字符串问题
- 如何重构类层次结构以避免菱形问题
- 基于boost的程序的静态链接——zlib问题
- C++格式化输出问题
- 使用mongocxx驱动程序时包含头文件问题