Stramge linking error in wiring.c: Undefined reference to setup

I've been porting my project (+40 .cpp and .h) to Visual Studio with the Visual Micro extension.
Suddenly the compilation failed with the following message:

Error compiling for board Arduino/Genuino Mega w/ ATmega2560 (Mega 2560)
Debug build failed for project 'CSense'
cccVEJYo.ltrans2.ltrans.o*: In function init
wiring.c:356: undefined reference to setup
wiring.c:356: undefined reference to loop
collect2.exe*: error: ld returned 1 exit status

As i have been struggling with getting my project and my own library in visual studio in the correct way, I have no idea what part of all the modifications have caused this error to popup.

I use quite a bit of 3rd party libraries (Nextion, Timer, EEPRomex, TinyGPS, DHT, MPU6050, BMP085 and some more) and some of them have local alterations of my one (which have been succefully compiled before)

Before I start dismanteling my project and library to find the cause of the problem the hard way, I was wondering if anybody could point me to the direction of the cause of this error or maybe even have a solution!


Did you define setup and loop functions?

Is there only one *.ino file?

Did you define setup and loop functions?

#include <Arduino.h>

#include "CSense.h"
#include "SenseUtils.h"
#include "CSenseStoredSettings.h"

CSense* C = NULL; // Its too early to create main object and all its parts

void setup() {
  Serial.print(F("Initializing Arduino..."));
  C = new CSense();

void loop() {


Is there only one *.ino file?

Good suggestion! Checked the log of a full build ... and only one .ino is mentioned :frowning:

Yes, I've solved it!!

It was caused by the fact that I had a .cpp and .h combination with the same name as the .ino !

So my main ino was CSense.ino and it included a CSense.h
Obviously the toolchain used in Visual Studio doesnt like that although I had no problems with this setup during the last months while i was compiling with a windows batch file directly callig arduino-builder.exe