I am trying to compile the following program:
#include <iostream>
int main(){
std::cout << "Hello, world!";
return 0;
}
When I compile it, I get this message:
C:\programs>g++ test.cpp
Info: resolving std::cout by linking to __imp___ZSt4cout (auto-import)
c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe: warning: a
uto-importing has been activated without --enable-auto-import specified on the c
ommand line.
This should work unless it involves constant data structures referencing symbols
from auto-imported DLLs.
The build succeeds and the executable runs as expected, but this warning still irritates me. I expect a successful build to be completely silent. This message gives the false impression that there’s something wrong with my code.
I can silence this error with g++ -Xlinker --enable-auto-import test.cpp, but this is undesirable, as it triples the number of characters I need to type to compile a program.
Questions:
- Why does this warning appear for the simplest of programs? i don’t expect cryptic warnings when I compile Hello World.
- Is it possible to silence this warning without passing the flag to the linker every time? An option in a config file hidden somewhere in
c:\mingw, perhaps? Or maybe I missed an “automatically enable auto-import” checkbox during installation?
Possibly Relevant Specs
- GCC Version 4.5.0
- ld.exe Version 2.20.51.20100613
- Windows XP Service Pack 3
I did some reading and it looks like it might be related to the mingw32 dll not having dllimport attributes defined.
Perhaps there is a patch or you can rebuild mingw32 yourself and add them?