Wind-River / vxworks7-ros2-build

Build system to automate the build of VxWorks 7 and ROS2
Apache License 2.0
96 stars 22 forks source link

Error in building a CMake project #18

Closed enriLoniterp closed 2 years ago

enriLoniterp commented 2 years ago

Hi @razr, thank you very much for the previous corrections, it all worked fine.

Now i'm currently finishing the examples, timer_lambda and python examples have been launched succesfully.

Then i passed to the Build a simple Cmake based OSS project:

cd vxworks7-ros2-build
export TOP_BUILDDIR=$PWD
export WIND_USR_MK=$TOP_BUILDDIR/mk/usr
export PACKAGE_DIR=$TOP_BUILDDIR/pkg
DEFAULT_BUILD=unixextra make

this 5 lines don't give any error, the i cloned this repository and created the directory:

git clone https://github.com/leethomason/tinyxml2.git
cd tinyxml2; mkdir vxworks-build; cd vxworks-build

Then i tried this command: cmake .. -DCMAKE_TOOLCHAIN_FILE=$TOP_BUILDDIR/buildspecs/cmake/rtp.cmake

It sends me back an error, but after i checked the interested directory rtp.cmake was not in here, instead i've found inside ./buildspecs/cmake: -Platform(directory) -toolchain.cmake

inside toolchain.cmake there is a comment:

DESCRIPTION
# This is toolchain.cmake template file
#
# Usage:
#    export WIND_CC_SYSROOT=<VSB_DIR>
#    Build RTP
#        cmake -D CMAKE_TOOLCHAIN_FILE=$WIND_CC_SYSROOT/toolchain.cmake [-DVX_TARGET_TYPE=RTP] <SRC_DIR>
#    Build DKM
#        cmake -D CMAKE_TOOLCHAIN_FILE=$WIND_CC_SYSROOT/toolchain.cmake -DVX_TARGET_TYPE=DKM <SRC_DIR>
#

# tell cmake to find VxWorks.cmake from 
# <DIR of toolchain.cmake>/cmake/Modules

My first attemp is Build RTP, i used export with the dir to my toolchain.cmake file, after i tried with the first cmake command: cmake -D CMAKE_TOOLCHAIN_FILE=$WIND_CC_SYSROOT/toolchain.cmake -DVX_TARGET_TYPE=RTP .. but i received:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:4 (project):
  The CMAKE_C_COMPILER:

    wr-cc

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.

CMake Error at CMakeLists.txt:4 (project):
  The CMAKE_CXX_COMPILER:

    wr-c++

  is not a full path and was not found in the PATH.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred!
See also "/home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeOutput.log".
See also "/home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeError.log".

so i've changed this command setting where my wr-cc and wr-c++ are located:

cmake CC=/home/rosdev/Desktop/wrsdk-vxworks7-up2/toolkit/host_tools/x86_64-linux/bin/wr-cc CXX=/home/rosdev/Desktop/wrsdk-vxworks7-up2/toolkit/host_tools/x86_64-linux/bin/wr-cc CMAKE_TOOLCHAIN_FILE=$WIND_CC_SYSROOT/toolchain.cmake ..`
 and apparently it moves on with this:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /home/rosdev/Desktop/wrsdk-vxworks7-up2/toolkit/host_tools/x86_64-linux/bin/wr-cc
-- Check for working C compiler: /home/rosdev/Desktop/wrsdk-vxworks7-up2/toolkit/host_tools/x86_64-linux/bin/wr-cc - broken
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/home/rosdev/Desktop/wrsdk-vxworks7-up2/toolkit/host_tools/x86_64-linux/bin/wr-cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_d000c/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_d000c.dir/build.make CMakeFiles/cmTC_d000c.dir/build
    gmake[1]: Entering directory '/home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_d000c.dir/testCCompiler.c.o
    /home/rosdev/Desktop/wrsdk-vxworks7-up2/toolkit/host_tools/x86_64-linux/bin/wr-cc    -o CMakeFiles/cmTC_d000c.dir/testCCompiler.c.o -c /home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeTmp/testCCompiler.c
    [wr-cc] Error: cannot find config file (tried ...)
    [wr-cc]   /home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/buildspecs/cmake/cc-conf/default
    [wr-cc]   /home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/buildspecs/cmake/cc-conf/default.conf
    gmake[1]: *** [CMakeFiles/cmTC_d000c.dir/build.make:78: CMakeFiles/cmTC_d000c.dir/testCCompiler.c.o] Error 1
    gmake[1]: Leaving directory '/home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:127: cmTC_d000c/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)

-- Configuring incomplete, errors occurred!
See also "/home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeOutput.log".
See also "/home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeError.log".

In this section of the error i see that it has moved to CmakeTmp dir and run the build command. Maybe the problem could be exactly because CmakeTmp is empty and wr-cc can't compile as mentioned below:

Change Dir: /home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_246d3/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_246d3.dir/build.make CMakeFiles/cmTC_246d3.dir/build
    gmake[1]: Entering directory '/home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_246d3.dir/testCCompiler.c.o
    /home/rosdev/Desktop/wrsdk-vxworks7-up2/toolkit/host_tools/x86_64-linux/bin/wr-cc    -o CMakeFiles/cmTC_246d3.dir/testCCompiler.c.o -c /home/rosdev/VxWorks_ros_master/vxworks7-ros2-build/tinyxml2/vxworks-build/CMakeFiles/CMakeTmp/testCCompiler.c

I can't understand what it is not working, maybe i'm missing some details. Thank you for the help and the attentions.

razr commented 2 years ago

@enriLoniterp please take a look at PR #19 thanks for reporting it.

enriLoniterp commented 2 years ago

Hi @razr, now i am able to execute simple RTP process with CMake as described in the new docs!

Next step is to execute my packages and my node.

[vxWorks *]# ls . Hi @razr, now i am able to execute simple RTP process with CMake as described in the new docs!

Next step is to execute my packages and my node. If i put my self inside /bin i have this list command:

[vxWorks *]# ls
. 
.. 
test2 
2to3 
2to3-3.8 
f2py 
f2py3 
f2py3.8 
idle3 
idle3.8 
pydoc3 
pydoc3.8 
python3 
python3-config 
python3.8 
python3.8-config 
xmltest 
rst2html.py 
rst2html4.py 
rst2html5.py 
rst2latex.py 
rst2man.py 
rst2odt.py 
rst2odt_prepstyles.py 
rst2pseudoxml.py 
rst2s5.py 
rst2xetex.py 
rst2xml.py 
rstpep2html.py 
__pycache__ 
docutils 
catkin_create_pkg 
catkin_find_pkg 
catkin_generate_changelog 
catkin_package_version 
catkin_prepare_release 
catkin_tag_changelog 
catkin_test_changelog 
_ros2_daemon 
ament_index 
launch_test 
pendulum_demo 
pendulum_launch.bash 
pendulum_logger 
pendulum_teleop 
ros2 
rttest_plot 
tlsf_allocator_example 
action_client_not_composable_with_cancel 
action_client_member_functions 
action_client_not_composable 
action_client_not_composable_with_feedback 
action_server_member_functions 
action_server_not_composable 
client_main 
composition_publisher 
composition_subscriber 
composition_composed 
publisher_member_function 
publisher_not_composable 
publisher_lambda 
service_main 
subscriber_not_composable 
subscriber_lambda 
subscriber_member_function 
timer_member_function 
timer_lambda 
hlds_laser_publisher 
turtlebot3_ros 
hello_headers 
test 
listener 
talker 

The last 4 files are my tests, in particular the last two are a publisher and a subscriber. I have an external package which i compiled with colcon build and then i extracted from the /install folder this two executable, i moved them in my simulation and then i tried: rtp exec -u 0x20000 ros2 run talker (talker is a simple publisher and obviously it works fine in my pc) but as i expected it doesn't work:

Launching process 'python3' ...
Process 'python3' (process Id = 0xffff80000825b7d0) launched.
usage: ros2 run [-h] [--prefix PREFIX] package_name executable_name ...
ros2 run: error: the following arguments are required: executable_name, argv
[vxWorks *]# rtp exec -u 0x20000 python3 ros2 run cpp_pubsub talker
Launching process 'python3' ...
Process 'python3' (process Id = 0xffff8000083c9bf0) launched.
Traceback (most recent call last):
  File "ros2", line 11, in <module>
    load_entry_point('ros2cli==0.7.11', 'console_scripts', 'ros2')()
  File "/ata4/lib/python3.8/site-packages/ros2cli/cli.py", line 69, in main
    rc = extension.main(parser=parser, args=args)
  File "/ata4/lib/python3.8/site-packages/ros2run/command/run.py", line 57, in main
    path = get_executable_path(
  File "/ata4/lib/python3.8/site-packages/ros2run/api/__init__.py", line 30, in get_executable_path
    paths = get_executable_paths(package_name=package_name)
  File "/ata4/lib/python3.8/site-packages/ros2pkg/api/__init__.py", line 41, in get_executable_paths
    prefix_path = get_prefix_path(package_name)
  File "/ata4/lib/python3.8/site-packages/ros2pkg/api/__init__.py", line 34, in get_prefix_path
    prefix_path = get_package_prefix(package_name)
  File "/ata4/lib/python3.8/site-packages/ament_index_python/packages.py", line 49, in get_package_prefix
    content, package_prefix = get_resource('packages', package_name)
  File "/ata4/lib/python3.8/site-packages/ament_index_python/resources.py", line 37, in get_resource
    for path in get_search_paths():
  File "/ata4/lib/python3.8/site-packages/ament_index_python/search_paths.py", line 29, in get_search_paths
    raise EnvironmentError(
OSError: Environment variable 'AMENT_PREFIX_PATH' is not set or empty

Can you give me some advice on how to compile and run my node and my packages inside VxWorks because i know how to deal this phase externally but i do not have clear the entire process from my package to my executable? Thanks again for your work and patient for my questions. Enrico