ros2 / libyaml_vendor

CMake wrapper downloading and building libyaml
Apache License 2.0
2 stars 17 forks source link

--- stderr: libyaml_vendor #63

Closed The-Lyc closed 2 days ago

The-Lyc commented 1 month ago

colcon build --symlink-install, building from source code(iron or jazzy,meets the same problem;but humble is ok) when compiling libyaml_vendor:

/usr/bin/ld: CMakeFiles/benchmark_reader.dir/test/benchmark/benchmark_reader.cpp.o: in function `PerformanceTest_initialize_delete_Benchmark::BenchmarkCase(benchmark::State&)':
benchmark_reader.cpp:(.text+0x10b): undefined reference to `yaml_parser_initialize'
/usr/bin/ld: benchmark_reader.cpp:(.text+0x11a): undefined reference to `yaml_parser_delete'
/usr/bin/ld: CMakeFiles/benchmark_reader.dir/test/benchmark/benchmark_reader.cpp.o: in function `PerformanceTest_yaml_parser_set_input_string_Benchmark::BenchmarkCase(benchmark::State&)':
benchmark_reader.cpp:(.text+0x304): undefined reference to `yaml_parser_initialize'
/usr/bin/ld: benchmark_reader.cpp:(.text+0x32e): undefined reference to `yaml_parser_set_input_string'
/usr/bin/ld: benchmark_reader.cpp:(.text+0x33d): undefined reference to `yaml_parser_delete'
/usr/bin/ld: CMakeFiles/benchmark_reader.dir/test/benchmark/benchmark_reader.cpp.o: in function `PerformanceTest_yaml_parser_set_input_file_Benchmark::BenchmarkCase(benchmark::State&)':
benchmark_reader.cpp:(.text+0x6cb): undefined reference to `yaml_parser_initialize'
/usr/bin/ld: benchmark_reader.cpp:(.text+0x6e4): undefined reference to `yaml_parser_set_input_file'
/usr/bin/ld: benchmark_reader.cpp:(.text+0x6f3): undefined reference to `yaml_parser_delete'
/usr/bin/ld: CMakeFiles/benchmark_reader.dir/test/benchmark/benchmark_reader.cpp.o: in function `PerformanceTest_yaml_parser_set_input_file_event_Benchmark::BenchmarkCase(benchmark::State&)':
benchmark_reader.cpp:(.text+0xbab): undefined reference to `yaml_parser_initialize'
/usr/bin/ld: benchmark_reader.cpp:(.text+0xbc4): undefined reference to `yaml_parser_set_input_file'
/usr/bin/ld: benchmark_reader.cpp:(.text+0xbdd): undefined reference to `yaml_parser_parse'
/usr/bin/ld: benchmark_reader.cpp:(.text+0xbec): undefined reference to `yaml_event_delete'
/usr/bin/ld: benchmark_reader.cpp:(.text+0xbfb): undefined reference to `yaml_parser_delete'
/usr/bin/ld: benchmark_reader: unable to sort relocs - they are in more than one size
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/benchmark_reader.dir/build.make:102: benchmark_reader] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:184: CMakeFiles/benchmark_reader.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
---
Failed   <<< libyaml_vendor [28.2s, exited with code 2]

then I check the CMakeLists.txt in libyaml_vendor, I use cmake . -LAH:

CMake Error at CMakeLists.txt:10 (find_package):
  By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ament_cmake", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake" with
  any of the following names:

    ament_cmakeConfig.cmake
    ament_cmake-config.cmake

  Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
  "ament_cmake_DIR" to a directory containing one of the above files.  If
  "ament_cmake" provides a separate development package or SDK, be sure it
  has been installed.

I found ament_cmakeConfig.cmake in dir /opt/ros/iron/share/ament_cmake/cmake/ament_cmakeConfig.cmake ,then I tried to add this to the CMakeLists,but it met other errors like this.

mjcarroll commented 1 month ago

This looks like some CMake paths aren't set up.

Did you source your /opt/ros/iron workspace before beginning the build?

When you open your terminal try:

source /opt/ros/iron/setup.bash  # or sh, zsh depending on shell
cd ~/my/ros/workspace
colcon build --symlink-install
mjcarroll commented 1 month ago

@The-Lyc friendly ping. We need more information to be able to help you out here.

The-Lyc commented 5 days ago

@mjcarroll Sorry for the delayed response, I didn't see your message earlier. I tried to source /opt/ros/iron workspace before beginning the build, but still met the same problem. I successfully build humble version on the same environment before, can this cause my problem?

mjcarroll commented 4 days ago

I successfully build humble version on the same environment before, can this cause my problem?

Yes, in general, you should not mix multiple distributions in the same environment. Perhaps try cleaning out any artifacts generated by the build (typically the log/ install/ and build/ directories), and see if that helps.

The-Lyc commented 2 days ago

@mjcarroll thanku very much.

I deleted all the build artifacts, but the issue still occurred. After reinstalling the environment, I was able to compile successfully. It seems that in the original environment, simply deleting the build artifacts and running the commands source /opt/ros/iron/setup.bash did not completely eliminate the influence of the previously successfully compiled Humble.

Is there any method to completely remove a successfully compiled ROS 2 version?

mjcarroll commented 2 days ago

It's likely that there were additional paths added to environment variables such as PATH, LD_LIBRARY_PATH, etc. These can be manually cleaned, but the the fastest way is simply to close the terminal and start a new one that hasn't been updated by the setup.sh scripts.

The-Lyc commented 2 days ago

@mjcarroll thanku.