ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Novice
Ubuntu 16.04, Eclipse Helios Service Release 2
I had a simple working UDP echo server running (copied from a tutorial) and added some code to exit gracefully. After getting the syntax correct, had several errors as I worked through it, Eclipse now complains: multiple definition of ‘main’
No other errors or warnings or informational flags.
This is a single app, Project Explorer shows a single app. Have not even tried two apps in one project. Do a find for “main” and it is only in one place. The matching UDP client app is in a completely different project. Exited and restarted Eclipse and even rebooted to no avail.
What can be done to get Eclipse to tell me where it finds the other “main”? How can this be corrected?
Edit: in the C/C++ Projects there are three items:
udp_client_simple
udp_client_very_simple
udp_server_very_simple
Might those be causing the problem? I don't see a method to remove them from this window. Right click and delete wants to delete the whole thing, which I do not want. The option "Remove from Context" is greyed out.
I screwed up and accidently deleted everything while trying to fix this. I did notice that a copy of the client code managed to sneak into the project. That might be the source of the second "main" But Eclipse would not tell me so.
I will mark this resolved and would prefer to delete the entire thread since no definitive answer can be produced now.
If you, dear reader, are a moderator and can delete this thread, please do so. I do not see a delete option.
Resolution:
I believe I looked at a file from another project to copy a some code into this project, then accidently saved it. That created two files with main(). When I did a search for "main" it only found one instance.
I presume (weakly) that is because the second file is not part of the project. I used ctl-F for the find. When I used that just now I see that there is no scope for the find. (For example, Nothing that restricts the scope of the to just this file, just this project, or all open projects. So I presume the find looks in all open files.)
I put the resolution here in the OP so the reader does not need to scan through many posts to find the answer.
Last edited by bkelly; 04-02-2018 at 12:21 PM.
Reason: show resolution
You have to know that these user-friendly IDE-tools make the programmers work quick and easy.
In reality, they make simple things complicated, and they don't give you a fair chanche to find out what's actually happening.
So I suggest you write your first programs in a simple text-editor like mcedit, and compile them with gcc:
Code:
cd ~
mkdir mytest
cd mytest
mcedit test1.c
gcc -o test1 -Wall -W -Werror -g test1.c
./test1
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.