English 中文(简体)
ros2 上校在Ang++11.4 ubuntu 22.04中制造错误
原标题:ros2 colon build error in g++ 11.4 ubuntu 22.04

build code with ros2 and see this error is there not install something? or i make wrong in cmakelist? i want create a socket with ros2 in ubuntu 22.04

$ colcon build
Starting >>> socket  
--- stderr: socket                             
/usr/bin/ld: cannot find -lsocket: No such file or directory
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/socket_server_node.dir/build.make:151: socket_server_node] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:165: CMakeFiles/socket_server_node.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
---
Failed   <<< socket [0.22s, exited with code 2]

问题回答

这里是我的CMAKELIST。


cmake_minimum_required(VERSION 3.8)
project(socket)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)

# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

set(dependencies
  rclcpp
  std_msgs
  sensor_msgs
)

set(SOURCES
  src/netsockserver.cpp
)
# add_library(netsock src/netsock.cpp)
add_library(netsockserver src/netsockserver.cpp)

# add_library(time src/time.cpp)


include_directories(
    include)


add_executable(socket_server_node src/socket_server_node.cpp)
target_link_libraries(socket_server_node
                      ${PROJECT_NAME}
                      ${catkin_LIBRARIES}
                      )
ament_target_dependencies(socket_server_node rclcpp)
ament_target_dependencies(netsockserver rclcpp)
install(TARGETS
    socket_server_node
    DESTINATION lib/${PROJECT_NAME}
)


# Install the library
install(TARGETS netsockserver
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
  INCLUDES DESTINATION include
)

# install this package
install(DIRECTORY
    include/
    DESTINATION include/
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签