Page 1 of 1

Codelite suddenly gives me "undefined reference of main" ?

Posted: Mon May 15, 2023 10:51 am
by Kaknes

Hello all!

I just recently started to learn how to code in C++.

Everything has been going good and I am learning through a course on Udemy.

Everything went fine and had set it up accordingly to what was instructed to do and was on my way to learn how to code.

However, as of yesterday, going through the course and learning, for some reason Codelite just spat out the error "undefined reference of main" out of nowhere.

The first second it could compile, build and execute and then the next time I did it it just spat out that error.

Confused and I did not know what was happening, I was looking around for solutions as to what could have caused this to happen and how to solve it.

The only hint I could find was was that Codelite was apparently trying to compile, build and execute in C, instead of C++. This is from what I understood is the error that is given when you try to execute C++ code in a C setup.

Moreover, I tried re-installing Codelite and installing different versions of Codelite, and it would still express that error.

I decided to give the setup Wizard a go again and set it up again as instructed from the course.

And the default code in the template for C++ popped up in the projects window. I managed to compile, build and execute it with no issues. However, if I changed one letter in the cout << "Default Project" << endl; to cout << "Default Projet" << endl; The same error appears again.

Codelite lets me compile this code but not build it and execute it.

I do not know what is causing this.

This version of Codelite was installed through Terminal using yay command.

I will add some attachments.


Re: Codelite suddenly gives me "undefined reference of main" ?

Posted: Mon May 15, 2023 4:58 pm
by DavidGH

Hi,

I don't know why that would happen, but a couple of suggestions:
1) With CodeLite closed, temporarily rename its config dir: e.g. mv ~/.codelite/ ~/.codeliteOrig/
Then run CodeLite, recreate a workspace and the appropriate project. Build and run several times and see what happens.

If that fixed the problem, fine. Otherwise:
2) Create a tarball of your failing ./codelite/ and your workspace/project and attach it to your reply. I'll test it here.

Regards,

David


Re: Codelite suddenly gives me "undefined reference of main" ?

Posted: Mon May 15, 2023 5:32 pm
by Kaknes

Hello! It did not work at all.

I am suspecting that it must have something to do with the config between my OS and Codelite itself. I am not experiencing this issue on my laptop at all, which is running the same OS and Codelite version. Only a matter of time before it might happen again.

Anyways, here is a link where you can download my Codelite folder and the workspace folder:

https://drive.google.com/drive/folders/ ... sp=sharing

Thanks!


Re: Codelite suddenly gives me "undefined reference of main" ?

Posted: Mon May 15, 2023 11:11 pm
by DavidGH

(I don't have an EndeavourOS VirtualBox guest, so I randomly chose to test on Fedora 38.)
I got the same link error. After playing with it for a while, and comparing it with one of the projects that comes with CodeLite, a C project, it turned out that you need to remove --static from your linker settings.


Re: Codelite suddenly gives me "undefined reference of main" ?

Posted: Tue May 16, 2023 3:21 am
by Kaknes

Hi! Thank you for checking it out for me.

Unfortunately, I did as you instructed and I am still getting this error.

Could it be that something got corrupted?


Re: Codelite suddenly gives me "undefined reference of main" ?

Posted: Tue May 16, 2023 11:14 am
by DavidGH

Try the C sample that comes with CodeLite; does that build and run? If so, just once or every time you try? If that's OK, it must be your project's settings that are somehow intermittently wrong, so try deleting that project and replace it, using the definitely-OK settings of the C-sample.

If the CodeLite sample also fails you have some system issue, though I can't imagine what that would be to cause an intermittent problem.


Re: Codelite suddenly gives me "undefined reference of main" ?

Posted: Sat May 27, 2023 6:11 pm
by eranif

have you tried changing the main signature to the standard int main(char** argv, int argc) ?