2013-08-17 47 views
0

我在linux下有一個鏈接器問題這是我的cmake 文件製作cmake後鏈接錯誤

cmake_minimum_required(VERSION 2.6) 

# Locate GTest 
find_package(GTest REQUIRED Boost) 
include_directories(${GTEST_INCLUDE_DIRS}) 

file(GLOB info_model 

"../src/info_model/*.h" 
"../src/info_model/*.cpp" 
"../src/gcc_xml_parsing/*.h" 
"../src/gcc_xml_parsing/*.cpp" 
"../src/messages_filed_with_values/*.h" 
"../src/messages_filed_with_values/*.cpp" 

) 

# Link runTests with what we want to test and the GTest and pthread library 

add_library(info_model_lib STATIC ${info_model}) 

add_executable(runTests_xml unit/gcc_xml_parsing/ut_XMLFile.cpp) 
add_executable(runTests_hexDumpUtil unit/info_model/ut_HexDumpUtil.cpp) 
add_executable(runTests_cstruct unit/info_model/ut_CStruct.cpp) 
add_executable(runTests_primitive_type_field unit/info_model/ut_PrimitiveTypeField.cpp) 
add_executable(runTests_enumField unit/info_model/ut_EnumField.cpp) 
add_executable(runTests_ArrayOfFields unit/info_model/ut_ArrayType.cpp) 

target_link_libraries(runTests_xml ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread  boost_regex boost_thread info_model_lib) 
target_link_libraries(runTests_hexDumpUtil ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex boost_thread info_model_lib) 
target_link_libraries(runTests_cstruct ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex boost_thread info_model_lib) 
target_link_libraries(runTests_primitive_type_field ${GTEST_LIBRARIES}  ${GTEST_MAIN_LIBRARIES} pthread boost_regex boost_thread info_model_lib) 
target_link_libraries(runTests_enumField ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}  pthread boost_regex boost_thread info_model_lib) 
target_link_libraries(runTests_ArrayOfFields ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread boost_regex boost_thread info_model_lib) 

但是,鏈接throwns一個錯誤,它開始(我沒有提供整個日誌,因爲它比下面的5倍):

libinfo_model_lib.a(XMLFile.cpp.o): In function `bool boost::regex_search<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::string>)': 

謝謝你幫

回答

1

你必須提升之前你的鏈接庫::正則表達式

target_link_libraries(runTests_xml ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} info_model_lib pthread boost_regex boost_thread) 
+0

它的工作原理非常感謝:D – friko