ros阿克曼小车,鲁班猫板子3566的错误 SDL

catkin_make -DCATKIN_WHITELIST_PACKAGES="world_canvas_msgs"
sudo chmod -R 777 src/

error:
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_ReadLE16'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_FillRect'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_ReadBE32'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_SetColorKey'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_ClearError'
/usr/bin/ld: /home/cat/hl/wheeltec_robot/devel/lib/libmap_server_image_loader.so: undefined reference to `SDL_FreeSurface'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_MapRGB'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_RWFromFile'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_SetError'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_UpperBlit'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_ReadLE32'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_CreateRGBSurface'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libSDL_image.so: undefined reference to `SDL_Error'
/usr/bin/ld: /home/cat/hl/wheeltec_robot/devel/lib/libmap_server_image_loader.so: undefined reference to `SDL_GetError'
collect2: error: ld returned 1 exit status
make[2]: *** [navigation-noetic-devel/map_server/CMakeFiles/map_server.dir/build.make:128:/home/cat/hl/wheeltec_robot/devel/lib/map_server/map_server] 错误 1
make[1]: *** [CMakeFiles/Makefile2:922:navigation-noetic-devel/map_server/CMakeFiles/map_server.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2
Invoking "make -j4 -l4" failed


ERROR: cannot launch node of type [map_server/map_server]: Cannot locate node of type [map_server] in package [map_server]. Make sure file exists in package path and permission is set to executable (chmod +x)

我是从客服那拿到一个新map_server来重新编译

这个错误表明在CMake测试阶段,编译器无法找到pthread库。要解决这个问题,你可以尝试以下步骤:

    查找正确的pthread库:首先确保你的系统中已经安装了pthread库。通常情况下,pthread库是Linux系统的一部分,但在某些情况下可能需要单独安装。你可以通过包管理器来安装,例如对于Debian/Ubuntu系统,你可以运行以下命令:

sudo apt-get install libpthread-stubs0-dev

对于其他Linux发行版,你需要查找相应的包名并使用适当的包管理器进行安装。

设置正确的链接库:错误信息中提到找不到"-lpthreads",这表明CMake正在尝试链接pthread库时使用了错误的名称。pthread库的名称可能因系统而异,通常应该是"-lpthread"而不是"-lpthreads"。你可以在CMakeLists.txt文件中显式指定链接pthread库:

cmake

    find_package(Threads REQUIRED)
    target_link_libraries(your_target_name Threads::Threads)

    将"your_target_name"替换为你的目标名称。

    重新运行CMake:在进行上述更改后,重新运行CMake来重新生成Makefile,并确保编译器能够找到pthread库。

通过执行以上步骤,你应该能够解决CMake测试阶段中关于pthread的链接错误。

要查找SDL2和SDL2_image的安装路径,你可以执行以下步骤:

    使用pkg-config:SDL2和SDL2_image通常提供了pkg-config文件,可以用来查询它们的安装路径。你可以使用以下命令来查找:

    bash

pkg-config --cflags --libs sdl2 sdl2_image

这将输出SDL2和SDL2_image的编译标志和链接标志,其中包含了包含文件的路径和库的路径。

使用locate命令:如果你的系统上安装了SDL2和SDL2_image,并且updatedb数据库已经更新,你可以使用locate命令来搜索相关文件的路径。例如:

bash

    locate SDL2
    locate SDL2_image

    这将列出与SDL2和SDL2_image相关的文件及其路径,包括头文件、库文件等。

    查看默认安装路径:通常情况下,SDL2和SDL2_image会被安装在系统的默认路径下,例如在Linux上可能是/usr/include和/usr/lib。你可以直接查看这些目录来确认是否存在SDL2和SDL2_image的相关文件。

通过执行这些步骤,你应该能够找到SDL2和SDL2_image的安装路径。


cat@lubancat:~/hl/wheeltec_robot$ pkg-config --cflags --libs sdl2
-D_REENTRANT -I/usr/local/include -I/usr/local/include/SDL2 -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL2

cat@lubancat:~/hl/wheeltec_robot$ pkg-config --cflags --libs sdl2_image
Package sdl2_image was not found in the pkg-config search path.
Perhaps you should add the directory containing `sdl2_image.pc'
to the PKG_CONFIG_PATH environment variable
No package 'sdl2_image' found


/usr/bin/mkdir -p /usr/local/lib/cmake/SDL2_image
/usr/bin/install -c -m 644 sdl2_image-config.cmake /usr/local/lib/cmake/SDL2_image
/usr/bin/install -c -m 644 sdl2_image-config-version.cmake /usr/local/lib/cmake/SDL2_image
 /usr/bin/mkdir -p '/usr/local/include/SDL2'
 /usr/bin/install -c -m 644 include/SDL_image.h '/usr/local/include/SDL2'
 /usr/bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 SDL2_image.pc '/usr/local/lib/pkgconfig'
make[2]: 离开目录“/home/cat/下载/SDL2_image-2.8.2”
make[1]: 离开目录“/home/cat/下载/SDL2_image-2.8.2”


根据你提供的输出,SDL2_image已经成功安装,并且相关的文件已经被复制到了系统目录中。然而,根据你之前的问题描述,pkg-config仍然无法找到SDL2_image。

请尝试执行以下操作:

    确保在执行pkg-config --cflags --libs sdl2_image命令之前,已经执行了设置PKG_CONFIG_PATH的命令。如果没有,请执行以下命令:

    bash

    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

    然后再次运行pkg-config --cflags --libs sdl2_image命令,检查是否能够找到SDL2_image。

如果还是无法找到SDL2_image,请检查一下PKG_CONFIG_PATH变量是否设置正确,并确保SDL2_image的pkg-config文件位于/usr/local/lib/pkgconfig目录下。如果问题仍然存在,可能需要检查一下其他系统设置或者重新安装SDL2_image。


cat@lubancat:~/下载/SDL2_image-2.8.2$ pkg-config --cflags --libsdl2_image
Unknown option --libsdl2_image


看起来在你运行pkg-config --cflags --libsdl2_image时出现了错误,提示Unknown option --libsdl2_image。

这个错误表明pkg-config无法识别--libsdl2_image作为选项。这很可能是因为命令中的选项格式不正确。

请尝试将命令改为:

bash

pkg-config --cflags --libs SDL2_image

注意命令中SDL2_image之前没有--前缀,因为SDL2_image是包的名称,而不是选项。执行上述命令后,应该能够正确获取SDL2_image的编译标志和链接标志

cat@lubancat:~/下载/SDL2_image-2.8.2$ pkg-config --cflags --libs SDL2_image
-D_REENTRANT -I/usr/local/include/SDL2 -I/usr/local/include -I/usr/local/include/SDL2 -L/usr/local/lib -lSDL2_image -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL2

/usr/bin/ld: /home/cat/hl/wheeltec_robot/devel/lib/libmap_server_image_loader.so: undefined reference to `SDL_FreeSurface'
/usr/bin/ld: /home/cat/hl/wheeltec_robot/devel/lib/libmap_server_image_loader.so: undefined reference to `IMG_Load'
/usr/bin/ld: /home/cat/hl/wheeltec_robot/devel/lib/libmap_server_image_loader.so: undefined reference to `SDL_GetError'
collect2: error: ld returned 1 exit status
make[2]: *** [navigation-noetic-devel/map_server/CMakeFiles/map_server.dir/build.make:125:/home/cat/hl/wheeltec_robot/devel/lib/map_server/map_server] 错误 1
make[1]: *** [CMakeFiles/Makefile2:922:navigation-noetic-devel/map_server/CMakeFiles/map_server.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2
Invoking "make -j4 -l4" failed


这个错误表明编译时发生了链接错误,具体是由于在libmap_server_image_loader.so库中找不到SDL_FreeSurface、IMG_Load和SDL_GetError函数的定义。

这通常是由于未正确链接SDL2_image库导致的。请确保你已经正确地安装了SDL2_image库,并且在CMakeLists.txt文件中添加了正确的链接标志。

请检查以下几点:

    确保你已经正确地安装了SDL2_image库。可以尝试使用pkg-config命令来确认SDL2_image库的安装路径和版本信息:

pkg-config --modversion SDL2_image

在CMakeLists.txt文件中,确保你使用了正确的链接标志来链接SDL2_image库。你可以在target_link_libraries()函数中添加${SDL2_IMAGE_LIBRARIES}变量,如下所示:

cmake

target_link_libraries(your_executable
  ${catkin_LIBRARIES}
  ${SDL2_IMAGE_LIBRARIES}
)

确保你在CMakeLists.txt文件中正确地设置了SDL2_image的包含路径。你可以在include_directories()函数中添加${SDL2_IMAGE_INCLUDE_DIRS}变量,如下所示:

cmake

    include_directories(
      ${catkin_INCLUDE_DIRS}
      ${SDL2_IMAGE_INCLUDE_DIRS}
    )

完成以上步骤后,重新构建你的项目,看看是否能够解决链接错误。如果问题仍然存在,请确保你的SDL2_image库完整且可用,并检查你的CMakeLists.txt文件中是否有其他可能导致链接错误的配置错误

你可以使用pkg-config命令来查看SDL2_image库的链接标志。

在终端中运行以下命令:

shell

pkg-config --libs SDL2_image

这将返回SDL2_image库的链接标志,例如-lSDL2_image和其他可能需要的系统库。

另外,你还可以使用pkg-config命令来查看SDL2_image库的包含路径,运行以下命令:

shell

pkg-config --cflags SDL2_image

这将返回SDL2_image库的包含路径,例如-I/usr/include/SDL2。

通过查看链接标志和包含路径,你就能够正确地配置你的CMakeLists.txt文件,以确保能够正确链接SDL2_image库。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值