orocos / soem

ROS package wrapping the Simple Open EtherCAT Master (SOEM) from https://github.com/OpenEtherCATsociety/SOEM
http://wiki.ros.org/soem
77 stars 62 forks source link

Explicitly export libosal and liboshw #30

Closed garaemon closed 5 years ago

garaemon commented 5 years ago
mgruhler commented 5 years ago

@garaemon thank you for you contribution.

As with #24 there will be a complete restructuring of this repo and the build system, I don't think it is worth to merge this proposal now, though.

With the new system, all will be tied into a single library following the standard upstream SOEM practice. This eliminates the need for the explicit export.

Is this something you can live with? Please check out the respective upstream_soem_via_subtree branch and see if this resolves your issues.

garaemon commented 5 years ago

Hi @mgruhler,

I tested upstream_soem_via_subtree and I found the new package does not export dependency to pthread library.

During compilation of my code, I encountered the following error message:

/home/rueda/gitai/catkin_ws/devel/.private/soem/lib/libsoem.a(osal.c.o): In function `osal_thread_create':
osal.c:(.text+0x3c7): undefined reference to `pthread_attr_setstacksize'
osal.c:(.text+0x3df): undefined reference to `pthread_create'

If dependency to pthread is solved, the restructured package works well. The following code is based on CMakeLists of roscpp.

set(PTHREAD_LIB "")
find_package(Threads)
if(CMAKE_THREAD_LIBS_INIT)
  string(LENGTH ${CMAKE_THREAD_LIBS_INIT} _length)
  if(_length GREATER 2)
    string(SUBSTRING ${CMAKE_THREAD_LIBS_INIT} 0 2 _prefix)
    if(${_prefix} STREQUAL "-l")
      math(EXPR _rest_len "${_length} - 2")
      string(SUBSTRING ${CMAKE_THREAD_LIBS_INIT} 2 ${_rest_len} PTHREAD_LIB)
    endif()
  endif()
endif()
catkin_package(
  CFG_EXTRAS soem-ros-extras.cmake
  LIBRARIES soem ${PTHREAD_LIB}
)
mgruhler commented 5 years ago

@garaemon thanks for spotting this. I've never experienced this, but actually I've added the pthread linking manually in my packages. I've been able to reproduce and fix this as you suggested in c9befb8!

Kudos to you for spending time, debugging and actually providing the solution! Very much appreciated.

If this solves all your issues, please feel free to close this PR.

garaemon commented 5 years ago

@mgruhler

If this solves all your issues, please feel free to close this PR.

Yes, it solves all my issues. #24 looks good to me.