Go Down

Topic: Error Importing Standard C++ library (cstdarg) (Read 160 times) previous topic - next topic

Arnaud9

My Setup

  • MacOS
  • Board: Arduino Uno
  • Arduino IDE Version : 1.8.10

Hello everyone,

I am fairly new to C++ compiling processes and I am trying to run a project but Arduino can not compile it. I get an error saying that the arduino builder can't find library cstdarg.

I am a bit suprised I could not find a clear answer about this since it seems quite simple. I must be missing something.


Minimum Working Example

mwe.ino

Code: [Select]
#include <cstdarg>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}


Detailed response (Arduino IDE verbose mode)

Code: [Select]

/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/arnauda/Documents/Arduino/libraries -fqbn=arduino:avr:uno -ide-version=10810 -build-path /var/folders/lx/t7n0s66x22g_f__4nlwghmzr0000gn/T/arduino_build_932281 -warnings=none -build-cache /var/folders/lx/t7n0s66x22g_f__4nlwghmzr0000gn/T/arduino_cache_932193 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -verbose /Users/arnauda/Documents/Arduino/sketch_nov20a/sketch_nov20a.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/arnauda/Documents/Arduino/libraries -fqbn=arduino:avr:uno -ide-version=10810 -build-path /var/folders/lx/t7n0s66x22g_f__4nlwghmzr0000gn/T/arduino_build_932281 -warnings=none -build-cache /var/folders/lx/t7n0s66x22g_f__4nlwghmzr0000gn/T/arduino_cache_932193 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=/Applications/Arduino.app/Contents/Java/hardware/tools/avr -verbose /Users/arnauda/Documents/Arduino/sketch_nov20a/sketch_nov20a.ino
Using board 'uno' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
Using core 'arduino' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr
Detecting libraries used...
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard /var/folders/lx/t7n0s66x22g_f__4nlwghmzr0000gn/T/arduino_build_932281/sketch/sketch_nov20a.ino.cpp -o /dev/null
Alternatives for cstdarg: []
sketch_nov20a:1:10: error: cstdarg: No such file or directory
ResolveLibrary(cstdarg)
 #include <cstdarg>
  -> candidates: []
          ^~~~~~~~~
compilation terminated.
exit status 1
cstdarg: No such file or directory


However, I see that this library is present in several locations on my computer:

  • /usr/include/c++/4.2.1/tr1/cstdarg
  • /usr/include/c++/4.2.1/cstdarg
  • /usr/local/Cellar/gcc/9.1.0/include/c++/9.1.0/tr1/cstdarg
  • /usr/local/Cellar/gcc/9.1.0/include/c++/9.1.0/cstdarg
  • /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1/tr1/cstdarg
  • /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1/cstdarg


My questions

  • What compiler is Arduino using?
  • How can I add a path to the locations the compiler is looking for the libraries?
  • Can anyone explain the steps in the logs a bit more in details or provide me a resource about these commands?


Thanks a lot for your time !

pert

However, I see that this library is present in several locations on my computer:
None of those will be accessible when compiling with the Arduino IDE. It uses the toolchains specified by the hardware package of the currently selected board, rather than some random compiler installation you have on your computer.

What compiler is Arduino using?
This depends on which board you are compiling for. For the Arduino Uno, and the other AVR-based Arduino boards it's avr-gcc. The compiler version depends on which hardware package version you have installed. In the case of Arduino AVR Boards (the hardware package used for the Uno), this is somewhat related to the IDE version, since Arduino AVR Boards is bundled with the Arduino IDE. However, it is possible to install any version of Arduino AVR Boards with any IDE version so it's not certain that a specific IDE version will indicate a particular version of Arduino AVR Boards and thus avr-gcc.

The version of avr-gcc used by the Arduino AVR Boards bundled with Arduino IDE 1.8.10 is 7.3.0-atmel3.6.1-arduino5.

How can I add a path to the locations the compiler is looking for the libraries?
You can't.

Can anyone explain the steps in the logs a bit more in details or provide me a resource about these commands?
In the log you posted, you have a couple of arduino-builder commands and a avr-g++ command.

Information on arduino-builder:
https://github.com/arduino/arduino-builder

Information on avr-g++:
https://linux.die.net/man/1/avr-g++

sterretje

There is a stdargs.h; I guess it provides the same functionality as cstrargs.h.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Arnaud9

@pert @sterretje Thank you very much for your quick responses and clear explanations.

The project I am trying to compile has, indeed, only been tested on Arduino Nano 33 BLE and the library is available for this board.

I had not clearly in mind that the compiler was closely related to the board used. I will definitely have to modify the code to only include available libraries if I want to run it on my Arduino Uno.

Thanks again !

Go Up