queezythegreat / arduino-cmake

Arduino CMake Build system
648 stars 216 forks source link

Can't compile project #10

Closed treaves closed 12 years ago

treaves commented 12 years ago

I've committed this to https://brewtroller.googlecode.com/svn/branches/BrewTroller/cmake

This should work with Arduino IDE 0022, but, the sanguine modifications from http://code.google.com/p/brewtroller/downloads/detail?name=BTModsForArduino22%2C20110227.zip&can=2&q= will need to be added (this adds support for the sanguino boards). The mods should be fairly straight-forward; the libraries do not need to be copied over into the IDE, as I've made them part of this project in the above referenced commit. HardwareSerial.* will need to be replaced from the above referenced zip file, as well as the boards updated.

This project fails with errors around several different "error: expected '=', ',', ';', 'asm' or 'attribute' before", like the following: /Users/treaves/Development/BrewTroller/cmake/libraries/PID_Beta6/PID_Beta6.h:4: error: expected '=', ',', ';', 'asm' or 'attribute' before 'PID'

treaves commented 12 years ago

The current issue here seems to be when it uses the C++ compiler, and when the C. It is not using the C++ compiler when it should, I think.

treaves commented 12 years ago

I have a second, simpler project https://brewtroller.googlecode.com/svn/trunk/Libraries/OpenTroller here. This fails, but differently than the first. This project compiled file until I added the test directory structure. Before the test directory was added, this just created a library.

The libraries directory still is not seen until I added the CMakeLists.txt file in the libraries directory.

Finally, the make/console directory has a file that just contains your sample code; this fails to compile with : :-1: error: cannot find -lWire

I have tried both with and with-out adding Wire to the libs directive for the console firmware. I plan on continuing to troubleshoot this, but, I could really use some help. I understand how difficult the cmake code is. A cmake expert would be good! :)

By the way, the Wire library is in place, and the imports work. It seems to be something with how the link command is being executed. The verbose output is: Linking CXX executable Console.elf cd /Users/treaves/Development/BrewTroller/OpenTroller/builds/unix/test/console && "/Applications/CMake 2.8-6.app/Contents/bin/cmake" -E cmake_link_script CMakeFiles/Console.dir/link.txt --verbose=1 /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-g++ -g -Os -ffunction-sections -fdata-sections -fno-exceptions -Wl,--gc-sections -mmcu=atmega1284p CMakeFiles/Console.dir/console.cpp.obj -o Console.elf ../../src/libatmega1284_Wire.a ../../src/libOpenTroller.a -lWire ../../src/libatmega1284_Wire.a ../../libraries/libModbusMaster.a ../../libraries/libatmega1284_CORE.a /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld: cannot find -lWire make[2]: * [test/console/Console.elf] Error 1 make[1]: * [test/console/CMakeFiles/Console.dir/all] Error 2 make: *\ [all] Error 2

treaves commented 12 years ago

O.K., oddly enough, when I then removed Wire from the LIBS directive, it now compiled fine. How very odd. That just leaves the first project failing, which seems to be a C versus C++ issue.

queezythegreat commented 12 years ago

Arduino type libraries should not be specified using the ${TARGET_NAME}_LIBS setting.

Arduino libraries get automatically detected from the sources (based on the includes), and if found automatically added internally to the libraries to be linked with the firmware. The _LIBS setting is to be used with libraries created using generate_arduino_library or with a library installed in the system (outside the build system).

queezythegreat commented 12 years ago

I'm closing this issue, as your last post seems to indicate you have fixed the problem.