Undefined reference to 'setup' and 'loop' using CMake for custom project
I am trying to implement a CLI uploader for an Arduino MEGA2560 using rosserial_arduino and CMake, based upon http://wiki.ros.org/rosserial_arduino... under LUbuntu 14.04 with ROS-Indigo on an ODROID (ARM) development board.
The tutorial works fine, as can be seen here:
$ catkin_make helloworld_firmware_hello-upload
Base path: /home/odroid/catkin_ws
Source space: /home/odroid/catkin_ws/src
Build space: /home/odroid/catkin_ws/build
Devel space: /home/odroid/catkin_ws/devel
Install space: /home/odroid/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/odroid/catkin_ws/build"
####
####
#### Running command: "make helloworld_firmware_hello-upload -j8 -l8" in "/home/odroid/catkin_ws/build"
####
[ 0%] Built target _rosserial_msgs_generate_messages_check_deps_RequestServiceInfo
[ 0%] [ 0%] Built target _rosserial_msgs_generate_messages_check_deps_Log
Built target _rosserial_msgs_generate_messages_check_deps_TopicInfo
[ 0%] [ 0%] Built target _rosserial_msgs_generate_messages_check_deps_RequestMessageInfo
Built target _rosserial_msgs_generate_messages_check_deps_RequestParam
[ 87%] Built target rosserial_msgs_generate_messages_py
[ 87%] Built target rosserial_msgs_genpy
[100%] Built target helloworld_ros_lib
-- Generating hello
-- Configuring done
-- Generating done
-- Build files have been written to: /home/odroid/catkin_ws/build/helloworld/firmware
[100%] Built target helloworld_firmware
make[4]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
[ 90%] Built target mega2560_CORE
[100%] Built target hello
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e9801
avrdude: reading input file "/home/odroid/catkin_ws/devel/share/helloworld/hello.hex"
avrdude: input file /home/odroid/catkin_ws/devel/share/helloworld/hello.hex auto detected as Intel Hex
avrdude: writing flash (9854 bytes):
Writing | ################################################## | 100% 1.60s
avrdude: 9854 bytes of flash written
avrdude: reading input file "/home/odroid/catkin_ws/devel/share/helloworld/hello.eep"
avrdude: writing eeprom (0 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 0 bytes of eeprom written
avrdude: safemode: Fuses OK (H:E6, E:D8, L:E6)
avrdude done. Thank you.
[100%] Built target hello-upload
[100%] Built target helloworld_firmware_hello-upload
However, when I create a new catkin_package for my desired file (which is actually a symbolic link to a ../sketchbook/ Arduino project due to the need for both IDE and non-IDE uploading (some students are competent with CLI, others GUI)), I get the following output (I have removed the Policy CMP0022 warnings from this output):
$ catkin_make mechbot_v3_firmware_code-upload
Base path: /home/odroid/catkin_ws
Source space: /home/odroid/catkin_ws/src
Build space: /home/odroid/catkin_ws/build
Devel space: /home/odroid/catkin_ws/devel
Install space: /home/odroid/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/odroid/catkin_ws/build"
####
####
#### Running command: "make mechbot_v3_firmware_code-upload -j8 -l8" in "/home/odroid/catkin_ws/build"
####
[ 0%] [ 0%] Built target _rosserial_msgs_generate_messages_check_deps_TopicInfo
Built target _rosserial_msgs_generate_messages_check_deps_Log
[ 0%] [ 0%] Built target _rosserial_msgs_generate_messages_check_deps_RequestServiceInfo
[ 0%] Built target _rosserial_msgs_generate_messages_check_deps_RequestParam
Built target _rosserial_msgs_generate_messages_check_deps_RequestMessageInfo
[ 87%] Built target rosserial_msgs_generate_messages_py
[ 87%] Built target rosserial_msgs_genpy
[100%] Built target mechbot_v3_ros_lib
-- Generating code
-- Configuring done
... lots of Policy CMP0022 warnings removed ...
-- Generating done
-- Build files have been written to: /home/odroid/catkin_ws/build/mechbot_v3/firmware
[100%] Built target mechbot_v3_firmware
Scanning dependencies of target mechbot_v3_firmware_code-upload
make[4]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
[ 71%] Built target mega2560_CORE
[ 78%] Built target mega2560_Wire
[ 82%] Built target mega2560_ITG3200
[ 85%] Built target mega2560_HMC58X3
[ 89%] Built target mega2560_Servo
[ 92%] Built target mega2560_ADXL345
[ 96%] Built target mega2560_LiquidCrystal
[ 96%] Built target mega2560_PinChangeInt
Linking CXX executable /home/odroid/catkin_ws/devel ...