跨平台项目中的eigen错误
Error with Eigen in cross-platform project
我正在开发一个动态库,该库将在Windows和Linux软件上链接。为了简化构建操作,我决定使用 cmake 。
库具有以下结构:
MyProject
└ Subproject_1
| └ ...
| └ CMakeLists.txt
└ Subproject_2
| └ ...
| └ CMakeLists.txt
└ ...
└ CMakeLists.txt
在 subproject_1 中我使用 eigen 3.3 (我下载了最新版本(和 opencv 3.3.0 。
主要的cmakelists文件是此
cmake_minimum_required (VERSION 2.8)
SET(CMAKE_CXX_STANDARD 11)
project (MyProject)
## Output directory configuration
SET(out_dir ./)
SET(EXECUTABLE_OUTPUT_PATH ${out_dir}../lib/ CACHE PATH "Build directory" FORCE)
SET(LIBRARY_OUTPUT_PATH ${out_dir}../lib/ CACHE PATH "Build directory" FORCE)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${out_dir}../lib)
SET(CMAKE_BUILD_FILES_DIRECTORY ${out_dir})
SET(CMAKE_BUILD_DIRECTORY ${out_dir})
SET(CMAKE_BINARY_DIR ${out_dir})
SET(CMAKE_CACHEFILE_DIR ${out_dir})
SET(opencv_path "")
if (WIN32 OR MSVC OR MSYS OR MINGW)
SET(opencv_path "../opencv-3.3.0/build64/")
endif()
message("Setted OpenCV path to '" ${opencv_path} "'")
find_package(OpenCV REQUIRED PATHS ${opencv_path}
opencv_core opencv_features2d opencv_flann opencv_highgui opencv_imgcodecs opencv_imgproc opencv_photo opencv_plot opencv_xfeatures2d opencv_ml opencv_video
)
# Additional dependencies
include_directories(
${OPENCV_INCLUDE_DIRS}
"../eigen/"
"Subprojects_1/include"
"Subprojects/include"
)
## Subprojects
add_subdirectory ("Subproject_1")
add_subdirectory ("Subproject_2")
subproject_1 cmakelists文件是
cmake_minimum_required (VERSION 2.8)
project(Subproject_1)
file (GLOB core_file "include/*.h" "src/*.cpp")
add_library(library SHARED ${core_file})
target_link_libraries(library
${OpenCV_LIBRARIES}
)
现在,当我在Windows上编译该项目时,都可以正常工作,但是如果我尝试在Ubuntu 16.04 LT上进行编译,我有此错误:
... error: cannot declare reference to ‘Eigen::MatrixXi& {aka class Eigen::Matrix<int, -1, -1>&}’, which is not a typedef or a template type argument
static void bitwiseAND(const Eigen::MatrixXi& m1, const Eigen::MatrixXi& m2, Eigen::MatrixXi& and);
^
... error: cannot declare reference to ‘Eigen::MatrixXi& {aka class Eigen::Matrix<int, -1, -1>&}’, which is not a typedef or a template type argument
static void bitwiseNOT(const Eigen::MatrixXi& m, Eigen::MatrixXi& not);
^
我很确定问题不是归因于CMake,但是我在Google上没有任何东西,或者在这里可以帮助我解决它。此外,我试图按照特征官方说明进行操作,但它们在Windows上不起作用。
确切地说,我正在使用:
- 在Windows上:Visual Studio 2017,制作3.8版和Ninja
- 在Ubuntu上:制作版本4.1
由于我共享包含两个存储库的工作区目录,因此库和特征文件是相同的,而且我已经尝试在ubuntu上也尝试使用忍者。
欢迎每个建议
您必须避免使用not
和and
作为Linux下的变量名称,您应该将它们重命名为其他内容以进行编译。
它们实际上是C 关键字(请参阅此处(,在Linux下引起问题。Visual Studio无法识别它们,这解释了为什么汇编在Windows下工作的原因。有关详细信息,请参阅此问题。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 如何修复错误:"vreinterpretq_u32_f64"未在此范围内声明 - 在Android上使用Eigen构建
- 在标准向量中将元素分配给 Eigen::Vector2d 会引发错误
- 编译特征程序时出错:错误:'seq'不是'Eigen'的成员
- 跨平台项目中的eigen错误
- libigl,GLEW,GLFW和Eigen在CLion,Windows 10上.链接器错误
- Eigen SparseLU解决错误读取访问冲突,这>m_sup_to_col被0x111011101110112
- EIGEN 3.3 SVD.SOLVE返回错误的值
- Eigen & OpenMP : 由于错误共享和线程开销,没有并行化
- 从 Eigen::CwiseBinaryOp 转换为 MatrixXd 会导致段错误
- 使用Visual Studio 2013的动态库使用Eigen时出现内存对齐错误
- Eigen中存在maxCoeff的奇怪错误
- 为什么在c++中使用Eigen会出现这个错误?
- 在linux上使用intel编译器编译Eigen库时出现错误