Undefined main when main is defined [on hold]
Undefined main when main is defined [on hold]
I'm using Ubuntu 18.04 on Windows 10 and I have installed the gcc. Before this, I had no trouble compiling the .cpp but recently I'm encountering this error
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status"
I even tried to compile this dummy code but the error still occurs.
#include <iostream>
using namespace std;
int main() {
cout <<"whyn";
}
How can I fix that?
This question appears to be off-topic. The users who voted to close gave this specific reason:
I am sorry I am still new with this and not very familiar with the terms. However the dummy file name is "1.cpp" and the command was "g++ 1.cpp -o 1"
– bill
Jun 29 at 15:39
Bill, there is a 99.999% chance you messed somewhere while building your program. Trash everything, and restart anew in a fresh directory. It will work.
– YSC
Jun 29 at 15:45
thank you guys, it works
– bill
Jun 29 at 16:17
How do you build your program? Can you show us the exact commands that leads to the error? And are you sure you build with the right source or object files?
– Some programmer dude
Jun 29 at 15:36