i can't reproduce this with a minimal example...
if i create a project with the following files:
a.cpp
#include "a.h"
const int test[5] = {42,43,44,45,46};
a.h
extern const int test[5];
main.cpp:
#include <iostream>
#include "a.h"
using namespace std;
int main()
{
cout << "Hello world!" << endl;
cout << test[3] << endl;
return 0;
}
compiling (i made the main.cpp compiling weight lower, so it gets compiled earlier, like in your project:
[ 33.3%] mingw32-g++.exe -Wall -fexceptions -g -std=gnu++11 -Wno-unused-local-typedefs -Wno-deprecated-declarations -c ###\main.cpp -o obj\Debug\main.o
[ 66.7%] mingw32-g++.exe -Wall -fexceptions -g -std=gnu++11 -Wno-unused-local-typedefs -Wno-deprecated-declarations -c ###\fghhh\a.cpp -o obj\Debug\a.o
[100.0%] mingw32-g++.exe -o bin\Debug\fghhh.exe obj\Debug\main.o obj\Debug\a.o
Output file is bin\Debug\fghhh.exe with size 1.01 MB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:
all fine,
also your coding style is ok (http://stackoverflow.com/questions/1433204/how-do-i-use-extern-to-share-variables-between-source-files-in-c)
so there has to be something else...
can you try to replicate this with a minimal example?
greetings