Ask Your Question
0

Using C code in ROS, including a .c file in ROS

asked 2013-06-18 09:48:01 -0500

canatan gravatar image

updated 2014-01-28 17:16:57 -0500

ngrennan gravatar image

Hi,

I have a .c file (and a corresponding .h file) that has a function I would like to call inside my ROS package.

I altered the cmakelist.txt to include the .c file rosbuild_add_executable(myNodeName src/mainFile.cpp src/cFile.c)

This does not build however if I change the file's extension to cpp and then change the corresponding rosbuild statement it builds fine.

I looked at "how-to-develop-interface-from-c-program-with-ros" and "shell-script-and-c-program-in-ros" on this site.

Is my only option to build a wrapper for the .c file ?

edit retag flag offensive close merge delete

Comments

All I had to do was add the c99 flags to the cmakelist file to make it work. add_definitions(-std=c99)

canatan gravatar image canatan  ( 2013-06-18 16:45:19 -0500 )edit

Canatan, you should include that response as an answer.

SL Remy gravatar image SL Remy  ( 2013-06-19 02:39:17 -0500 )edit

done thanks

canatan gravatar image canatan  ( 2013-06-24 15:12:33 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-06-24 15:12:07 -0500

canatan gravatar image

All I had to do was add the c99 flags to the cmakelist file to make it work. add_definitions(-std=c99)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-06-18 09:48:01 -0500

Seen: 1,420 times

Last updated: Jun 24 '13