Linking Problem

Hello,

I am currently installing Orocos OCL.

While running 'make', I get errors while linking 'helloworld'.

/usr/local/orocos/lib/liborocos-rtt.a(._corelib_activities_TimerOneShot.o)(.text+0x56): In function `RTT::detail::TimerOneShot::TimerOneShot[not-in-charge](long long)':
: undefined reference to `pthread_mutexattr_init'
/usr/local/orocos/lib/liborocos-rtt.a(._corelib_activities_TimerOneShot.o)(.text+0x60): In function `RTT::detail::TimerOneShot::TimerOneShot[not-in-charge](long long)':
: undefined reference to `pthread_mutexattr_settype'
/usr/local/orocos/lib/liborocos-rtt.a(._corelib_activities_TimerOneShot.o)(.text+0x146): In function `RTT::detail::TimerOneShot::TimerOneShot[in-charge](long long)':
: undefined reference to `pthread_mutexattr_init'
/usr/local/orocos/lib/liborocos-rtt.a(._corelib_activities_TimerOneShot.o)(.text+0x150): In function `RTT::detail::TimerOneShot::TimerOneShot[in-charge](long long)':
: undefined reference to `pthread_mutexattr_settype'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x8f): In function `RTT::OS::periodicThread(void*)':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x9a): In function `RTT::OS::periodicThread(void*)':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xcd): In function `RTT::OS::periodicThread(void*)':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x40d): In function `RTT::OS::PeriodicThread::PeriodicThread[not-in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_init'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x47e): In function `RTT::OS::PeriodicThread::PeriodicThread[not-in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x4bd): In function `RTT::OS::PeriodicThread::PeriodicThread[not-in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_init'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x52e): In function `RTT::OS::PeriodicThread::PeriodicThread[not-in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x644): In function `RTT::OS::PeriodicThread::PeriodicThread[not-in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x64e): In function `RTT::OS::PeriodicThread::PeriodicThread[not-in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x688): In function `RTT::OS::PeriodicThread::PeriodicThread[not-in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x7dd): In function `RTT::OS::PeriodicThread::PeriodicThread[in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_init'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x84e): In function `RTT::OS::PeriodicThread::PeriodicThread[in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x88d): In function `RTT::OS::PeriodicThread::PeriodicThread[in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_init'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x8fe): In function `RTT::OS::PeriodicThread::PeriodicThread[in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xa14): In function `RTT::OS::PeriodicThread::PeriodicThread[in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xa1e): In function `RTT::OS::PeriodicThread::PeriodicThread[in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xa58): In function `RTT::OS::PeriodicThread::PeriodicThread[in-charge](int, std::basic_string, std::allocator > const&, double, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xbfa): In function `RTT::OS::PeriodicThread::~PeriodicThread [not-in-charge]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xc05): In function `RTT::OS::PeriodicThread::~PeriodicThread [not-in-charge]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xd0a): In function `RTT::OS::PeriodicThread::~PeriodicThread [in-charge]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xd15): In function `RTT::OS::PeriodicThread::~PeriodicThread [in-charge]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xe1a): In function `RTT::OS::PeriodicThread::~PeriodicThread [in-charge deleting]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xe25): more undefined references to `sem_destroy' follow
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0xffc): In function `RTT::OS::PeriodicThread::start()':
: undefined reference to `sem_trywait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x1057): In function `RTT::OS::PeriodicThread::start()':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x11c8): In function `RTT::OS::PeriodicThread::stop()':
: undefined reference to `sem_trywait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x1228): In function `RTT::OS::PeriodicThread::stop()':
: undefined reference to `sem_trywait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x1450): In function `RTT::OS::PeriodicThread::setScheduler(int)':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x145b): In function `RTT::OS::PeriodicThread::setScheduler(int)':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x186a): In function `RTT::OS::PeriodicThread::setPeriod(double)':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x1875): In function `RTT::OS::PeriodicThread::setPeriod(double)':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x18f4): In function `RTT::OS::PeriodicThread::setPeriod(long, long long)':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x18ff): In function `RTT::OS::PeriodicThread::setPeriod(long, long long)':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x1aac): In function `RTT::OS::PeriodicThread::terminate()':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_PeriodicThread.o)(.text+0x1ab7): In function `RTT::OS::PeriodicThread::terminate()':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x97): In function `RTT::OS::singleThread_f(void*)':: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xb0): In function `RTT::OS::singleThread_f(void*)':: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x15b): In function `RTT::OS::singleThread_f(void*)':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x2fb): In function `RTT::OS::SingleThread::SingleThread[not-in-charge](int, std::basic_string, std::allocator > const&, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_init'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x30e): In function `RTT::OS::SingleThread::SingleThread[not-in-charge](int, std::basic_string, std::allocator > const&, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_init'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x3aa): In function `RTT::OS::SingleThread::SingleThread[not-in-charge](int, std::basic_string, std::allocator > const&, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x3b4): In function `RTT::OS::SingleThread::SingleThread[not-in-charge](int, std::basic_string, std::allocator > const&, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x3e8): In function `RTT::OS::SingleThread::SingleThread[not-in-charge](int, std::basic_string, std::allocator > const&, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x5bb): In function `RTT::OS::SingleThread::SingleThread[in-charge](int, std::basic_string, std::allocator > const&, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_init'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x5ce): In function `RTT::OS::SingleThread::SingleThread[in-charge](int, std::basic_string, std::allocator > const&, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_init'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x66a): In function `RTT::OS::SingleThread::SingleThread[in-charge](int, std::basic_string, std::allocator > const&, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x674): In function `RTT::OS::SingleThread::SingleThread[in-charge](int, std::basic_string, std::allocator > const&, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x6a8): In function `RTT::OS::SingleThread::SingleThread[in-charge](int, std::basic_string, std::allocator > const&, RTT::OS::RunnableInterface*)':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x856): In function `RTT::OS::SingleThread::~SingleThread [not-in-charge]()':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x85e): In function `RTT::OS::SingleThread::~SingleThread [not-in-charge]()':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x8c6): In function `RTT::OS::SingleThread::~SingleThread [not-in-charge]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0x8d0): In function `RTT::OS::SingleThread::~SingleThread [not-in-charge]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xa56): In function `RTT::OS::SingleThread::~SingleThread [in-charge]()':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xa5e): In function `RTT::OS::SingleThread::~SingleThread [in-charge]()':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xac6): In function `RTT::OS::SingleThread::~SingleThread [in-charge]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xad0): In function `RTT::OS::SingleThread::~SingleThread [in-charge]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xc56): In function `RTT::OS::SingleThread::~SingleThread [in-charge deleting]()':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xc5e): In function `RTT::OS::SingleThread::~SingleThread [in-charge deleting]()':
: undefined reference to `sem_wait'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xcc6): In function `RTT::OS::SingleThread::~SingleThread [in-charge deleting]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xcd0): In function `RTT::OS::SingleThread::~SingleThread [in-charge deleting]()':
: undefined reference to `sem_destroy'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xe0c): In function `RTT::OS::SingleThread::setScheduler(int)':
: undefined reference to `sem_post'
/usr/local/orocos/lib/liborocos-rtt.a(._os_common_SingleThread.o)(.text+0xf28): In function `RTT::OS::SingleThread::start()':
: undefined reference to `sem_post'
collect2: ld returned 1 exit status
make[2]: *** [helloworld/helloworld] Error 1
make[1]: *** [helloworld/CMakeFiles/helloworld.dir/all] Error 2
make: *** [all] Error 2

This seems to have something to do with linking.

I am currently running ld version 2.12.

Unfortunately I have been unable to remedy this problem. Would any of you be able to help point me in the right direction?

Thanks,
Ben

Linking Problem

On Thursday 22 March 2007 04:22:41 BKoopman wrote:
> Hello,
>
> I am currently installing Orocos OCL.
>
> While running 'make', I get errors while linking 'helloworld'.
>
> /usr/local/orocos/lib/liborocos-rtt.a(._corelib_activities_TimerOneShot.o)
(.text+0x56): In function
`RTT::detail::TimerOneShot::TimerOneShot[not-in-charge](long long)':
> : undefined reference to `pthread_mutexattr_init'

[...]

> This seems to have something to do with linking.
>
> I am currently running ld version 2.12.
>
> Unfortunately I have been unable to remedy this problem. Would any of you
> be able to help point me in the right direction?

It seems the linker did not receive the -lpthread option. On our platform,
that seems to be optional, while required on yours. Looking at the
/usr/local/orocos/lib/pkgconfig/orocos-rtt.pc file, that option is indeed
absent. The easiest thing to do is to edit that file and add -lpthread
to the end of the line starting with

Libs: -L${libdir} -lorocos-rtt ... -lpthread

You then need to rerun cmake (cd build; cmake ..) in OCL such that it picks up
this flag. Then issue make and it should work.

Thanks for reporting,
Peter