我一直在尝试将boost.Log集成到我的项目中,但在构建时我收到错误消息:
$.each(obj, function (i, data) {
jsonData.push({ A: data.countAgree, B: data.countSomewhatAgree, C: data.countDisagree, Q: 'Question' + (i + 1) });
});
我已经检查确保我没有在任何地方定义BOOST_NO_EXCEPTIONS,但我仍然难以理解为什么我收到此错误。我的CMAKE文件如下:
/usr/lib/cross/boost/lib/libboost_date_time.so: undefined reference to `boost::throw_exception(std::exception const&)'
来自FIND的库的输出似乎没问题:
set(Boost_INCLUDE_DIR /usr/lib/cross/boost/include)
set(Boost_LIBRARY_DIR /usr/lib/cross/boost/lib)
find_package(Boost 1.63.0 COMPONENTS system filesystem log REQUIRED)
message(status "** Boost Include: ${Boost_INCLUDE_DIR}")
message(status "** Boost Libraries: ${Boost_LIBRARY_DIRS}")
message(status "** Boost Libraries: ${Boost_LIBRARIES}")
set (PROJECT_LINK_LIBS thrift crypto ssl sqlcipher)
link_directories( $ENV{LD_LIBRARY_PATH}
${Boost_LIBRARY_DIRS}
)
include_directories( $ENV{LD_INCLUDE_PATH}
$ENV{LD_INCLUDE_PATH}/sqlcipher
${Boost_INCLUDE_DIR}
)
add_executable(databaseManager ${MY_SRC})
target_link_libraries(databaseManager ${Boost_LIBRARIES} ${PROJECT_LINK_LIBS} )
最后,它失败的链接步骤的详细输出:
-- Boost version: 1.63.0
1> -- Found the following Boost libraries:
1> -- system
1> -- filesystem
1> -- log
1> -- date_time
1> -- log_setup
1> -- thread
1> -- regex
1> -- chrono
1> -- atomic
1> status** Boost Include: /usr/lib/cross/boost/include
1> status** Boost Libraries: /usr/lib/cross/boost/lib
1> status** Boost Libraries:
/usr/lib/cross/boost/lib/libboost_system.so;/usr/lib/cross/boost/lib/libboost_filesystem.so;/usr/lib/cross/boost/lib/libboost_log.so;/usr/lib/cross/boost/lib/libboost_date_time.so;/usr/lib/cross/boost/lib/libboost_log_setup.so;/usr/lib/cross/boost/lib/libboost_thread.so;/usr/lib/cross/boost/lib/libboost_regex.so;/usr/lib/cross/boost/lib/libboost_chrono.so;/usr/lib/cross/boost/lib/libboost_atomic.so
有没有人知道我还可以检查或做些什么来克服这个错误?
干杯!
*******编辑*********
有一些关于在COMPONENTS列表中添加异常的建议。我已经尝试并测试了这个,但遗憾的是收到了同样的错误。
唯一需要注意的是所有主库都是动态链接的(.so版本被拉入),而boost_exception是静态拉(.a版本)。
find_package命令的新版本:
/home/imx7/build/imx7-firmware-dev-package/src/maketools/obj.iMX7/bin/arm-devolo-linux-g++ -fexceptions -frtti -pthread -O3 -DNDEBUG -rdynamic CMakeFiles/databaseManager.dir/DatabaseManagerEventHandler.cpp.o CMakeFiles/databaseManager.dir/DatabaseManagerHandler.cpp.o CMakeFiles/databaseManager.dir/DatabaseManagerServer.cpp.o CMakeFiles/databaseManager.dir/DatabaseManagerService.cpp.o CMakeFiles/databaseManager.dir/Logger.cpp.o CMakeFiles/databaseManager.dir/dbConnection.cpp.o CMakeFiles/databaseManager.dir/thrift_common/base_constants.cpp.o CMakeFiles/databaseManager.dir/thrift_common/base_types.cpp.o CMakeFiles/databaseManager.dir/thrift_dbManager/DatabaseManager.cpp.o CMakeFiles/databaseManager.dir/thrift_dbManager/dbManager_constants.cpp.o CMakeFiles/databaseManager.dir/thrift_dbManager/dbManager_types.cpp.o CMakeFiles/databaseManager.dir/thrift_supervisor/Info.cpp.o CMakeFiles/databaseManager.dir/thrift_supervisor/Supervision.cpp.o CMakeFiles/databaseManager.dir/thrift_supervisor/supervision_constants.cpp.o CMakeFiles/databaseManager.dir/thrift_supervisor/supervision_types.cpp.o -o databaseManager -L/usr/lib/cross/official_libs -L/usr/lib/cross/boost/lib -Wl,-rpath,/usr/lib/cross/official_libs:/usr/lib/cross/boost/lib: /usr/lib/cross/boost/lib/libboost_system.so /usr/lib/cross/boost/lib/libboost_filesystem.so /usr/lib/cross/boost/lib/libboost_chrono.so /usr/lib/cross/boost/lib/libboost_log.so /usr/lib/cross/boost/lib/libboost_date_time.so /usr/lib/cross/boost/lib/libboost_log_setup.so /usr/lib/cross/boost/lib/libboost_thread.so /usr/lib/cross/boost/lib/libboost_regex.so /usr/lib/cross/boost/lib/libboost_atomic.so -lthrift -lcrypto -lssl -lsqlcipher
/home/imx7/build/imx7-firmware-dev-package/src/maketools/binaries.iMX7/tools/bin/../lib/gcc/arm-devolo-linux-gnueabihf/4.9.4/../../../../arm-devolo-linux-gnueabihf/bin/ld: warning: libz.so.1, needed by /usr/lib/cross/official_libs/libsqlcipher.so, not found (try using -rpath or -rpath-link)
/usr/lib/cross/boost/lib/libboost_date_time.so: undefined reference to `boost::throw_exception(std::exception const&)'
collect2: error: ld returned 1 exit status
src/CMakeFiles/databaseManager.dir/build.make:470: recipe for target 'src/databaseManager' failed
make[2]: Leaving directory '/var/cppbuild/DatabaseManager/build/Linux-Release'
CMakeFiles/Makefile2:88: recipe for target 'src/CMakeFiles/databaseManager.dir/all' failed
make[1]: Leaving directory '/var/cppbuild/DatabaseManager/build/Linux-Release'
make[2]: *** [src/databaseManager] Error 1
make[1]: *** [src/CMakeFiles/databaseManager.dir/all] Error 2
Makefile:132: recipe for target 'all' failed
make: *** [all] Error 2
以上更改构建错误:
find_package(Boost 1.63.0 COMPONENTS system atomic filesystem log exception REQUIRED)
答案 0 :(得分:0)
如果有其他人遇到过此更新。
我能够让它发挥作用的唯一方法是使用以下代码片段:
#define BOOST_NO_EXCEPTIONS
#include <boost/throw_exception.hpp>
void boost::throw_exception(std::exception const & e){
//do nothing
}
我玩了库的顺序,明确地包括它们,使用findBoost.cmake并且一切都无济于事。我猜是一个随意的怪癖!