User forums > Help
Linker multiple definitions
thomas:
Well, if you include the header file, not the source file, it will work.
This isn't related to any particular IDE, compiler, or linker. You just aren't doing things right. Read a C/C++ tutorial on how to use #include to understand what it does.
sggarps:
Ok, I'll give that a go then. It just struck me as a little odd that it worked fine when compiling from the command line using g++. But I'll do what you suggest and get back to you. Thanks for your help.
sggarps:
Ok, I understand it now. The compiler automatically compiles all the source files, so they don't need to be included. The header file needs to be included so that the main function knows the class exists. When I compiled with g++, I didn't tell g++ to compile the class.cpp separately, but since it was included in the main.cpp file it was compiled anyway. Now I jsut need to try it out.
sggarps:
Yeah adding the .h instead of the .cpp worked :), thanks very much for your help :).
Navigation
[0] Message Index
[*] Previous page
Go to full version