auto-import DLL's

I'm getting a strange warning that I don't understand and was hoping someone could explain it to me. Here is an example that illustrates this behavior.

Foo.h
1
2
3
4
5
6
7
8
9
10
11
12
#ifndef FOO_H_
#define FOO_H_

class Foo
{
public:
  static const char* const NAMES [];
  Foo ();
  ~Foo ();
};

#endif /* FOO_H_ */ 


Foo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "foo.h"

const char* const  Foo::NAMES [] =
  {
    "Hello", "World"
  };

Foo::Foo ()
{

}

Foo::~Foo ()
{

}


main.cpp
1
2
3
4
5
6
7
8
#include <iostream.h>
#include "foo.h"

int main ()
{
  cout << "Foo::NAMES[1]: " << Foo::NAMES[1] << endl;
  return 0;
}


I compile the Foo class to a library (DLL) like this:
1
2
g++ -Wall -Wno-deprecated -c foo.cpp -o foo.o
g++ -shared -o foo.dll foo.o


Then I compile main.cpp and link it to the DLL produced above like this:
 
g++ -Wall -Wno-deprecated main.cpp -o main -L. -lfoo


The program compiles and runs as expected, but g++ gives me the following warning:
c:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.


My question/issue: What does this mean and how can I fix (not ignore) this warning? If I compile foo.cpp with main.cpp to produce main.exe, I don't get the warning. Meaning, if I do this, the warning is not there:
 
g++ -Wall -Wno-deprecated foo.cpp main.cpp -o main


That's besides the point, because I need to link to a DLL in the larger scope of my application. Any ideas?

Thanks everyone!
Topic archived. No new replies allowed.