Skip to content

Instantly share code, notes, and snippets.

@Meltwin
Last active June 14, 2024 09:19
Show Gist options
  • Save Meltwin/fe2c15a5d7e6a8795911907f627255e0 to your computer and use it in GitHub Desktop.
Save Meltwin/fe2c15a5d7e6a8795911907f627255e0 to your computer and use it in GitHub Desktop.
Installing ROS1 Noetic on Ubuntu 22.04

The process is pretty similar to the standard installation from source except for some fixes that you will have to make during the installation. I will keep the same header so you can keep a track on both guide at the same time (follow the official website for more explication, I will only write the steps to make).

1 - Prerequisites

1.1 - Installing bootstrap dependencies

To install bootstrap dependencies

sudo apt-get install python3-rosdep python3-rosinstall-generator python3-vcstools python3-vcstool build-essential

1.X - Changing rosdep repository adress

The first problem that you will encounter while following the official guide is the lacking of some packages on the apt. In order to resolve this problem, do these steps:

  1. Init rosdep: sudo rosdep init
  2. Modify /etc/ros/rosdep/sources.list.d/20-default.list as following:
# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

# generic
yaml <enter base.yaml address>
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
  1. Go to this gist and click Raw. Replace <enter base.yaml address> in the file by the address of the raw file.
  2. Save the file (require sudo rights).

1.Y - HDDTemp can't be found

It can happens that the package hddtemp can't be found with an error message similar to this:

diagnostic_common_diagnostics: [hddtemp] defined as "not available" for OS version [*]

For Ubuntu 22.04, it is possible to install it thanks to an online archive. The solution I found was on this StackOverflow post. What you have to do is:

sudo add-apt-repository ppa:malcscott/ppa
sudo apt update 
sudo apt install hddtemp

1.2 - Initializing rosdep

rosdep update

2 - Installation

2.1 - Create a catkin Workspace

Place yourself in the working folder of your choice. Create a ROS Workspace:

mkdir ./noetic_ws
cd ./noetic_ws

Downloading ROS1 source code.

rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic-desktop.rosinstall
mkdir ./src
vcs import --input noetic-desktop.rosinstall ./src

2.1.1 - Resolving Dependencies

Install all the dependencies with rosdep:

rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro noetic -y

If you are on another distro than classical Ubuntu/Kubuntu/Xubuntu (e.g. Manjaro, Mint, ...), add --os=ubuntu:jammy at the end of the precendent command:

2.1.2 - Building the catkin Workspace

2.1.2.A Building from the source

Let's build the sources. Run the following commands.

./src/catkin/bin/catkin_make_isolated -DCMAKE_BUILD_TYPE=Release

It's likely that you will have some errors while building the sources. In the next subsections, you will have the needed steps to resolve the issue.

Don't worry about the warning and notes (especially about deprecated BOOST_PRAGMA_MESSAGE ), only focus on the errors.

2.1.2.B - Fixing rosconsole error

The second error that you will likely encounter is linked to rosconsole and log4cxx. It means that you are likely to have log4cxx 11 or 12. To fix that you need to follow the changes suggested on this PR and especially this commit. Here is a quick summary of what to do:

  • Open src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp and replace its content by this version of the file
  • Same thing with src/rosconsole/test/thread_test.cpp with this version
  • Same thing with src/rosconsole/test/utest.cpp with this version
2.1.2.C - Fixing std::share_mutex error

The third error that you will likely encounter is a C++ compilation version. It's a problem where the packages wants to be compiled with C++11 and use objects from C++17.

The solution that I found was to change in every CMakeLists.txt of the packages that generate this errors the C++ version to use.

You can use this small python script to do that for you. Just place it at the root of your ROS workspace and run

python3 change_cpp.py
2.1.2.D - Installing noetic
Guide installation

If you want to install noetic in the working folder, run the installation with:

./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release
Opt folder installation (require sudo privileges)

If you want to install noetic in /opt/ros/noetic you can follow these steps:

  1. Run sudo mkdir /opt/ros/noetic
  2. Run sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/noetic
@EdMlt
Copy link

EdMlt commented Mar 15, 2024

Hello, thank you for the detailed process, I got the same issue than @hejia-zhang the local installation ok but not in the opt folder, I tried the solution provided by @Enkrl-last but still not working for me.
Any other way found to fix the issue?
Thank you 👍

@KlrShaK
Copy link

KlrShaK commented Apr 2, 2024

rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro noetic -y --os=ubuntu:jammy
executing command [sudo -H apt-get install -y python3-rospkg-modules]
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python3-rospkg-modules
ERROR: the following rosdeps failed to install
  apt: command [sudo -H apt-get install -y python3-rospkg-modules] failed

I get this error when running the line rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro noetic -y can anyone help with this

@Meltwin
Copy link
Author

Meltwin commented Apr 4, 2024

I get this error when running the line rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro noetic -y can anyone help with this

What OS are you using for the installation ?

@pk3012
Copy link

pk3012 commented Apr 4, 2024

I get this error when running the line rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro noetic -y can anyone help with this

What OS are you using for the installation ?

Hi i used Ubuntu 22.04and got this error.

WARNING: given --rosdistro noetic but ROS_DISTRO is "iron". Ignoring environment.
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
diagnostic_common_diagnostics: [hddtemp] defined as "not available" for OS version [*]

Also in the step sudo rosdep --init . i got this error

ERROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize

Is it important. I am installing it as a ROS1 as i already have ROS2 in my PC

@Meltwin
Copy link
Author

Meltwin commented Apr 5, 2024

Ok, let's try some things.

WARNING: given --rosdistro noetic but ROS_DISTRO is "iron". Ignoring environment.

First, try without sourcing ROS2 in the terminal for the installation, maybe it will mess it up :/

Also in the step sudo rosdep --init . i got this error
ERROR: default sources list file already exists: /etc/ros/rosdep/sources.list.d/20-default.list Please delete if you wish to re-initialize

Did you modify it before running sudo rosdep --init ? Try deleting the file, launching the previous command, then modifying and finally updtating it.

rm -f /etc/ros/rosdep/sources.list.d/20-default.list
sudo rosdep --init
nano /etc/ros/rosdep/sources.list.d/20-default.list # Modify the file as precised here
rosdep update

And try again. Keep me informed if it works or not.

@sergio-contente
Copy link

I'm getting this error:

./src/catkin/bin/catkin_make_isolated -DCMAKE_BUILD_TYPE=Release
ImportError: "from catkin_pkg.topological_order import topological_order" failed: No module named 'catkin_pkg'
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.

When I execute this command:

./src/catkin/bin/catkin_make_isolated -DCMAKE_BUILD_TYPE=Release

I've already installed "python3-catkin-pkg" with apt-get and it still not works. I'm using Ubuntu 22.04.
Do you know any solution to this problem?

@Meltwin
Copy link
Author

Meltwin commented Apr 5, 2024

I've already installed "python3-catkin-pkg" with apt-get and it still not works. I'm using Ubuntu 22.04.
Do you know any solution to this problem?

Seems like it doesn't find the package .. which is a bit weird. As I looked into the catkin_pkg repo, it seems that between the time I wrote this gist and now, they dropped the python2 version and switched to python3 and that might have make everything messy.
As the import is done with the condition on the ROS_PYTHON_VERSION environment variable, try running export ROS_PYTHON_VERSION=3 in the terminal before launching the command. I don't know if it will sort things out or not.

Else, try installing catkin_pkg though pip instead: python3 -m pip install catkin-pkg.

Others solutions could be found through this post on StackOverflow . If the previous ways doesn't works, try theses steps:

export PYTHONPATH="$PYTHONPATH:$(locate catkin_pkg -l)"
export PATH="$HOME/anaconda3/bin:$PATH"

@pk3012
Copy link

pk3012 commented Apr 24, 2024

SOLVED:)

Hi i am facing this error in 2.1.1 . You help solved the precious issue

ROS_DISTRO=ubuntu:jammy rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro noetic -y
WARNING: given --rosdistro noetic but ROS_DISTRO is "ubuntu:jammy". Ignoring environment.
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
diagnostic_common_diagnostics: [hddtemp] defined as "not available" for OS version [*]

earlier i tried this

rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro noetic -y
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
diagnostic_common_diagnostics: [hddtemp] defined as "not available" for OS version [*]

i still get same error

I use ubuntu22.04

Thanks in advance :)

SOLUTION: changed the base.yaml file to local directiory to fix it

@defenzelite-robotics
Copy link

Hi i am getting the usual error when compiling on ubuntu 24.04 can you help me with it,
the version of log4cxx is 1.1.0-1build3: amd64 arm64 armhf ppc64el riscv64 s390x, below i am adding the error text
/usr/include/log4cxx/spi/location/locationinfo.h:79:17: note: candidate expects 4 arguments, 3 provided
make[2]: *** [CMakeFiles/rosconsole_log4cxx.dir/build.make:76: CMakeFiles/rosconsole_log4cxx.dir/src/rosconsole/impl/rosconsole_log4cxx.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:368: CMakeFiles/rosconsole_log4cxx.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
<== Failed to process package 'rosconsole':
Command '['/home/robo/ros_catkin_ws/install_isolated/env.sh', 'make', '-j4', '-l4']' returned non-zero exit status 2.

Reproduce this error by running:
==> cd /home/robo/ros_catkin_ws/build_isolated/rosconsole && /home/robo/ros_catkin_ws/install_isolated/env.sh make -j4 -l4

Command failed, exiting.

@pk3012
Copy link

pk3012 commented Jun 1, 2024

HI i successfully install ROS Noetic on Ubuntu22.04 but then i tried
sudo apt install ros-noetic-geodesy ros-noetic-pcl-ros ros-noetic-nmea-msgs ros-noetic-libg2o

i get errors
E: Unable to locate package ros-noetic-geodesy
E: Unable to locate package ros-noetic-pcl-ros
E: Unable to locate package ros-noetic-nmea-msgs
E: Unable to locate package ros-noetic-libg2o

i need to buid a noetic package
TIA

@Meltwin
Copy link
Author

Meltwin commented Jun 9, 2024

HI i successfully install ROS Noetic on Ubuntu22.04 but then i tried sudo apt install ros-noetic-geodesy ros-noetic-pcl-ros ros-noetic-nmea-msgs ros-noetic-libg2o

i get errors E: Unable to locate package ros-noetic-geodesy E: Unable to locate package ros-noetic-pcl-ros E: Unable to locate package ros-noetic-nmea-msgs E: Unable to locate package ros-noetic-libg2o

i need to buid a noetic package TIA

Hi,
Yeah, so the reason you can't install Noetic in the first place is that the packages are not available for Ubuntu 22.04. So, other packages made for Noetic won't be available either. If you really want to install them, if the sources are available online then you try to clone the repositories and compile them by hand. It can be tiresome but that's the only way.
If they are not open-source then .. it's over for you, you should switch Ubuntu version to <= 20.04.

I hope that will help you :/

@Meltwin
Copy link
Author

Meltwin commented Jun 9, 2024

the version of log4cxx is 1.1.0-1build3: amd64 arm64 armhf ppc64el riscv64 s390x, below i am adding the error text
/usr/include/log4cxx/spi/location/locationinfo.h:79:17: note: candidate expects 4 arguments, 3 provided
make[2]: *** [CMakeFiles/rosconsole_log4cxx.dir/build.make:76: CMakeFiles/rosconsole_log4cxx.dir/src/rosconsole/impl/rosconsole_log4cxx.cpp.o] Error 1

Hi, it seems that your log4cxx it too recent for ROS Noetic (the changes making this error is due to this PR on the log4cxx repo). For me there are two ways of solving your issue:

  • Downgrade the Log4cxx package that you use on your system for a version < 0.13.0 (strictly, before the merge on the 6 of January 2022),
  • Try to fix rosconsole so that this error won't happen anymore. I can only give you a fix for this problem only, but if there are more occuring, then you'll have to fix them also.

Anyway, if you're interested, here's the fix I can come up with:

  1. Go and open the file rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp
  2. Go to the following function implementation (might be a bit different with other bugfixes):
void print(void* handle, ::ros::console::Level level, const char* str, const char* file, const char* function, int line)
{
  log4cxx::Logger* logger  = (log4cxx::Logger*)handle;
  try
  {
    logger->forcedLog(g_level_lookup[level], str, log4cxx::spi::LocationInfo(file, function, line));
  }
  catch (std::exception& e)
  {
    fprintf(stderr, "Caught exception while logging: [%s]\n", e.what());
  }
}
  1. Change logger->forcedLog(g_level_lookup[level], str, log4cxx::spi::LocationInfo(file, function, line)); by
logger->forcedLog(g_level_lookup[level], str, log4cxx::spi::LocationInfo(file, log4cxx::spi::LocationInfo::calcShortFileName(file),function, line));

I hope there's no other fix needed after that.


Sources I used here:

@SirTobias
Copy link

SirTobias commented Jun 14, 2024

Thank you for the detailed instructions. So far, it worked out. Please add the following packages to the apt command, as these are dependencies needed by Noetic:
sudo apt install liblog4cxx-dev libpoco-dev libbz2-dev libgpgme-dev liburdfdom-dev libogre-1.09-dev python3-defusedxml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment