Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with typegen in compiling an orocos package #39

Open
yudhapane opened this issue Oct 9, 2020 · 8 comments
Open

Problem with typegen in compiling an orocos package #39

yudhapane opened this issue Oct 9, 2020 · 8 comments

Comments

@yudhapane
Copy link

Dear Orocos developer/maintainer,

I have a problem in compiling an orocos package that tries to generate a typekit from a header file. The package is a robot driver (KUKA LWR) and the header file is a library provided by the company (friComm.h). The library contains a number of datatypes and I would like orocos to recognize these datatypes. Therefore, in the CMakeLists.txt, I added the following:

orocos_typegen_headers(--notransports=corba,typelib,mqueue include/kuka_lwr_fri/friComm.h)

Upon compilation (using catkin_make) I received the following error:

Cannot require 'typelib'
If you are using Rock, the 'typelib' package should have been installed automatically.
First, make sure that you have loaded autoproj's env.sh script before continuing
Second, typelib should be installed in tools/typelib from the root of your Rock installation.
If it is not the case, report this to the rock developers. To workaround, run
  amake typelib
and try again.
CMake Error at /home/common/orocos-install/orocos-2.9_ws/install_isolated/lib/cmake/orocos-rtt/UseOROCOS-RTT.cmake:611 (add_subdirectory):
  The source directory

    /home/common/catkin_ws/build/robots/kuka-robot-hardware/kuka_lwr_fri/typekit

  does not contain a CMakeLists.txt file.
Call Stack (most recent call first):
  robots/kuka-robot-hardware/kuka_lwr_fri/CMakeLists.txt:34 (orocos_typegen_headers)

I am using the following:

It seems that there is a problem with the typegen and orogen. I can locate both on my computer. But when I type 'typegen' in the terminal it gives the same error that it can't import the typelib. I also have made sure that the RUBYLIB path contains the path of the typelib.rb file. So I don't understand why this error occurs. Could you perhaps enlighten me on how to solve this problem?

Thank you in advance,

Yudha (KU Leuven ROB Group)

@meyerj
Copy link
Member

meyerj commented Jan 27, 2021

I am not a Ruby pro and did not use orogen and typegen anymore for quite some time, but the error above seems to be due to missing paths in the RUBYLIB environment variable, as you already figured out. Normally this variable should be set by a catkin env-hook in package utilrb, 00.utilrb.sh.in.

If it is still relevant to you, could you please check whether that hook was installed to <prefix>/etc/catkin/profile.d/, and that RUBYLIB is set to the paths that contain orogen.rb, typelib.rb and typelib_ruby.so after you sourced the install-space? typelib also has a compiled library, which on my system (same OS and ROS distro) gets installed to <prefix>/lib/x86_64-linux-gnu/ruby/2.5.0. That is the path added by "@CMAKE_INSTALL_PREFIX@/@RUBY_EXTENSIONS_INSTALL_DIR@" in the env-hook. Next to that, apparently the [DY]LD_LIBRARY_PATH also needs to be adjusted to find the shared library:

#!/bin/sh

# Ruby 1.9 and newer ships with RubyGems built-in. Uncomment for older Ruby versions.
#export RUBYOPT=-rrubygems

for file_path in "/opt/orocos/melodic/install/lib/ruby/2.5.0" "/opt/orocos/melodic/install/lib/x86_64-linux-gnu/ruby/2.5.0"; do
  if [ ! -d "$file_path" ]; then
    continue
  fi

  if [ -z "$RUBYLIB" ]; then
    RUBYLIB="$file_path"
  elif ! echo "$RUBYLIB" | grep -q "$file_path"; then
    RUBYLIB="$file_path:$RUBYLIB"
  fi
  export RUBYLIB

  if [ `uname -s` != Darwin ]; then
    if [ -z "$LD_LIBRARY_PATH" ]; then
      LD_LIBRARY_PATH="$file_path"
    elif ! echo "$LD_LIBRARY_PATH" | grep -q "$file_path"; then
      LD_LIBRARY_PATH="$file_path:$LD_LIBRARY_PATH"
    fi
    export LD_LIBRARY_PATH
  else
    if [ -z "$DYLD_LIBRARY_PATH" ]; then
      DYLD_LIBRARY_PATH="$file_path"
    elif ! echo "$DYLD_LIBRARY_PATH" | grep -q "$file_path"; then
      DYLD_LIBRARY_PATH="$file_path:$DYLD_LIBRARY_PATH"
    fi
    export DYLD_LIBRARY_PATH
  fi
done

But I am not sure whether that is actually needed, if Ruby finds the extension library by looking it up in the RUBYLIB path...

@cf-dtx
Copy link

cf-dtx commented Feb 1, 2021

Hello @meyerj,

First of all, thank you for taking the time to review this issue.

I carefully read your reply, and from what I can understand, I think my system is set up as you described. Where is how it looks like,

neuebot@neuebot-VirtualBox:~/orocos_toolchain/install/etc/orocos/profile.d$ ls
00.ocl-lua.sh  00.rtt.sh  00.utilrb.sh

neuebot@neuebot-VirtualBox:~/orocos_toolchain/install/etc/orocos/profile.d$ echo $RUBYLIB
/home/neuebot/orocos_toolchain/install/lib/x86_64-linux-gnu/ruby/2.3.0:/home/neuebot/orocos_toolchain/install/lib/ruby/2.3.0

neuebot@neuebot-VirtualBox:~/orocos_toolchain/install/etc/orocos/profile.d$ ls /home/neuebot/orocos_toolchain/install/lib/x86_64-linux-gnu/ruby/2.3.0
typelib_ruby.hh  typelib_ruby.so

neuebot@neuebot-VirtualBox:~/orocos_toolchain/install/etc/orocos/profile.d$ ls /home/neuebot/orocos_toolchain/install/lib/ruby/2.3.0
orogen  orogen.rb  typelib  typelib.rb  utilrb  utilrb.rb  yard-utilrb.rb

neuebot@neuebot-VirtualBox:~/orocos_toolchain/install/etc/orocos/profile.d$ ls /home/neuebot/orocos_toolchain/install/lib/x86_64-linux-gnu/ruby/2.3.0/
typelib_ruby.hh  typelib_ruby.so

Nonetheless, after sourcing the orocos_toolchain/env.sh script, I still get the same compilation error when I call the orocos_typegen_headers macro as @yudhapane pointed out.

(edit) I forgot to add that the 00.utilrb.sh looks identical to the one you pasted,

#!/bin/sh

# Ruby 1.9 and newer ships with RubyGems built-in. Uncomment for older Ruby versions.
#export RUBYOPT=-rrubygems

for file_path in "/home/neuebot/orocos_toolchain/install/lib/ruby/2.3.0" "/home/neuebot/orocos_toolchain/install/lib/x86_64-linux-gnu/ruby/2.3.0"; do
  if [ ! -d "$file_path" ]; then
    continue
  fi

  if [ -z "$RUBYLIB" ]; then
    RUBYLIB="$file_path"
  elif ! echo "$RUBYLIB" | grep -q "$file_path"; then
    RUBYLIB="$file_path:$RUBYLIB"
  fi
  export RUBYLIB

  if [ `uname -s` != Darwin ]; then
    if [ -z "$LD_LIBRARY_PATH" ]; then
      LD_LIBRARY_PATH="$file_path"
    elif ! echo "$LD_LIBRARY_PATH" | grep -q "$file_path"; then
      LD_LIBRARY_PATH="$file_path:$LD_LIBRARY_PATH"
    fi
    export LD_LIBRARY_PATH
  else
    if [ -z "$DYLD_LIBRARY_PATH" ]; then
      DYLD_LIBRARY_PATH="$file_path"
    elif ! echo "$DYLD_LIBRARY_PATH" | grep -q "$file_path"; then
      DYLD_LIBRARY_PATH="$file_path:$DYLD_LIBRARY_PATH"
    fi
    export DYLD_LIBRARY_PATH
  fi
done

@jdclzl
Copy link

jdclzl commented Mar 12, 2021

The orocos online doc mentions

"Typegen requires that you have built the Orocos Toolchain with autoproj and that you have 'sourced' the env.sh file in your shell. "

Maybe you should install autoproj first.

@neuebot
Copy link

neuebot commented Mar 13, 2021

The orocos online doc mentions

"Typegen requires that you have built the Orocos Toolchain with autoproj and that you have 'sourced' the env.sh file in your shell. "

Maybe you should install autoproj first.

Hello @jdclzl,

In my first post, I explain that I also tried to compile orocos from source, but I get the following error.

I just want to install a version of orocos in ubuntu 16.04/18.04 and be able to use typegen... 😩

@hex-plex
Copy link

hex-plex commented Apr 9, 2021

I am facing the same difficulty is there any fix for it.

@tyronedong
Copy link

same problem

@Ogiwara-CostlierRain464
Copy link

Ogiwara-CostlierRain464 commented Jun 26, 2022

  1. sudo gem install facets
  2. sudo apt install ruby-backports
  3. sudo gem install metaruby

@kaiqiboen
Copy link

kaiqiboen commented Sep 28, 2023

require "typelib"
and comment this lines
"begin
require "typelib"
rescure LoadError
......
end"

Trying do this, maybe fix this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants