Go Down

Topic: Error compiling with custommade library (Read 175 times) previous topic - next topic

nuddel69

Sep 17, 2020, 10:08 pm Last Edit: Sep 17, 2020, 10:09 pm by nuddel69
I just made my own library. I have never done so before and followed This tutorial. The sketch I used as a base worked fine as a project, but now I'm having issues compiling my example project. I have added the library in this post.

My error messages:

Code: [Select]

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

D:\Arduino\arduino-builder -dump-prefs -logger=machine -hardware D:\Arduino\hardware -hardware C:\Users\Mats Bjonnes\AppData\Local\Arduino15\packages -tools D:\Arduino\tools-builder -tools D:\Arduino\hardware\tools\avr -tools C:\Users\Mats Bjonnes\AppData\Local\Arduino15\packages -built-in-libraries D:\Arduino\libraries -libraries C:\Users\Mats Bjonnes\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10813 -build-path C:\Users\MATSBJ~1\AppData\Local\Temp\arduino_build_882378 -warnings=more -build-cache C:\Users\MATSBJ~1\AppData\Local\Temp\arduino_cache_342348 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=D:\Arduino\hardware\tools\avr -verbose C:\Users\Mats Bjonnes\Documents\Arduino\libraries\8segMat\Examples\Counter\Counter.ino

D:\Arduino\arduino-builder -compile -logger=machine -hardware D:\Arduino\hardware -hardware C:\Users\Mats Bjonnes\AppData\Local\Arduino15\packages -tools D:\Arduino\tools-builder -tools D:\Arduino\hardware\tools\avr -tools C:\Users\Mats Bjonnes\AppData\Local\Arduino15\packages -built-in-libraries D:\Arduino\libraries -libraries C:\Users\Mats Bjonnes\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=2341_0043 -ide-version=10813 -build-path C:\Users\MATSBJ~1\AppData\Local\Temp\arduino_build_882378 -warnings=more -build-cache C:\Users\MATSBJ~1\AppData\Local\Temp\arduino_cache_342348 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=D:\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=D:\Arduino\hardware\tools\avr -verbose C:\Users\Mats Bjonnes\Documents\Arduino\libraries\8segMat\Examples\Counter\Counter.ino

Using board 'uno' from platform in folder: D:\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: D:\Arduino\hardware\arduino\avr

Detecting libraries used...

"D:\\Arduino\\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=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "C:\\Users\\MATSBJ~1\\AppData\\Local\\Temp\\arduino_build_882378\\sketch\\Counter.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE

Alternatives for 8segMat.h: [8segMat]

ResolveLibrary(8segMat.h)

  -> candidates: [8segMat]

"D:\\Arduino\\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=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\Mats Bjonnes\\Documents\\Arduino\\libraries\\8segMat" "C:\\Users\\MATSBJ~1\\AppData\\Local\\Temp\\arduino_build_882378\\sketch\\Counter.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE

Error while detecting libraries included by C:\Users\MATSBJ~1\AppData\Local\Temp\arduino_build_882378\sketch\Counter.ino.cpp

"D:\\Arduino\\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=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\Mats Bjonnes\\Documents\\Arduino\\libraries\\8segMat" "C:\\Users\\Mats Bjonnes\\Documents\\Arduino\\libraries\\8segMat\\8segMat.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE

Error while detecting libraries included by C:\Users\Mats Bjonnes\Documents\Arduino\libraries\8segMat\8segMat.cpp

Generating function prototypes...

"D:\\Arduino\\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=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-ID:\\Arduino\\hardware\\arduino\\avr\\variants\\standard" "-IC:\\Users\\Mats Bjonnes\\Documents\\Arduino\\libraries\\8segMat" "C:\\Users\\MATSBJ~1\\AppData\\Local\\Temp\\arduino_build_882378\\sketch\\Counter.ino.cpp" -o "C:\\Users\\MATSBJ~1\\AppData\\Local\\Temp\\arduino_build_882378\\preproc\\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE

In file included from C:\Users\Mats Bjonnes\Documents\Arduino\libraries\8segMat\Examples\Counter\Counter.ino:1:0:

C:\Users\Mats Bjonnes\Documents\Arduino\libraries\8segMat/8segMat.h:5:9: error: macro names must be identifiers

 #ifndef 8segMat_h

         ^~~~~~~~~

Using library 8segMat in folder: C:\Users\Mats Bjonnes\Documents\Arduino\libraries\8segMat (legacy)

exit status 1

Error compiling for board Arduino Uno.



Though I suspect it'll be of little help, here's my code as well:

Code: [Select]

#include <8segMat.h>

8segMat 8segMat(12, 11, 3, 10, 5, 6, 8, 4);

void setup() {

}

void loop() {
  8segMat.nine();
}


The sketch I'm working on is the "Counter.ino" in the examples folder.

pert

Identifiers, including macro names, aren't allowed to start with a number. So you'll need to chose a different name for your include guard (perhaps "EightSegMat_h"?).

nuddel69

Identifiers, including macro names, aren't allowed to start with a number. So you'll need to chose a different name for your include guard (perhaps "EightSegMat_h"?).
Thanks, but this did little. Any other suggestions?

pert

Post the error output you're getting now.

david_2018

The error messages get a bit cryptic, but I finally noticed you forgot a semicolon in the header file:

Code: [Select]

   private:
    int _aPin;
    int _bPin;
    int _cPin;
    int _dPin;
    int _ePin;
    int _fPin;
    int _gPin;
    int _DPPin;
}  //  <<< you forgot the ;

#endif

Go Up