How to add Arduino library to CLion PlatformIO project - arduino

I worked through the steps at https://www.jetbrains.com/help/clion/platformio.html to get PlatformIO installed and working with CLion. The following program now works:
void setup() {
Serial.begin(9600);
Serial.println("yay, I'm working.");
}
void loop() {
}
Now... I need to get an ESP32-compatible SSD1306 library installed (among others), so I can actually do something useful.
As far as I can tell, CLion (with or without the PlatformIO plugin) has nothing like the library browser in the Arduino IDE. Is there a less barbaric way of getting Arduino libraries into a CLion-PlatformIO project than grabbing the library's repo from Github and hand-copying files (and their recursive dependencies)?
Are PlatformIO projects created via CLion round-trip compatible with VSCode+PlatformIO? Like, can I create the PlatformIO project in CLion, exit CLion, launch VSCode, open the same project, use VSCode to add the libraries, exit VSCode, then go back into CLion and use them? Or is that a recipe for pain, tears, and corrupt config files?

Opening a CLion+PlatformIO project in Visual Studio Code works fine especially when you just want to add Libraries.
As far as am concerned PlatformIO works best with Visual Studio Code.

As far as I can tell, CLion (with or without the PlatformIO plugin) has nothing like the library browser in the Arduino IDE. Is there a less barbaric way of getting Arduino libraries into a CLion-PlatformIO project than grabbing the library's repo from Github and hand-copying files (and their recursive dependencies)?
Using PlatformIO, you just need to add the library name into platformio.ini file. PlatformIO provides PlatformIO Home to help you with searching and adding library into platformio.ini file. Run pio home in the your terminal. If your setup is correct you will be able to run the command and access the web app.
For your reference:
Home page
Library Browser
Adding library to your project
platformio.ini
Are PlatformIO projects created via CLion round-trip compatible with VSCode+PlatformIO? Like, can I create the PlatformIO project in CLion, exit CLion, launch VSCode, open the same project, use VSCode to add the libraries, exit VSCode, then go back into CLion and use them? Or is that a recipe for pain, tears, and corrupt config files?
Yes. You can open it from both IDE. You can view more in their docs

Related

Is there any basic tutorial on how to compile software from source under windows

I'm a beginner on open source world.
I can compile my own C++ code in VS 2015. but, I have little knowledge about compiling open source code. I can't even find a project file of that.
Anyway, I'd like to compile Sigil 0.9.4 version from source. My system is Windows 10 64 bit, and Qt 5.6.0 is installed. I've been looking for any basic guide for that but I haven't found yet.
I have downloaded a source code zip file from the link
https://github.com/Sigil-Ebook/Sigil/releases
And I have no idea what's the difference between Sigil-0.9.4-Code.zip and Source code (zip).
Which one should I download to compile?
Intuitively, I used 'importing project' in Qt but I get message 'no rule to make target all. stop'
Any instructions for that?
Thank you in advance!!!
For compilation you will need to use CMake. I recommend going through their web-site and read about it.
If you look at the source repository of the software you are trying to build (Sigil), you will see the root folder contains CMakeLists.txt. This is the file that will tell cmake program how to build and configure the software.
If you are planning to use Qt as your IDE, I recommend to download and install cmake first. Then make sure, Qt's toolchain is set up properly with the cmake. Then all you have to do is to open that CMakeLists.txt in Qt (see more details in the aforementioned link). Also, you can find plenty other tutorials on how to use cmake to compile your projects.
Hope this will help you get started.

Exclude Arduino library from compilation

I've created an Arduino project using the "Adafruit_SSD1306" display library, which works as expected using a Uno board.
A subsequent project needed to use the ESP8266 wifi board, which required a new display library "ESP_SSD1306". I can see from the source this library is derived from the "Adafruit_SSD1306". Everything compiles and works as expected.
However, if I go back and try to rebuild my old project, or any old project, sample etc that references "Adafruit_SSD1306", it will not build, unless I remove the "ESP_SSD1306" library from my "libraries" folder.
The error is:
sketch_aug04b_xxxxxxx.ino:24:30: fatal error: Adafruit_SSD1306.h: No such file or directory
compilation terminated.
Error compiling.
The workaround is to add or remove this library from the libraries folder whenever I switch to non-ESP8266 project and manually add it back when I switch to an ESP8266-based project.
I'm guessing the libraries conflict in some way, but I am hoping there is a better user experience for dealing with this. Some #define or project setting I can use to remove a library from the compilation path (other then the current process, which involves manually removing the library).
Looks like I've found the answer.
Both libraries have the identical name in their library.properties file. This appears to be what is causing the conflict.
The solution was to change the name property of the ESP_SSD1306 library from "Adafruit SSD1306" to "ESP SSD1306":
name=ESP SSD1306
version=1.0.0
author=Adafruit
maintainer=Adafruit
sentence=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs!
paragraph=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs!
category=Display
url=https://github.com/adafruit/Adafruit_SSD1306
architectures=*

Using Arduino IDE to build Ardupilot code

I try to open and compile arduPilot code using Arduino IDE (V. 1.0.5). But it's not working. I found the code is not compatible with standard IDE.
How can you modify the code and build it? any help is appreciated.
It just worked for me. ArduPilot 2.7.1 and Arduino 1.0.5 on Windows.
Note that the ArduPilot build was last updated in 2010, back when Arduino was not using the new INO files, but PDE files. So you have to manually go to file->open, then select ardupilot_2-7.pde to open.
As you can see above ArduPilot has a modified Arduino IDE. The Visual Micro plugin for Atmel Studio also supports the APM modifications.

Compile standalone exe problems

So I made a program using Qt Creator (Windows) and I compiled and ran it. It runs fine on my computer, but when I send it to a buddy of mine, he gets these errors:
The program can't start because libgcc_s_dw2-1.dll is missing from your computer. Try reinstalling the program to fix this problem.
The program can't start because mingwm10.dll is missing from your computer. Try reinstalling the program to fix this problem.
What can I do for the exe to basically be standalone, so I can just send the exe anywhere and be able to run it without error.
I guess static linking is what you want, see these Qt docs for a detailed explanation.
The reason is that you used gcc in mingw to compile the program. You can either distribute those two dlls with your program (they're found in C:\Qt\YOUR_VERSION\mingw\bin) or do a static build as 7vies suggested.
He does not need to install Qt on his computer. You need to link the Qt libraries and build them into your executable, or include the necessary dll/library files with the distribution. You have to statically link to the Qt libraries/files/etc. Hope this helps.
He needs to install the Qt library on his computer. Tell him to go here.

Qt creator won't run app after compiling

I checked out a Qt project hosted on google code with SVN to a local folder. When I opened it on Qt Creator, it managed to compile the project, but when it tried to run the compiled program, an error message came up on the application output:
The process could not be started!
What is wrong?
I solved this problem by going to projects>run settings and manually specifying the executable. Found this solution by googling, don't know if it's the proper way to fix this.
I assume you tried to run it manually and not from the IDE by pressing Ctrl+R, and I assume that it works when you're running it from the IDE. If that's the case, the problem is that the compiled application requires the Qt libraries and the runtime loader can't find them. When deploying the app, you need to copy the Qt libraries it links against to the application folder (on Windows), or you need to copy them to the app directory and launch it via a wrapper script which adds that directory to LD_LIBRARY_PATH (on Linux.)

Resources