2023-04-22 01:55 AM
I have already spent hours trying to get the Arduino library working in my CubeIDE (1.12.0 IDE; latest STM32duino; Firmware F3 1.11.4). I set up all the include paths, and changed the arduino stuff, to point to the CubeIDE generated files.
I had some issues, that the Serial was not declared, but this could be fixxed, when i changed my user_man file to *.cpp. But now it says " undefined reference to `setup' ".
main.c:
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "user_main.h"
user_man.cpp:
#include "user_main.h"
#include "stdio.h"
#include "stm32f3xx_nucleo_32.h"
#include <stdbool.h>
#include "arduino.h"
void setup(){
}
void loop(){
}
user_main.h:
extern void setup();
extern void loop();
What has to be done in order to make it work?
Solved! Go to Solution.
2023-04-22 11:43 AM - edited 2023-11-20 07:25 AM
2023-04-22 07:12 AM
Use extern "C" void setup(.. forms to stop it mangling the name
2023-04-22 09:23 AM
Then i get this:
../Core/Src/user_main.h:1:8: error: expected identifier or '(' before string constant
1 | extern "C" void setup();
| ^~~
2023-04-22 09:42 AM
As I understand, you try running Arduino program in cubeIDE , -- good luck!
I also needed a library from Arduino for driving the 4"TFT, but I just made my program in cubeIDE and including the library from Arduino. After some adapting the function call and variables name, it's running fine. All is in C .
2023-04-22 10:40 AM
That seems to work:
#ifdef __cplusplus
extern "C" {
#endif
void setup();
void loop();
#ifdef __cplusplus
}
#endif
I still got other errors though.
2023-04-22 11:43 AM - edited 2023-11-20 07:25 AM
IT FINALLY WORKS! Woohoo!
2024-03-09 06:21 AM
Can you elaborate on how you get the Arduino vendor to work in CubelDE?