multiple source files, header, global variable not working

Hi,
I'm trying to write some code while having a global variable shared in all my source files. compiler is not happy about something. If i run it it gives me this error
PasswordAdjust.h.gch: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status


//main.cpp

#include <iostream>
#include "PasswordAdjust.h"

using namespace std;



int main()
{
extern int password;

cout<<password<<endl;

return 0;
}

--------------------------------------------

//password.cpp

#include <iostream>
#include "PasswordAdjust.h"

using namespace std;


int password = 100;

----------------------------------------------

//PasswordAdjust.h

#ifndef PASSWORDADJUST_H_INCLUDED
#define PASSWORDADJUST_H_INCLUDED


extern int password;


#endif // PASSWORDADJUST_H_INCLUDED
Try removing the .gch (precompiled header) file and see if that works.
I did but when i compile the project it creates one automatically.
Maybe I'm missing something very basic.

I'm using codeblocks.
I checked some guides and after a bit i fixed password.cpp:
now if i go >projects>password.cpp>properties>build: debug and release are ticked

Still not working.
started from zero, copied code from here and pasted it on new files.
now it works but i dunno why.
maybe some settings in codeblocks that were not correct before
Topic archived. No new replies allowed.