leggedrobotics / ros_best_practices

Best practices, conventions, and tricks for ROS
https://rsl.ethz.ch/education-students/lectures/ros.html
BSD 3-Clause "New" or "Revised" License
1.49k stars 413 forks source link

ld error during catkin build #35

Open Hustwireless opened 3 years ago

Hustwireless commented 3 years ago

When I tried to build the project with catkin build, it returns error like this:

/usr/bin/ld: CMakeFiles/ros_package_template.dir/src/RosPackageTemplate.cpp.o: undefined reference to symbol '_ZTVN10cxxabiv121vmi_class_type_infoE@@CXXABI_1.3' /usr/bin/ld: /lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

After I searched the Internet, I found that it is probably because cmake didn't use the right compiler. See this https://stackoverflow.com/questions/59536040/libstdc-so-6-error-adding-symbols-dso-missing-from-command-line I think it might need to add a line like this in the CMakeLists.txt

set(CMAKE_CXX_COMPILER "/path/to/g++")

or simply modify the project line to

project(ros_package_template CXX)

tomlankhorst commented 3 years ago

Which operating system are you using? This assumes you're on the Ubuntu LTS distro that corresponds to the ROS Distro, using the default g++/gcc compilers.

That is for example: ROS Noetic + Focal Fossa + GCC 9.3

sahilpodey2 commented 3 years ago

I use ubuntu 20.04 and noetic. Basically many of them get this problem. You delete whole files from catkin folder and run catkin_make. Nxt step I will let you know.

On Mon, Mar 1, 2021, 2:19 AM Tom Lankhorst notifications@github.com wrote:

Which operating system are you using? This assumes you're on the Ubuntu LTS distro that corresponds to the ROS Distro, using the default g++/gcc compilers.

That is for example: ROS Noetic + Focal Fossa + GCC 9.3

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/leggedrobotics/ros_best_practices/issues/35#issuecomment-787520487, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ7GXT4NKIZRWUQCLOMDX3LTBKT33ANCNFSM4YDJ7GOQ .

Hustwireless commented 3 years ago

@tomlankhorst Yes, I'm using ROS Noetic + Focal Fossa + GCC 9.3

tomlankhorst commented 3 years ago

Would you mind compiling again, with the VERBOSE=1 variable set?

Did you compile with project(ros_package_template CXX) ? What's the result.

Hustwireless commented 3 years ago

With project(ros_package_template CXX) everything is fine, however without CXX, it will prompt errors like _ZTVN10__cxxabiv121__vmi_class_type_infoE@@CXXABI_1.3

Could you maybe tell me how to complie with the VERBOSE=1 variable set? I can then try to compile it again.

tomlankhorst commented 3 years ago

Sorry for my late reply.

What is the value of your CC and CXX environment variables? Are you using an IDE? Some set these variables for you.

What is the output of the following commands?

echo $CC
echo $CXX
which g++
g++ --version

Then, a quick compiler test, can you compile c++ hello world?

wget -q https://raw.githubusercontent.com/leachim6/hello-world/master/c/C%2B%2B.cpp
g++ C++.cpp
./a.out