Hi all.
I'm having a linking issue with a basic C++ program. No, I'm not including .cpp files!
This is what's happening.
main.cpp
#include "header.h"
#include <iostream>
int main() {
std::cout << "Hello!";
}
header.h
#ifndef _HEADER_H
#define _HEADER_H
class Something {
public:
printContents();
};
#endif
something.cpp
#include "header.h"
#include <iostream>
Something::printContents() {
cout << "This class's Contents!!";
}
What's happening is that I get a compiler error going: multiple definitions of some standard C function, such as strtod.
g++ -o ... main.o
build/....main.o: In function `strtod':../MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdlib.h:318: multiple definition of `strtod'
build/..something.o:...something.cpp:(.text+0x0): first defined here collect2: ld returned 1 exit status
If I get rid of #include in one of the two occasions and get rid of the couts, it will compile. What the hell? I'm using g++ and NetBeans to compile.
I tried in the command line: g++ *.h *.cpp -o program
and the same thing happened.
Thanks!