-
February 12th, 2009, 04:27 PM
#1
Linker error
I am trying to compile a linked list implementation file that includes a linked list header file. I get this error.
In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status
I know that since the implementation file is a cpp file without a main function, it needs some sort of special command when compiling, but I don't know what it is.
-
February 12th, 2009, 04:31 PM
#2
Re: Linker error
You can compile, but you can't link without a main function.
-
February 12th, 2009, 04:40 PM
#3
Re: Linker error
Oh. My professor has shown in his lecture sample code in this same format with the class interface in a header file and the class implementation in a cpp file that includes the header file.
-
February 12th, 2009, 05:20 PM
#4
Re: Linker error
Originally Posted by ichiben
Oh. My professor has shown in his lecture sample code in this same format with the class interface in a header file and the class implementation in a cpp file that includes the header file.
In real world usage those files would be included in a larger project, which will have a main function somewhere else. Or, you could make them into a library instead of an executable program, you just have to change your linker settings.
-
February 13th, 2009, 03:45 AM
#5
Re: Linker error
int main() is like an entry point to your's program.
You can put the implementation file at main file but not recommended or include header file at main file.
Thanks for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|