Hi! Everybody,
I have several c++ sources files as following:
main.cpp:
#include "A.hpp"
int main()
{
return 0;
}
A.hpp:
#ifndef A_HPP_
#define A_HPP_
#include "B/B.hpp"
#endif /* A_HPP_ */
B/B.hpp:
#ifndef B_HPP_
#define B_HPP_
class Foo
{
int foo(int val);
};
#endif /* B_HPP_ */
B/B.cpp:
#include "B.hpp"
int Foo::foo(int val) { return val;}
when I compiled them using (actually the commands were generated by Eclipse IDE):
g++ -O0 -g3 -Wall -c -fmessage-length=0 -omain.o ..\main.cpp
g++ -O0 -g3 -Wall -c -fmessage-length=0 -oB\B.o ..\B\B.cpp
g++ -otest.exe main.o B\B.o B.o
I got these error messages:
B.o: In function `ZN3Foo3fooEi':
C:/Users/sam/workspace/test/Debug/../B.cpp:10: multiple definition of `Foo::foo(int)'
B\B.o:C:/Users/sam/workspace/test/Debug/../B/B.cpp:10: first defined here
collect2: ld returned 1 exit status
thx