Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pctechtv

macrumors member
Original poster
Sep 3, 2013
55
3
I have been trying to test some of the code I am working in Visual Studio in Xcode. I am running in to the problem when it comes time to include file in my project. When I use file add files to project, from that point on nothing will build successful. Even more the main.c that Xcode created for me stops working as well (won't build). Could someone suggest what I am not understanding or missing? Thanks

Screen Shot 2015-08-10 at 10.29.25 PM.png
 
Last edited:
You don't include the error message you get which makes things difficult but my guess from the picture alone is you still have the auto-generated main function in your project. With the one you added from your source code you now have 2 mains and that isn't allowed. Remove the auto generated main (which I guess is in main.c) and try again.
 
Look at your project files pane you'll probably note the existance of a "main.c" in the project template interfering with your successful linking.
 
Thanks guys a great help, it is what all of you suggest. Forgive me for lack of understanding of terminology in Xcode and how to work with C constructs. I started with programing with JavaScript and PHP this C stuff is new to me. The suggestions you guys said already helped me understand better. As for the project files pane (lloyddean suggest) I never found it. I do think that is the problem “successful linking” once deleting all other files with a main function it worked fine. I am including a pic of the error message here, it also says something about linking. I would like to know why if any of you know…. why Visual Studio does not have the same problem?

xcodeHelp1.jpg
 
I am wrong guys, Visual Studio does give the same error when the files are in same location. I was missing it, the way I was running them following lessons. Disregard my question about Visual Studio. So a C program can only have one main function.... good to know! As for not being able to find the "project files pane" I am still searching, I am using Xcode 7 beta. Could this be why I don't find it? Thanks
 
As for not being able to find the "project files pane" I am still searching, I am using Xcode 7 beta. Could this be why I don't find it?

Perhaps it's the one in the image you included that contains the files "func.c", "func.h", "working.c" and "main.c"?

You show us the content of the "func.c" which clearly contains your "main" function but failed to remove the file "main.c" from the project meaning the linker is likely complaining of more than one main function in the project.
 
Perhaps it's the one in the image you included that contains the files "func.c", "func.h", "working.c" and "main.c"?

I get it, I was looking at it! I thought that is was a specific other view. Thank you so much, you and the other members helped a great deal. I am working now, and cam continue learning more. Thanks!!!
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.