Error 1 Error Lnk2005 _main Already Defined In Main.obj
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up error LNK2005: _main already defined in hold.obj up vote 0 down vote favorite Hi Please i have browsed all same error that i got but I didnt get solving for my problem, so I am using MS VC++ 2010 and i have two files a.c and b.c, each one works no error alone and each one has a simple code and clear. But when i use them to gather shows this error **error LNK2005: _main already defined in a.c ** this same error shows on Code block IED. I think that refer to using main function twice. Now how can i use one main function for both file Code file a.c #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; http://stackoverflow.com/questions/26583763/error-lnk2005-main-already-defined-in-hold-obj it only takes a minute: Sign up Two files containing definition of main() Visual Studio? up vote 6 down vote favorite 1 I have created a project in Visual Studio 2008 Professional Edition. This project contains one .cpp file for each assignment like this... [-]Source Files \ |-- 233.cpp |-- test.cpp And each file contains definition of main(). Action:CTRL+F5 Error http://stackoverflow.com/questions/646559/two-files-containing-definition-of-main-visual-studio 1 error LNK2005: _main already defined in 233.obj test.obj Error 2 fatal error LNK1169: one or more multiply defined symbols found How do I compile and see output of each file ? Thanks. c++ visual-studio visual-studio-2008 share|improve this question edited Mar 14 '09 at 19:46 JaredPar 451k859211227 asked Mar 14 '09 at 19:31 Pratik Deoghare 13.4k1570118 add a comment| 2 Answers 2 active oldest votes up vote 12 down vote accepted You can't have 2 functions called main() in a single project. What you should do is change the names of the functions, and then call them from a new main() function which would function as a menu. If you make them separate projects, you can switch which one to run with Solution Properties -> Startup Project. share|improve this answer answered Mar 14 '09 at 19:33 rlbond 32.2k34133190 add a comment| up vote 3 down vote I guess in your situation your project consists of just one file. If you want to compile them separately then I suggest: create individual project (CSPROJ) file per each of the
Search this Thread Rate Thread #1 03-May-2008, 13:30 Mrehman New Member Join https://www.gidforums.com/t-18159.html Date: Mar 2008 Posts: 23 Error LNK2005: _main already defined https://www.reddit.com/r/reconstructcavestory/comments/271n3v/episode_2_lnk2005_main_already_defined_in_mainobj/ in hey guyz how's it going? alright the thing is i am working on structs, i think i have finished the code. when i compile it i don't have any errors but 4 warnings which i don't understand. following that when i error 1 run the program it gives me 2 errors. they are common and i searched for them on Google. i saw lot of them but didn't know where was i making error, and how should i fix it. this is what the code suppose to do Create 2 instances of the Struct 1st error 1 error Instance is underneath and 2nd is suppose to be ours. Mr. Lupoli 18005557878 1600 Pennsylvania Ave. Washington D.C. 20001 my code is CPP / C++ / C Code:
# include# include using namespace std; struct BIO { string Fname; string Lname; int Tele; string Str_add; string Town; string State; int Zip; }; void main() { cout<<"here's Mr. Lupoli's Info"< "Mr.","Lupoli",18005557878,"1600 Pennsylvania Ave","Washington","D.C.",20001}; cout<<"END OF INSTANCE"< "Here's My Info"< "Mateen","Rehman", 4434556786, "9351 Owings Choice Ct", "Owings Mills", "Maryland", 21117}; cout<<"END OF INSTANCE"< sorry that i use void main instead of int main. my errors are 1>------ Build started: Project: Struct, Configuration: Debug Win32 ------ 1>Linking... 1>Struct.obj : error LNK2005: _main already defined in Struct 2.obj 1>C:\Users\Amateen\Documents\Visual Studio 200 »reddit.comreconstructcavestorycommentsWant to join? Log in or sign up in seconds.|Englishlimit my search to /r/reconstructcavestoryuse the following search parameters to narrow your results:subreddit:subredditfind submissions in "subreddit"author:usernamefind submissions by "username"site:example.comfind submissions from "example.com"url:textsearch for "text" in urlselftext:textsearch for "text" in self post contentsself:yes (or self:no)include (or exclude) self postsnsfw:yes (or nsfw:no)include (or exclude) results marked as NSFWe.g. subreddit:aww site:imgur.com dogsee the search faq for details.advanced search: by author, subreddit...this post was submitted on 01 Jun 20143 points (100% upvoted)shortlink: remember mereset passwordloginSubmit a new linkSubmit a new text postreconstructcavestorysubscribeunsubscribe329 readers~5 users here nowThe official subreddit to accompany the youtube series Reconstructing Cave Story The intent is to have a place to bounce ideas for future refactors, ask for help with bugs, and discuss design solutions. Feel free to ask anything related. The Rules Don't be obscene or negative. If you have criticism (for myself or for other forum users), offer it positively. Good: "I think it would be better if you did this because...". "It would save you time if you did...". Bad: "You idiot. You should be doing it my way..." Don't spam. You will get banned.