Undefined reference with namespace, can you help me ?

I'm creating an app which need the creation of a namespace, but I've a beautiful undefined reference at the first compilation when I'm using this namespace in my main file. But if I re-compile the code, the undefined reference disappear. So, can you explain me what is the problem ?

My code is similar to :

Header file :
<namespace setFile
{
void aide();
void ecouteArguments(int nbArg, char **tabArg);
}>

Source file :
<namespace setFile
{
void aide()
{
std::cout << "================MISE EN FORME DES FICHIERS================" << std::endl;
}

void ecouteArguments(int nbArg, char **tabArg)
{
//Some code
}
}>

Main file :
<void aide()
{
std::cout << "================AIDE GENERALE================" << std::endl;
}

void ecouteArguments(int nbArg, char **tabArg)
{
//Some code
}

int main(int argc, char **argv)
{
if(strcmp(argv[1], "-auto") == 0)
std::cout << "Les antibiotiques, c'est pas automatique." << std::endl;
else
ecouteArguments(argc, argv);

return 0;
}>

And my error is :
<g++ -o main.exe main.o -LLibrairie/SSQLite/lib -lSSQLite
main.o: In function 'Z15ecouteArgumentsiPPc' :
Source/main.cpp:21: undefined reference to 'setFile::aide()'
Source/main.cpp:24: undefined reference to 'setFile::ecouteArguments(int, char**)'>

All help is welcome, thanks to have read all my message and sorry for my bad English !
First: Code tags make code posts more readable. See: http://www.cplusplus.com/articles/jEywvCM9/

Linker error. Namespaces are not the issue.

g++ -o main.exe main.o

You tell the linker to produce executable program (main.exe) from object file 'main.o' (and some libraries).

You should include the object file of the "source file" too:
g++ -o main.exe main.o sourcefile.o

Thank you a lot ! I missed this error :(
Registered users can post here. Sign in or register to post.