run as external library

Typically: "How do I... ", "How can I... " questions
Post Reply
qiwang
Posts: 17
Joined: 25 Feb 2013, 13:34

run as external library

Post by qiwang »

Hello,

I run V-REP and ROS on different machines, where V-REP runs under windows and ROS runs under Ubuntu. I want to add extApi.o and extApiPlatform.o to my ROS package as external libraries, so that I can connect V-REP on another machine.

I am not sure whether it can be done this way, but in CMakeLists.txt of my ROS package, I tried to add the following code

Code: Select all

...
target_link_libraries(manta_node
#  ${catkin_LIBRARIES}
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.o          
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApiPlatform.o
 )
...
But I always get the errors:

Code: Select all

Linking CXX executable /home/viki/hydro_workspace/devel/lib/manta/manta_node
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApiPlatform.o: In function `extApi_launchThread':
extApiPlatform.c:(.text+0x755): undefined reference to `pthread_create'
collect2: ld returned 1 exit status
make[2]: *** [/home/viki/hydro_workspace/devel/lib/manta/manta_node] Error 1
make[1]: *** [manta/CMakeFiles/manta_node.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed
It seems the problems is "In function `extApi_launchThread': extApiPlatform.c:(.text+0x755): undefined reference to `pthread_create"


Thanks!

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: run as external library

Post by coppelia »

Hello Qi,

try to add the source files (i.e. extApi.c and extApiPlatform.c) to the package in the add_library section, then also add pthread to the target_link_libraries section. You might have to add a few other things in this section.

Cheers

qiwang
Posts: 17
Joined: 25 Feb 2013, 13:34

Re: run as external library

Post by qiwang »

hello,

Thanks for the help. I have tried, but I still get the errors.

Code: Select all

...
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1364:12: error: conflicting types for ‘_appendCommand_s_buff’
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1002:36: note: previous implicit declaration of ‘_appendCommand_s_buff’ was here
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c: In function ‘_appendCommand_s_buff’:
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1368:40: error: ‘SIMX_SUBHEADER_SIZE’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1369:19: error: ‘simx_cmdheaderoffset_mem_size’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1371:19: error: ‘simx_cmdheaderoffset_full_mem_size’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1372:22: error: ‘simx_cmdheaderoffset_pdata_offset0’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1373:19: error: ‘simx_cmdheaderoffset_pdata_offset1’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1375:19: error: ‘simx_cmdheaderoffset_cmd’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1376:22: error: ‘simx_cmdheaderoffset_delay_or_split’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1377:7: error: ‘simx_cmdheaderoffset_status’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c: At top level:
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1387:12: error: conflicting types for ‘_appendChunkToBuffer’
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1184:9: note: previous implicit declaration of ‘_appendChunkToBuffer’ was here
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c: In function ‘_appendCommandToBufferAndTakeIntoAccountPreviouslyReceivedData’:
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1419:55: error: ‘simx_cmdheaderoffset_cmd’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1419:86: error: ‘simx_cmdmask’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1420:14: error: ‘simx_cmd_read_string_stream’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1422:13: warning: assignment makes pointer from integer without a cast [enabled by default]
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1427:27: error: ‘SIMX_SUBHEADER_SIZE’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1427:108: error: ‘simx_cmdheaderoffset_pdata_offset0’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1428:75: error: ‘simx_cmdheaderoffset_mem_size’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1446:53: error: ‘simx_cmdheaderoffset_full_mem_size’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c: At top level:
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1458:12: error: conflicting types for ‘_getSameCommandPointer’
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1422:14: note: previous implicit declaration of ‘_getSameCommandPointer’ was here
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c: In function ‘_getSameCommandPointer’:
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1462:56: error: ‘simx_cmdheaderoffset_cmd’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1462:87: error: ‘simx_cmdmask’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1469:17: error: ‘simx_cmd4bytes_start’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1469:49: error: ‘simx_cmd8bytes_start’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1471:29: error: ‘SIMX_SUBHEADER_SIZE’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1474:49: error: ‘simx_cmd1string_start’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1482:50: error: ‘simx_cmdreserved_start’ undeclared (first use in this function)
/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c:1488:61: error: ‘simx_cmdheaderoffset_mem_size’ undeclared (first use in this function)
...
I made part of my CMakeList.txt

Code: Select all

...
###########
## Build ##
###########
include_directories(/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/include)
include_directories(/home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi)
include_directories(${catkin_INCLUDE_DIRS})


add_library(extApi /home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApi.c)
add_library(extApiPlatform /home/viki/V-REP_PRO_EDU_V3_1_2_Linux/programming/remoteApi/extApiPlatform.c)

add_executable(manta_node src/manta_node.cpp)

target_link_libraries(manta_node
#  ${catkin_LIBRARIES}
  pthread
  extApi
  extApiPlatform
 )
...


note: one of the examples "bubbleRobClient" works good.

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: run as external library

Post by coppelia »

you will have to copy a few header files into your project folder, such as v_repConst.h

Cheers

Post Reply