How to compile if i dont have .ino file

I would like to compile and upload a sketch on my board, but my issue is that the folder i got from github does not contain a ".ino" file like i'm used to, only 2 ".cpp" files and a " .h" file...

I am unsure how to proceed when that is the case.

I am sure it is meant for arduino IDE as the beginning of the main.cpp goes like that:

#include <Arduino.h>
#include <Adafruit_NeoTrellisM4.h>
#include <instruments.h>

thanks for the help

1 Like

Provide a link to the GitHub in question perhaps?

I'd guess these are part of a library. Not a "top level" Arduino "sketch".

You can try re-naming it .INO but that probably won't work...

I must guess also hint.

Is there a *.pde file from the old days?

a7

What does the rest of the .cpp look like? If it looks like Arduino code, just rename it *.ino and see what happens.
Also, make sure it's not .CCCP might be Russians using your Arduino to do nefarious things.

The developer might have been using PlatformIO instead of the Arduino IDE to build it.

1 Like

You can create an empty .ino file. Any .cpp in the same folder will be compiled.

Or rename one of the .cpp files to a .ino file.

1 Like

I suppose there is no need to add comments until we get the link to the code…

Arduino "sketches" in the .ino format must contain the setup() function and the loop() function to be accepted by the IDE. Does any of your files contain those?

1 Like

Not true. If a sketch contains an 'int main()' function, as does a regular C/C++ program, it will compile without error. It won't automatically initialize the Arduino libraries so Arduino functions can't be used unless you add your own calls to init() and initVarient().

Looks like @lefab514 is yet another "Hit-and-Run Question-Asking Newbie". There have been 10 replies to the original question and no further information coming from OP. Why do they bother asking?

The extremely minimalistic sketch

int main () {}

compiles indeed, even with the extention .ino. Good to know. So the IDE initialises the Arduino stuff only when it sees setup & loop and defaults to manual otherwise, or something like that? I never quite figured out what exactly that IDE does behind your back, actually.

I think what happens is that the linker sees that "int main()" is already defined so it doesn't link in the "main.cpp" object file from the Arduino core. Without that file, there is no Arduino initialization and no references to setup() or loop(). Since there are no references, there is no error when they are not defined.

Note: You can have a setup() and/or loop() along with your own "int main()", but they will not be used since the Arduino main.cpp isn't there to call them.

int main () {}

void setup() {}

An Arduino main.c -

#include <Arduino.h>

int main(void)
{
    init();
#if defined(USBCON)
    USBDevice.attach();
#endif
    setup();
    for (;;) {
        loop();
        if (serialEventRun) serialEventRun();
    }
    return 0;
}

Add (THX @Coding_Badly)

The linker considers modules pulled in from a library "weak" in comparison to modules explicitly specified for inclusion.

So weak, it loses and you get your main.c.

a7

1 Like

Don't forget initVariant()!

And also declare a weak,empty one in case the variant file doesn't provide one"

// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }

THX, I did grab that from a unverified website, not tha e source code on my machine.

And I wondered about the weak thing, seems like something you would always want to have to make explicit… expected to see how that was done for main.c.

a7

Yes, I too thought it would be explicit but it's just the way libraries are linked.

I found the solution by myself in the end:
for the curious ones here's the link to the repo
generative-sequencer for the M4

Here's how I did it!
I just basically:

  • renamed the Main.ccp to generative_sequencer.ino
  • Created a folder for it with the same name and put the new generative_sequencer.ino fiile inside and moved that folder to my neotrellis examples folder inside libraries:
~/Documents/Arduino/libraries/Adafruit_NeoTrellis_M4_Library/examples/Generative_sequencer/Generative_sequencer.ino
  • Moved the two instruments files (.ccp & .h) in a folder that I also amed instruments and put this folder in arduino's library folder so
~/Documents/Arduino/libraries/Instruments

Verified it, then compiled it... worked like a charm!

been using it since yesterday!

1 Like

Nope, I so just happen to have been working for 16hrs straight, and no time to check on posts concerning my hobby.

I have posted my solution down in there.

Thanks for your constructive comment!

@smacaroni @johnwasser Is exactly what i did from a suggestion from another board.
Thank you for your answer.