Error Undefined Symbol .main
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 C++ Error: undefined reference to `main' up vote 5 down vote favorite 2 I'm working on a simple class List, but when compiling the header and cpp file, I get the error: undefined reference to `main' What am I doing wrong, and how could I fix this? Here is the list.h file that has simple headers: list.h #ifndef LIST_H #define LIST_H #include const int DEFAULT_CAPACITY = 100; class List { public: List(); List(int capacity); ~List(); void push_back(std::string s); int size() const; std::string at(int index) const; private: std::string* mData; int mSize; int mCapacity; }; #endif And here is the list.cpp file: list.cpp #include "list.h" #include List::List(){ mData = new std::string[DEFAULT_CAPACITY]; mSize = 0; mCapacity = 100; }; List::List(int capacity){ mData = new std::string[capacity]; mSize = 0; mCapacity = capacity; }; List::~List(){ delete[] mData; }; void List::push_back(std::string s){ if (mSizehere 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 Compile error: http://stackoverflow.com/questions/14620435/c-error-undefined-reference-to-main Undefined symbols: “_main”, referenced from: start in crt1.10.5.o up vote 16 down vote favorite 3 I have the following code: #include using namespace std; class testing{ int test() const; int test1(const testing& test2); }; int testing::test() const{ return 1; } int testing::test1(const testing& test2){ test2.test(); return 1; } after compilation, it gives me the following error: Undefined symbols: "_main", referenced from: start in http://stackoverflow.com/questions/550455/compile-error-undefined-symbols-main-referenced-from-start-in-crt1-10-5-o crt1.10.5.o ld: symbol(s) not found collect2: ld returned 1 exit status Why is it complaining about main? Can't i declare main in another file and include this one? Thanks a lot! c++ share|improve this question edited Sep 23 '09 at 17:13 Stu Thompson 23.7k1588144 asked Feb 15 '09 at 7:14 FurtiveFelon 3,960185582 add a comment| 2 Answers 2 active oldest votes up vote 20 down vote accepted You have tried to link it already: g++ file.cpp That will not only compile it, but try to already create the executable. The linker then is unable to find the main function that it needs. Well, do it like this: g++ -c file.cpp g++ -c hasmain.cpp That will create two files file.o and hasmain.o, both only compiled so far. Now you can link them together with g++: g++ -omy_program hasmain.o file.o It will automatically figure out that those are files already compiled, and invoke the linker on them to create a file "my_program" which is your executable. share|improve this answer answered Feb 15 '09 at 7:20 Johannes Schaub - litb 341k766701044 add a comment| up vote 1 down vote If you declare th
30 Days In the Last 90 Days In the Last 6 Months Home/Discussion Forum Error: L6218E: Undefined symbol main http://www.keil.com/forum/22459 (referred from rtentry2.o). Next Thread | Thread List | Previous Thread Start a Thread | Settings Details Message Read-Only AuthorAnand Dabhi Posted5-Mar-2013 18:18 GMT ToolsetARM Error: L6218E: Undefined symbol http://forums.devshed.com/programming/788154-linker-error-undefined-symbol-_main-module-c0-asm-post2599949.html main (referred from rtentry2.o). Anand Dabhi Hello!!!!!!!!! I have posted my program and the building message and errors below.Please solve the following errors and warning. #include #define RS 1<<4 error undefined // for write operation R/W pin of lcd is zero , so it is always grounded and not necessary to define // #define EN 1<<5 void delay(void) { unsigned int d; for(d=0; d<1000000; d++) { } } void outdata(unsigned char x) // send the data (cmd or data) to port // { int i; for (i=0 ; i<8 ; error undefined symbol i++) { if(x & (0x01<Search Username Password Remember Me? Register Lost Password? facebook google twitter rss Free Web Developer Tools Advanced Search Forum Programming Languages C Programming Linker Error : Undefined symbol _main in module c0.ASM Thread: Linker Error : Undefined symbol _main in module c0.ASM Share This Thread Tweet This + 1 this Post To Linkedin Subscribe to this Thread Subscribe to This Thread February 15th, 2011,12:15 AM #1 No Profile Picture viralmand View Profile View Forum Posts Registered User Devshed Newbie (0 - 499 posts) Join Date Feb 2011 Posts 6 Rep Power 0 Linker Error : Undefined symbol _main in module c0.ASM Sir, I had written a program in c like this: #include voidmain() { int p, n; float r, si; printf("Enter Value of p,n,r,"); scanf("%d%d%f, &p,&n,&r,"); si=p*n*r/100; printf ("%f", si); return 0; } while compling , it gives me error, Linker Error : Undefined symbol _main in module c0.ASM Please Help me viralmand Faq February 15th, 2011,01:00 AM #2 No Profile Picture the eVil piXel View Profile View Forum Posts Registered User Devshed Newbie (0 - 499 posts) Join Date Feb 2011 Posts 54 Rep Power 0 give a space between void and main. :eh: Faq February 15th, 2011,01:04 AM #3 No Profile Picture the eVil piXel View Profile View Forum Posts Registered User Devshed Newbie (0 - 499 posts) Join Date Feb 2011 Posts 54 Rep Power 0 Originally Posted by viralmand Sir, I had written a program in c like this: #include voidmain() ( SPACE GOES HERE) return 0; (NO NEED OF THIS - u sud be getting a warning) viralmand give a space between void and main. :eh: Faq February 15th, 2011,01:14 AM #4 LaughingBelly View Profile View Forum Posts Who set my Title? Devshed Novice (500 - 999 posts) Join Date Jun 2004 Posts 715 Rep Power 260 It should have been Code: int main() void is not a standard return type for main. Nobody is perfect. I am Nobody. Faq February 15th, 2011,01:54 AM #5 No Profile Picture the eVil piXel View Profile View Forum Posts Registered User Devshed Newbie (0 - 499 posts) Join Date Feb 2011 Posts 54 Rep Power 0 Originally Posted by LaughingBelly It sh