I have been trying to compile a simple hello world program in C++ on my lubuntu laptop. I use the command g++ -o out cta.cpp
but I always get the error message below..
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
I have made sure I have a main function, here is the entire program..
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
system("PAUSE");
return 0;
}
The laptop I am using is an ex-chromebook where I have overwritten the original OS using the instructions on this youtube video.
I have made sure that gcc and g++ are both the same version and both are in the usr/bin directory. I have uninstalled and reinstalled both. I am performing the commands from the same directory as cta.cpp, and I've made sure I've gotten the name of the file right. I am not sure what else to check.
How can I get my program to compile?
0 Answers