Compiling issues.

So I found this gem while doing some research and thought I could utilize a portion of the code in my current project. But for the life of me I can not get the code to compile and was looking for some insights. It seems to be having issues with a separate file from the main code. Below is the error code.

Arduino: 1.6.7 (Windows 10), Board: “Arduino/Genuino Uno”

C:\Users\OPTIXM~1\AppData\Local\Temp\build78da92f43a39639143f936ab43f96b55.tmp/core\core.a(main.cpp.o): In function `main’:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `setup’

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to `loop’

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling.

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.

And here is the code at the end of the directory.

/*
main.cpp - Main loop for Arduino sketches
Copyright (c) 2005-2013 Arduino Team. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation;
either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software

Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <Arduino.h>

//
Declared weak in Arduino.h to allow user redefinitions.
int atexit(void (* /func/ )()) { return 0; }

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

void setupUSB() attribute((weak));
void setupUSB() { }

int
main(void)

;{

init();

initVariant();

#if defined(USBCON)
USBDevice.attach();

#endif

setup();

for (;:wink:
{

loop();

if (serialEventRun) serialEventRun();

}

return 0;
}

Any idea?

Yes, it's rather obvious. The function "main()" is already defined in the Arduino environment. You have to adapt the code to work with setup() and loop(). Or else do some tinkering outside of that environment.

Also, quote tags are not code tags.

That is the main() in the arduino environment, i do not believe that I am defining main() a second time. care to take a look at the attachment?

tvout.txt (19.3 KB)

Your sketch does not define a setup function nor does it define a loop function.

those functions are part of the arduino environment outside of my code. You can not edit the sketch either.

So, compile it outside of the Arduino environment.

It will compile in visual studios, however not sure how to burn it to the arduino uno without using the arduino environment.

http://lmgtfy.com/?q=program+arduino+hex

I have converted it to Hex and used Xloader to burn the arduino. However, it gets stuck on uploading for hours upon hours. First 2 times I just thought it was something to do with the computer, verified everything is set up for com1 (it was) and performed a reboot. Then i decided it might just take a while so i left it running for the past 3 hours. Still a no go. is their a program you prefer over Xloader or?

Uhm, Arduino IDE 1.6.4 ::)

I'll test Xloader tomorrow