[FIXED] C++ undefined reference to main

So, I get all the steps correct, but when I get to step 4 and want to run the entire program by entering in g++ temperature.cpp I get an error message saying “undefined reference to ‘main’” but I have everything done correctly, and the information is typed in correctly word for word.

Hello, @unearthlysoap!
Is this the full text of the error you are seeing?

/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

If so, your code is not causing it. It is a problem with the website that will hopefully be addressed soon.

Yes that’s exactly what is happening thank you! Glad to know I did all the correct steps!

1 Like

I can’t say for sure that you did everything correctly, but this particular error is not related to your code. :wink:

This problem is caused also because , when i include the file.hpp , in my system the main file do not find any declaration of the method / constructor

Not sure what you’re referring to. The original post was referring to a bug in the CC learning environment that was fixed nearly 2 years ago. If you have a question regarding your code, please post the code, and the error message if you are receiving one.