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
无法正确链接CMakeLists中的库_Cmake_Ros_Catkin - Fatal编程技术网

无法正确链接CMakeLists中的库

无法正确链接CMakeLists中的库,cmake,ros,catkin,Cmake,Ros,Catkin,我在将源文件(我已将它们作为库添加到我的CmakeList中)与主文件链接时遇到一些问题。这是我的CMakeLists: cmake_minimum_required(VERSION 2.8.3) project(ros_bridge) set(${PROJECT_NAME}_CATKIN_COMPONENTS nav_msgs roscpp sensor_msgs std_msgs ) add_compile_options(-std=c++14) find_packag

我在将源文件(我已将它们作为库添加到我的CmakeList中)与主文件链接时遇到一些问题。这是我的
CMakeLists

cmake_minimum_required(VERSION 2.8.3)
project(ros_bridge)

set(${PROJECT_NAME}_CATKIN_COMPONENTS
  nav_msgs
  roscpp
  sensor_msgs
  std_msgs
)

add_compile_options(-std=c++14)

find_package(catkin REQUIRED COMPONENTS ${${PROJECT_NAME}_CATKIN_COMPONENTS})
find_package(RapidJSON REQUIRED)

catkin_package(
  INCLUDE_DIRS
    include
    include/aws_iot_sdk
    include/common
    include/network
  CATKIN_DEPENDS ${${PROJECT_NAME}_CATKIN_COMPONENTS}
)


include_directories(
  include
  include/aws_iot_sdk
  ${catkin_INCLUDE_DIRS}
)

## Libraries

add_library(ros_client src/ros_client.cpp)
add_library(ConfigCommon include/common/ConfigCommon.cpp)
add_library(OpenSSL include/network/OpenSSL/OpenSSLConnection.cpp)
add_library(WebSocket include/network/WebSocket/WebSocketConnection.cpp)

add_executable(ros_bridge_node src/main.cpp)

## Lib links
target_link_libraries(ros_client ConfigCommon ${catkin_LIBRARIES} ${RapidJSON_LIBRARIES} OpenSSL WebSocket)
target_link_libraries(ConfigCommon ${catkin_LIBRARIES} ${RapidJSON_LIBRARIES} OpenSSL WebSocket)

target_link_libraries(ros_bridge_node ${catkin_LIBRARIES} ros_client ConfigCommon OpenSSL WebSocket ${RapidJSON_LIBRARIES})
因此,当编译器尝试链接我的主文件(即
ros\u bridge\u node
)时,我得到链接错误:

ros_client.cpp:(.text+0x605): undefined reference to `awsiotsdk::util::Logging::GetLogSystem()'
ros_client.cpp:(.text+0x66d): undefined reference to `awsiotsdk::ResponseHelper::ToString[abi:cxx11](awsiotsdk::ResponseCode)'
CMakeFiles/ros_bridge_node.dir/src/ros_client.cpp.o: In function `ros_bridge::RosClient::RunPublish(int&)':
ros_client.cpp:(.text+0x8d9): undefined reference to `awsiotsdk::Utf8String::Create(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/home/abyl/master-wheel/devel/lib/libWebSocket.so: undefined reference to `BIO_push'
/home/abyl/master-wheel/devel/lib/libWebSocket.so: undefined reference to `awsiotsdk::NetworkConnection::Read(std::vector<unsigned char, std::allocator<unsigned char> >&, unsigned long, unsigned long, unsigned long&)'
/home/abyl/master-wheel/devel/lib/libConfigCommon.so: undefined reference to `awsiotsdk::util::JsonParser::InitializeFromJsonFile(rapidjson::GenericDocument<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>, rapidjson::CrtAllocator>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/abyl/master-wheel/devel/lib/libWebSocket.so: undefined reference to `SHA1'
/home/abyl/master-wheel/devel/lib/libWebSocket.so: undefined reference to `BIO_f_base64'
/home/abyl/master-wheel/devel/lib/libWebSocket.so: undefined reference to `awsiotsdk::network::OpenSSLConnection::IsPhysicalLayerConnected()'
/home/abyl/master-wheel/devel/lib/libWebSocket.so: undefined reference to `BIO_set_flags'
/home/abyl/master-wheel/devel/lib/libWebSocket.so: undefined reference to `BIO_new'
并试图将其链接到我的主文件:

target_link_libraries(ros_bridge_node ros_client ConfigCommon Open WebSocket wslay ${RapidJSON_LIBRARIES} ${catkin_LIBRARIES} -lssl ${aws_sdk})

但仍然有同样的联系问题。可能是我链接的对象文件错误?(现在所有的链接问题都来自于
aws\u iot\u sdk

@Tsyvarev我认为
未定义的引用
发生在您不链接库时?您的错误主要是抱怨
awsiotsdk
中的定义。你包括这个目录,但我看不到你在哪里链接到它的库。是否有
aws\u iot\u sdk
库?如果是这样,您可以尝试在调用
target\u link\u libraries()
?squareskittles我已经编辑了我的问题,请查找assign
aws\u sdk
变量使用命令
set(aws\u sdk…
),这里取消引用
${aws\u sdk}
是错误的。另外请注意,在
target\u link\u libraries
call中,您需要指定库。没有一个目录包含它们。链接器没有“链接该目录中的所有库”选项。至于
未定义的引用
,我刚刚发现
/home/abyl/master wheel/devel/lib/libWebSocket。因此
库实际上是在您的项目中构建的,而不是3d方(预先创建的)。不要介意我的第一条评论(目前已删除)。
target_link_libraries(ros_bridge_node ros_client ConfigCommon Open WebSocket wslay ${RapidJSON_LIBRARIES} ${catkin_LIBRARIES} -lssl ${aws_sdk})