-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Would not work under CLion with Arduino Nano 328 -- workaround found #162
Comments
Looking at the Arduino.cmake file, around line 822, inside the function get_arduino_flags, there is the line:
The worked for the old Arduino nano328 definition (see earlier post), as there is a "nano328.build.mcu=atmeta328p" line. However, the new Arduino 1.6 boards.txt looks like this:
But at this point, I lack the CMAKE knowledge to make it handle the .menu cases in the new boards.txt file format. |
Thank you for sharing your experience! In the Arduino IDE the code below compiles fine, while in CLion/CMake there is the following error message:
Thank you very much |
Looking at the example, shouldn't the code read: That said, I tried to use the Servo Sweep example within CLion using CMake, and even though I set the ARDLIBS Servo flag, it still wouldn't compile. I also tried various link_directories options, pointing directly to my Servo.h location. Variations include directory locations and ARDLIBS (Servo, Servo.h, Servo.cpp) options.
And I still got the cmake error: undefined reference to `Servo::Servo()' Anyone else out there that can help? |
Got Servo to Work with the following addition to CMakeLists.txt
This also worked:
This also worked, without the link directories. |
This also work for Stepper library |
@mizraith Thanks for your answer it helped me to find another workaround which I will put here just for people if needed. The workaround ressembles a lot, but instead of changing the platform files, I only change the CMakeList.txt file, by settings the cmake variables. I add the following in the CMakeList.txt file. This comes from the installed boards.txt file in the arduino cmake tools so you might need to check that yours is the same.
Then the entire project file looks like this :
Again, thanks for your findings ! |
I'm putting this here to help others that may be struggling with the same issue. I'm working on identifying a fix for arduino-cmake Downloaded CLion and the CLion-Arduino 1.2.1 plugin (which uses arduino-cmake), but wanted to get down my workaround for others to find.
I'll follow up with a possible workaround, but the crux of it is that the arduino-cmake doesn't seem to be able to process the new boards.txt format when there are core variants. I'm on a Mac (10.11) and have several Arduino SDK installs (1.06, 1.56, 1.6x) under /Applications. [ I truly wish the Arduino maintainers would reign in development efforts so that the SDKs don't all behave so differently and have arbitrarily different internal workings! ]
First Lesson -- arduino-cmake looks for /Applications/Arduino.app So rename your preferred SDK as "Arduino.app". Arduino 1.06 and 1.5+ have a different internal structure...but Arduino-Cmake seem stop handle this okay.
Second Lesson -- I tried at least a dozen different settings (CFLAGS, CXXFLAGS, ARDUINO FLAGS, etc etc), but kept getting a warning the the avr-g++ compiler was not getting the "-mmcu" flag. Sure enough, when you look at the cmake log, the line contains "-mmcu= " (nothing afterwards. Again, tried every setting....but was only able to compile under 1.06.
QUESTION: Is there an Arduino-Cmake setting that allows you to pass in a -mmcu flag to the avr-g++ compiler without deleting the other flags already built up?
Third Lesson -- something about the Clion-Arduino or the Arduino-Cmake process retains too much info, even after a quit. When I found a clear workaround, it was not reloading the boards.txt file. I seem to also not see a result from print_board_list() every time either. This inconsistency makes it very hard to debug. Workaround: I ended up going into the CMakeFiles directory and selectively deleting stuff (your mileage will vary).
Workaround steps to compile for nano328 on Arduino 1.5+
I opened the 1.08 boards.txt file and simply copied the nano328 section into the 1.5+ boards.txt file. It looks like this:
``
Again -- if you don't see "nano328" from your print_board_list() call, then you'll need to do some cleaning of CMakeFiles
With the above workaround, I don't need to edit any of the internal arduino-cmake files and my CMakeLists.txt file looks like:
`
The text was updated successfully, but these errors were encountered: