用特征构建时找不到符号
C++ - Symbols no found when building with eigen
我正在尝试使用特征库。但是当我尝试使用XCode在OSX Mavericks下编译时,我得到以下错误信息:
Undefined symbols for architecture x86_64:
"buildProblem(std::__1::vector<Eigen::Triplet<double, int>, std::__1::allocator<Eigen::Triplet<double, int> > >&, Eigen::Matrix<double, -1, 1, 0, -1, 1>&, int)", referenced from:
_main in main.o
"saveAsBitmap(Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, int, char const*)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我的代码或设置有什么问题?这里你可以看到我的代码:
#include <iostream>
#include </usr/local/include/Eigen/Eigen/Sparse>
#include <vector>
typedef Eigen::SparseMatrix<double> SpMat; // declares a column-major sparse matrix type of double
typedef Eigen::Triplet<double> T;
void buildProblem(std::vector<T>& coefficients, Eigen::VectorXd& b, int n);
void saveAsBitmap(const Eigen::VectorXd& x, int n, const char* filename);
int main(int argc, char** argv)
{
int n = 300; // size of the image
int m = n*n; // number of unknows (=number of pixels)
// Assembly:
std::vector<T> coefficients; // list of non-zeros coefficients
Eigen::VectorXd b(m); // the right hand side-vector resulting from the constraints
buildProblem(coefficients, b, n);
SpMat A(m,m);
A.setFromTriplets(coefficients.begin(), coefficients.end());
// Solving:
Eigen::SimplicialCholesky<SpMat> chol(A); // performs a Cholesky factorization of A
Eigen::VectorXd x = chol.solve(b); // use the factorization to solve for the given right hand side
// Export the result to a file:
saveAsBitmap(x, n, argv[1]);
return 0;
}
缺少的函数saveAsBitmap()
, buildProblem()
和编译示例代码所需的其他定义在此链接中发布。
CMakeLists.txt
文件位于同一个存储库的上面一个目录。我必须在该文件中添加一行cmake_minimum_required(VERSION 3.2)
和删除add_dependencies(all_examples Tutorial_sparse_example)
行来编译代码,现在运行良好。
您需要包含具有saveAsBitmap和buildProblem函数定义的头文件。
相关文章:
- CMake 生成的 MSVC 项目找不到符号,即使为其相关 dll 正确生成了 lib 文件也是如此
- 错误:当我从"WinDbg"打开可执行文件时,找不到符号文件。默认导出 ntdll 的符号.dll
- 编译 GCC-5.0 OS X 狮子 dyld:找不到符号:__ZNKSt11logic_error4whatEv
- 在 Mac 上C++编译代码时处理“dyld:惰性符号绑定失败:找不到符号”错误
- 与 dlopen 的动态链接:找不到符号
- MacOS LD:找不到符号(x86_64)
- dyld:惰性符号绑定失败:找不到符号:_yylex
- OSX MOJAVE -LD:架构X86_64 clang找不到符号:错误:链接器命令失败,出口代码1
- LD:架构x86_64 clang找不到符号:错误:链接器命令失败,出口代码1(使用-v to See
- GCC LD:构造I386找不到符号
- dyld:惰性符号绑定失败:找不到符号.预期在:平面命名空间
- 链接库时找不到符号
- sql::mysql::get_driver_instance()找不到符号
- 在我的嵌套 for 循环中找不到符号"k"?
- 惰性符号绑定失败:找不到符号
- 链接器链接正确的文件,但找不到符号
- 链接器读取库,但在其中找不到符号?未解析的外部符号,但仅适用于 Win32 而不是 x64
- Ctypes 在使用 CMake 创建的共享库中找不到符号
- G++ LD:在体系结构x86_64找不到符号
- ShiftVector 模板类 - "找不到符号"