You are here

undefined reference to main | Cypress Semiconductor

undefined reference to main

Summary: 6 Replies, Latest post by finke_1659276 on 18 Nov 2016 02:02 AM PST
Verified Answers: 1
Last post
Log in to post new comments.
finke_1659276's picture
User
4 posts

I'm currently working on a BLE project with PSoC 4. Since today everything worked fine. But now I'm facing the error "undefined reference to main" every time I compile my project. Didn't change anything on the project or code since the last successful compilation.

Hope you can help me.

 

user_242978793's picture
User
1033 posts

Are you missing your int main; function ? It could have been removed in an edit. Please post your code so we can check it.

user_1377889's picture
User
9606 posts

You specified in main.c

extern int main(void)

Get rid of the "extern"

 

Bob

finke_1659276's picture
User
4 posts

That doesn't change anything. In C extern is declared implicit.

finke_1659276's picture
User
4 posts

I fixed it.

main.c wasn't compiled at all. So the linker didn't find the object file main.o. After removing main.c from the project and adding it again, it was compiled properly. But then I got the same problem for all the other files in my project. So I had to remove and add all the other files, too.

This seems to be a bug in the IDE, that should be further investigated.

user_1377889's picture
User
9606 posts

This issue probably has to do with the way you add the files to the project. When you right click on your original main.c file, the option to compile it is grayed out. Same for the other .c files.

 

Bob

finke_1659276's picture
User
4 posts

I added all files by right-clicking on the project -> Add -> Existing item/New item. But it just worked fine until yesterday. Didn't add any new files. It seems that something broke my project file.

Log in to post new comments.