Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对ExternalProject_Add()目标中定义的函数的未定义引用 编写一个简单的C++代码来调用外部Apple中的函数。 当我编译这个C++代码时,我看到一些未定义的参考错误如下: CMakeFiles/okvis_test.dir/main.cpp.o: In function `okvis::cameras::CameraBase::CameraBase(int, int, unsigned long)': main.cpp:(.text._ZN5okvis7cameras10CameraBaseC2Eiim[_ZN5okvis7cameras10CameraBaseC5Eiim]+0x17): undefined reference to `vtable for okvis::cameras::CameraBase' CMakeFiles/okvis_test.dir/main.cpp.o: In function `okvis::cameras::CameraBase::~CameraBase()': main.cpp:(.text._ZN5okvis7cameras10CameraBaseD2Ev[_ZN5okvis7cameras10CameraBaseD5Ev]+0xd): undefined reference to `vtable for okvis::cameras::CameraBase' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0xa0): undefined reference to `okvis::cameras::CameraBase::createRandomImagePoint() const' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0xa8): undefined reference to `okvis::cameras::CameraBase::createRandomVisiblePoint(double, double) const' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0xb0): undefined reference to `okvis::cameras::CameraBase::createRandomVisibleHomogeneousPoint(double, double) const' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTIN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTIN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0x10): undefined reference to `typeinfo for okvis::cameras::CameraBase' CMakeFiles/okvis_test.dir/main.cpp.o: In function `okvis::ceres::ReprojectionError<okvis::cameras::PinholeCamera<okvis::cameras::EquidistantDistortion> >::EvaluateWithMinimalJacobians(double const* const*, double*, double**, double**) const': main.cpp:(.text._ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_[_ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_]+0x937): undefined reference to `okvis::ceres::PoseLocalParameterization::liftJacobian(double const*, double*)' main.cpp:(.text._ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_[_ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_]+0xe2b): undefined reference to `okvis::ceres::PoseLocalParameterization::liftJacobian(double const*, double*)' collect2: error: ld returned 1 exit status CMakeFiles/okvis_test.dir/build.make:148: recipe for target 'okvis_test' failed make[2]: *** [okvis_test] Error 1 CMakeFiles/Makefile2:96: recipe for target 'CMakeFiles/okvis_test.dir/all' failed make[1]: *** [CMakeFiles/okvis_test.dir/all] Error 2 Makefile:102: recipe for target 'all' failed make: *** [all] Error 2 我的简单C++代码: #include <Eigen/Dense> #include <okvis/cameras/EquidistantDistortion.hpp> #include <okvis/cameras/PinholeCamera.hpp> #include <okvis/ceres/ReprojectionError.hpp> int main(int argc, char **argv) { using DistortedPinholeCameraGeometry = okvis::cameras::PinholeCamera<okvis::cameras::EquidistantDistortion>; std::shared_ptr<const DistortedPinholeCameraGeometry> camera_geometry = std::static_pointer_cast<const DistortedPinholeCameraGeometry>( DistortedPinholeCameraGeometry::createTestObject()); Eigen::Vector2d kp; Eigen::Matrix2d information = Eigen::Matrix2d::Identity(); okvis::ceres::ReprojectionError<DistortedPinholeCameraGeometry> reprojection_error(camera_geometry, 1, kp, information); return 0; } #包括 #包括 #包括 #包括 int main(int argc,字符**argv){ 使用畸变针孔法= okvis::摄像机::PinholeCamera; std::共享\u ptr摄像机\u几何体= std::静态\u指针\u转换( 扭曲的PinHoleCamerageMetry::createTestObject()); 本征::矢量2d kp; Eigen::Matrix2d information=Eigen::Matrix2d::Identity(); okvis::ceres::重射者 重投影错误(摄像机几何,1,kp,信息); 返回0; }_C++_Cmake - Fatal编程技术网

对ExternalProject_Add()目标中定义的函数的未定义引用 编写一个简单的C++代码来调用外部Apple中的函数。 当我编译这个C++代码时,我看到一些未定义的参考错误如下: CMakeFiles/okvis_test.dir/main.cpp.o: In function `okvis::cameras::CameraBase::CameraBase(int, int, unsigned long)': main.cpp:(.text._ZN5okvis7cameras10CameraBaseC2Eiim[_ZN5okvis7cameras10CameraBaseC5Eiim]+0x17): undefined reference to `vtable for okvis::cameras::CameraBase' CMakeFiles/okvis_test.dir/main.cpp.o: In function `okvis::cameras::CameraBase::~CameraBase()': main.cpp:(.text._ZN5okvis7cameras10CameraBaseD2Ev[_ZN5okvis7cameras10CameraBaseD5Ev]+0xd): undefined reference to `vtable for okvis::cameras::CameraBase' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0xa0): undefined reference to `okvis::cameras::CameraBase::createRandomImagePoint() const' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0xa8): undefined reference to `okvis::cameras::CameraBase::createRandomVisiblePoint(double, double) const' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0xb0): undefined reference to `okvis::cameras::CameraBase::createRandomVisibleHomogeneousPoint(double, double) const' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTIN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTIN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0x10): undefined reference to `typeinfo for okvis::cameras::CameraBase' CMakeFiles/okvis_test.dir/main.cpp.o: In function `okvis::ceres::ReprojectionError<okvis::cameras::PinholeCamera<okvis::cameras::EquidistantDistortion> >::EvaluateWithMinimalJacobians(double const* const*, double*, double**, double**) const': main.cpp:(.text._ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_[_ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_]+0x937): undefined reference to `okvis::ceres::PoseLocalParameterization::liftJacobian(double const*, double*)' main.cpp:(.text._ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_[_ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_]+0xe2b): undefined reference to `okvis::ceres::PoseLocalParameterization::liftJacobian(double const*, double*)' collect2: error: ld returned 1 exit status CMakeFiles/okvis_test.dir/build.make:148: recipe for target 'okvis_test' failed make[2]: *** [okvis_test] Error 1 CMakeFiles/Makefile2:96: recipe for target 'CMakeFiles/okvis_test.dir/all' failed make[1]: *** [CMakeFiles/okvis_test.dir/all] Error 2 Makefile:102: recipe for target 'all' failed make: *** [all] Error 2 我的简单C++代码: #include <Eigen/Dense> #include <okvis/cameras/EquidistantDistortion.hpp> #include <okvis/cameras/PinholeCamera.hpp> #include <okvis/ceres/ReprojectionError.hpp> int main(int argc, char **argv) { using DistortedPinholeCameraGeometry = okvis::cameras::PinholeCamera<okvis::cameras::EquidistantDistortion>; std::shared_ptr<const DistortedPinholeCameraGeometry> camera_geometry = std::static_pointer_cast<const DistortedPinholeCameraGeometry>( DistortedPinholeCameraGeometry::createTestObject()); Eigen::Vector2d kp; Eigen::Matrix2d information = Eigen::Matrix2d::Identity(); okvis::ceres::ReprojectionError<DistortedPinholeCameraGeometry> reprojection_error(camera_geometry, 1, kp, information); return 0; } #包括 #包括 #包括 #包括 int main(int argc,字符**argv){ 使用畸变针孔法= okvis::摄像机::PinholeCamera; std::共享\u ptr摄像机\u几何体= std::静态\u指针\u转换( 扭曲的PinHoleCamerageMetry::createTestObject()); 本征::矢量2d kp; Eigen::Matrix2d information=Eigen::Matrix2d::Identity(); okvis::ceres::重射者 重投影错误(摄像机几何,1,kp,信息); 返回0; }

对ExternalProject_Add()目标中定义的函数的未定义引用 编写一个简单的C++代码来调用外部Apple中的函数。 当我编译这个C++代码时,我看到一些未定义的参考错误如下: CMakeFiles/okvis_test.dir/main.cpp.o: In function `okvis::cameras::CameraBase::CameraBase(int, int, unsigned long)': main.cpp:(.text._ZN5okvis7cameras10CameraBaseC2Eiim[_ZN5okvis7cameras10CameraBaseC5Eiim]+0x17): undefined reference to `vtable for okvis::cameras::CameraBase' CMakeFiles/okvis_test.dir/main.cpp.o: In function `okvis::cameras::CameraBase::~CameraBase()': main.cpp:(.text._ZN5okvis7cameras10CameraBaseD2Ev[_ZN5okvis7cameras10CameraBaseD5Ev]+0xd): undefined reference to `vtable for okvis::cameras::CameraBase' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0xa0): undefined reference to `okvis::cameras::CameraBase::createRandomImagePoint() const' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0xa8): undefined reference to `okvis::cameras::CameraBase::createRandomVisiblePoint(double, double) const' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTVN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0xb0): undefined reference to `okvis::cameras::CameraBase::createRandomVisibleHomogeneousPoint(double, double) const' CMakeFiles/okvis_test.dir/main.cpp.o:(.rodata._ZTIN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE[_ZTIN5okvis7cameras13PinholeCameraINS0_21EquidistantDistortionEEE]+0x10): undefined reference to `typeinfo for okvis::cameras::CameraBase' CMakeFiles/okvis_test.dir/main.cpp.o: In function `okvis::ceres::ReprojectionError<okvis::cameras::PinholeCamera<okvis::cameras::EquidistantDistortion> >::EvaluateWithMinimalJacobians(double const* const*, double*, double**, double**) const': main.cpp:(.text._ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_[_ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_]+0x937): undefined reference to `okvis::ceres::PoseLocalParameterization::liftJacobian(double const*, double*)' main.cpp:(.text._ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_[_ZNK5okvis5ceres17ReprojectionErrorINS_7cameras13PinholeCameraINS2_21EquidistantDistortionEEEE28EvaluateWithMinimalJacobiansEPKPKdPdPSB_SC_]+0xe2b): undefined reference to `okvis::ceres::PoseLocalParameterization::liftJacobian(double const*, double*)' collect2: error: ld returned 1 exit status CMakeFiles/okvis_test.dir/build.make:148: recipe for target 'okvis_test' failed make[2]: *** [okvis_test] Error 1 CMakeFiles/Makefile2:96: recipe for target 'CMakeFiles/okvis_test.dir/all' failed make[1]: *** [CMakeFiles/okvis_test.dir/all] Error 2 Makefile:102: recipe for target 'all' failed make: *** [all] Error 2 我的简单C++代码: #include <Eigen/Dense> #include <okvis/cameras/EquidistantDistortion.hpp> #include <okvis/cameras/PinholeCamera.hpp> #include <okvis/ceres/ReprojectionError.hpp> int main(int argc, char **argv) { using DistortedPinholeCameraGeometry = okvis::cameras::PinholeCamera<okvis::cameras::EquidistantDistortion>; std::shared_ptr<const DistortedPinholeCameraGeometry> camera_geometry = std::static_pointer_cast<const DistortedPinholeCameraGeometry>( DistortedPinholeCameraGeometry::createTestObject()); Eigen::Vector2d kp; Eigen::Matrix2d information = Eigen::Matrix2d::Identity(); okvis::ceres::ReprojectionError<DistortedPinholeCameraGeometry> reprojection_error(camera_geometry, 1, kp, information); return 0; } #包括 #包括 #包括 #包括 int main(int argc,字符**argv){ 使用畸变针孔法= okvis::摄像机::PinholeCamera; std::共享\u ptr摄像机\u几何体= std::静态\u指针\u转换( 扭曲的PinHoleCamerageMetry::createTestObject()); 本征::矢量2d kp; Eigen::Matrix2d information=Eigen::Matrix2d::Identity(); okvis::ceres::重射者 重投影错误(摄像机几何,1,kp,信息); 返回0; },c++,cmake,C++,Cmake,我认为对vtable的未定义引用与未定义的虚函数无关。 已定义虚拟析构函数CameraBase类,请参阅 基本上,CameraBase类中的所有虚函数都是定义的或纯虚函数 我已经陷入这个错误好几个小时了。 如有任何帮助或建议,我们将不胜感激。目标属性旨在包含一个单个库路径。如果希望一个目标同时表示多个库,请使用接口为其键入: add_library(OKVIS_LIBS INTERFACE) target_link_libraries(OKVIS_LIBS INTERFACE # Whe

我认为对vtable的未定义引用与未定义的虚函数无关。 已定义虚拟析构函数CameraBase类,请参阅 基本上,CameraBase类中的所有虚函数都是定义的或纯虚函数

我已经陷入这个错误好几个小时了。 如有任何帮助或建议,我们将不胜感激。

目标属性旨在包含一个单个库路径。如果希望一个目标同时表示多个库,请使用
接口
为其键入:

add_library(OKVIS_LIBS INTERFACE)
target_link_libraries(OKVIS_LIBS INTERFACE
    # Whenever one will link with OKVIS_LIBS target,
    # the files below will be linked automatically.
    ${OKVIS_LIBS_DIR}/libokvis_ceres.a
    ${OKVIS_LIBS_DIR}/libokvis_common.a
    ...
    ${OKVIS_LIBS_DIR}/libokvis_util.a
)
对于该库,您还可以指定包含目录:

target_include_directories(OKVIS_LIBS INTERFACE ${OKVIS_INCLUDE_DIR})
因此,所有okvis特定的设置都可以通过与库目标
okvis_LIBS
的简单链接获得

另请参见关于将“正常”(非导入)目标合并到单个目标中

target_include_directories(OKVIS_LIBS INTERFACE ${OKVIS_INCLUDE_DIR})