ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

"ROS" (in quotes as it's really ambiguous to ask these sort of things like that) is built with whatever is the default C++ compiler is on the system that it is built on.

In the end it's all CMake, so whatever CMake decides should be the compiler, will be the compiler.

You can override/configure that using the traditional CC and CXX environment variables (and using something called a toolchain file, but I'll ignore those here).


For ROS Kinetic on Ubuntu Xenial (16.04, amd64), the ROS buildfarm uses GCC version 5.4.0 -- as that is the default compiler on that platform. See the build output from this job (roscpp_core) fi:

11:22:56 -- The C compiler identification is GNU 5.4.0
11:22:56 -- The CXX compiler identification is GNU 5.4.0

This also tells you the path to the compiler binaries used:

11:22:56 -- Check for working C compiler: /usr/bin/cc
11:22:56 -- Check for working C compiler: /usr/bin/cc -- works
[..]
11:22:56 -- Check for working CXX compiler: /usr/bin/c++
11:22:56 -- Check for working CXX compiler: /usr/bin/c++ -- works

You can see the same output in a local invocation of catkin_make on ROS Kinetic/Ubuntu Xenial:

-- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works [..] -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works

With catkin_tools you can see this by adding the -v option to your build verb invocation.

I don't know how to choose the version to compile my workspace (use the default compiler like the answer said).

It would probably be good to figure out what the currently used version is first. You can do that by checking the output of the various build commands and/or by running gcc --version.

"ROS" (in quotes as it's really ambiguous to ask these sort of things like that) is built with whatever is the default C++ compiler is on the system that it is built on.

In the end it's all CMake, so whatever CMake decides should be the compiler, will be the compiler.

You can override/configure that using the traditional CC and CXX environment variables (and using something called a toolchain file, but I'll ignore those here).


For ROS Kinetic on Ubuntu Xenial (16.04, amd64), the ROS buildfarm uses GCC version 5.4.0 -- as that is the default compiler on that platform. See the build output from this job (roscpp_core) fi:

11:22:56 -- The C compiler identification is GNU 5.4.0
11:22:56 -- The CXX compiler identification is GNU 5.4.0

This also tells you the path to the compiler binaries used:

11:22:56 -- Check for working C compiler: /usr/bin/cc
11:22:56 -- Check for working C compiler: /usr/bin/cc -- works
[..]
11:22:56 -- Check for working CXX compiler: /usr/bin/c++
11:22:56 -- Check for working CXX compiler: /usr/bin/c++ -- works

You can see the same output in a local invocation of catkin_make on ROS Kinetic/Ubuntu Xenial:

-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
[..]
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works

works

With catkin_tools you can see this by adding the -v option to your build verb invocation.

I don't know how to choose the version to compile my workspace (use the default compiler like the answer said).

It would probably be good to figure out what the currently used version is first. You can do that by checking the output of the various build commands and/or by running gcc --version.

"ROS" (in quotes as it's really ambiguous to ask these sort of things like that) is built with whatever is the default C++ compiler is on the system that it is built on.

In the end it's all CMake, so whatever CMake decides should be the compiler, will be the compiler.

You can override/configure that using the traditional CC and CXX environment variables (and using something called a toolchain file, but I'll ignore those here).


For ROS Kinetic on Ubuntu Xenial (16.04, amd64), the ROS buildfarm uses GCC version 5.4.0 -- as that is the default compiler on that platform. See the build output from this job (roscpp_core) fi:

11:22:56 -- The C compiler identification is GNU 5.4.0
11:22:56 -- The CXX compiler identification is GNU 5.4.0

This also tells you the path to the compiler binaries used:

11:22:56 -- Check for working C compiler: /usr/bin/cc
11:22:56 -- Check for working C compiler: /usr/bin/cc -- works
[..]
11:22:56 -- Check for working CXX compiler: /usr/bin/c++
11:22:56 -- Check for working CXX compiler: /usr/bin/c++ -- works

You can see the same output in a local invocation of catkin_make on ROS Kinetic/Ubuntu Xenial:

-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
[..]
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works

With catkin_tools you can see this by adding the -v option to your build verb invocation.

I don't know how to choose the version to compile my workspace (use the default compiler like the answer said).

It would probably be good to figure out what the currently used version is first. You can do that by checking the output of the various build commands and/or by running gcc --version.


Edit:

Since I wrote the question I uninstalled and reinstalled gcc and g++,

which version? And how did you "uninstall and reinstall" it?

and I used these commands too export CC=/usr/local/bin/gcc; export CXX=/usr/local/bin/g++.

Setting environment variables like that should not be necessary, unless you have a setup with special requirements.

Also: on Ubuntu, system-managed compilers (or at least: their symlinks) are typically found in /usr/bin. Are you sure your compiler is located in /usr/local? If that is the case, then you're most likely not using a system managed compiler, which may the reason why you run into these issues.

What is the output of /usr/local/bin/gcc --version?

And would you know how that compiler ended up there?

Then I used CXX=g++5 CC=gcc5 catkin_make and it worked but just for one of my packages.

I'm not sure why you'd still need to do that if you've already done the export CC=.. and export CXX=.. commands earlier.

Tbh unless you have specific requirements and/or experience with it, I would not touch your compiler setup.