C++ Compiler for AT90CAN with Arduino Toolchain

Hello guys,
i´ve the following Problem. I ´ve imported a arduino project with libs that are written in arduino in cpp. All the the called functions in the ino are member function of class which is defined in the header. When I´m writing a member variable in the member function I get a undefined refrences error.

I´m using the C/C++ Intellisense extension in VS Code. I´ve installed the mingw64 compiler properly and it is in system path. But I still get these errors. Probably because platformio isnt recognizing the compiler.

Do you have any suggestion how to include the compiler in platformio? Is there any build tags I should use ?

Hard to say what is wrong. Either the file which implements myNFL is not being compiled in because ti’s in the wrong spot, or there’s a name-mangling error when interfacing C and C++ code. Can you show the project’s full code?

PlatformIO will always use its own compiler, for AVR that’s <home folder>/.platformio/packages/toolchain-atmelavr, it is never needed to set-up a compiler yourself.

Hey Max,
member functions ar defined in functionsvariables.h
Location:<folder>/PlatformIO/Project/ProjectName/lib

class NFL{
public:
    // Konstruktor
        NFL();

    // Funktionsdeklarationen// 
    void gpioInit();
        uint8_t canInit ();

    uint8_t msgIN1_ID;
}
extern NFL myNFL;

Member functions are declared in functionsvariables.cpp with writing on function member variable

uint8_t canInit(){myNFL.msgIN1_ID = 0xA; return 0; }

Location:<folder>/PlatformIO/Project/ProjectName/lib

Then calling the declared function in main.cpp

   canInit();

Location:<folder>/PlatformIO/Project/ProjectName/src

When Im implementing it like that i get the error you see at the top.

Thank you

Where is that object instantiated?

There needs to be a

NFL myNFL;

line in some .cpp file, otherwise you have just declared a object to exist but haven’t actually created it, leading to an undefined reference.

1 Like

Also be careful there, you cannot place that file directly in lib/. lib/ is supposed to have folders in it, each of which has the library files in it. Refer to the the README

This fixed my Problem. Thank you so much. First C++ I am coding.