From: Martin F. <mar...@gm...> - 2004-05-17 13:04:01
|
Hi, I've got some problems using the new GCC 3.4 feature of precompiled = headers with C++ programs. This is what the manual page says: > To create a precompiled header file, simply compile it as you would = any other > file, if necessary using the -x option to make the driver treat it as = a C or C++ > header file. So far so good. Now here is my little test case: -- file gchtest.h --- #include <iostream> -- file gchtest.cpp --- #include "gchtest.h" using namespace std; int main() { cout << "Hello GCH !\n"; return 0; } The Makefile for this simple test case would be something like this: gchtest.exe: gchtest.h.gch gchtest.cpp g++ gchtest.cpp -o $@ gchtest.h.gch: gchtest.h g++ gchtest.h But I didn't find a way to get it working. Trying to generate the GCH file using g++ results in this error (This works flawless in a native Linux build environment.): ...\gchtest>g++ gchtest.h gchtest.h:2: fatal error: can't read = E:\DOCUME~1\Martin\LOCALS~1\Temp/ccYPaaaa.s : No such file or directory compilation terminated. Trying to generate the GCH file using gcc results in this error: ...\gchtest>gcc gchtest.h gchtest.h:1:20: iostream: No such file or directory This one is OK, since "iostream" is a C++ header file. Trying to generate the GCH file using gcc with option "x c++" results in = linker errors: ...\gchtest>gcc gchtest.h gchtest.h:1:20: iostream: No such file or directory D:\src\examples\gchtest>gcc -x c++ gchtest.h E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0xd):gchtest.h: = undefined reference to `std::string::size() const' E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0x60):gchtest.h: = undefined reference to `std::string::operator[](unsigned) const' E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0x9f):gchtest.h: = undefined reference to `std::string::operator[](unsigned) const' E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0xce):gchtest.h: = undefined reference to `std::string::operator[](unsigned) const' E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0x11d):gchtest.h: = undefined reference to `std::ios_base::Init::Init()' E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0x138):gchtest.h: = undefined reference to `std::ios_base::Init::~Init()' E:/MinGW/bin/../lib/gcc/mingw32/3.4.0/../../../libmingw32.a(main.o)(.text= +0x97): main.c: undefined reference to `WinMain@16' collect2: ld returned 1 exit status It seems gcc treats the header file "gchtest.h" as a C++ file, compiles = it, and automatically invokes the linker instead of generating the = precompiled header file! I tried one more variation of command line arguments: ...\gchtest>gcc -x c++ -c gchtest.h This one doesn't print an error message, but it generates an object file = "gchtest.o" instead of the "gchtest.h.gch" file. So there seems to be a bug in the MinGW g++ frontent regarding = precompiled header support. Can anyone confirm this or even fix the = problem? Regards, Martin |
From: Michael B. <mic...@gm...> - 2004-05-17 15:26:38
|
Martin Fuchs wrote: >Hi, > >I've got some problems using the new GCC 3.4 feature of precompiled headers with C++ programs. > >This is what the manual page says: > > > >>To create a precompiled header file, simply compile it as you would any other >>file, if necessary using the -x option to make the driver treat it as a C or C++ >>header file. >> >> > >So far so good. Now here is my little test case: > > >-- file gchtest.h --- > >#include <iostream> > > >-- file gchtest.cpp --- > >#include "gchtest.h" > >using namespace std; > >int main() >{ > cout << "Hello GCH !\n"; > > return 0; >} > > >The Makefile for this simple test case would be something like this: > >gchtest.exe: gchtest.h.gch gchtest.cpp > g++ gchtest.cpp -o $@ > >gchtest.h.gch: gchtest.h > g++ gchtest.h > >But I didn't find a way to get it working. > > >Trying to generate the GCH file using g++ results in this error >(This works flawless in a native Linux build environment.): > >...\gchtest>g++ gchtest.h >gchtest.h:2: fatal error: can't read E:\DOCUME~1\Martin\LOCALS~1\Temp/ccYPaaaa.s >: No such file or directory >compilation terminated. > > >Trying to generate the GCH file using gcc results in this error: > >...\gchtest>gcc gchtest.h >gchtest.h:1:20: iostream: No such file or directory > >This one is OK, since "iostream" is a C++ header file. > > >Trying to generate the GCH file using gcc with option "x c++" results in linker errors: > >...\gchtest>gcc gchtest.h >gchtest.h:1:20: iostream: No such file or directory > >D:\src\examples\gchtest>gcc -x c++ gchtest.h >E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0xd):gchtest.h: undefined reference to `std::string::size() const' >E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0x60):gchtest.h: undefined reference to `std::string::operator[](unsigned) const' >E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0x9f):gchtest.h: undefined reference to `std::string::operator[](unsigned) const' >E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0xce):gchtest.h: undefined reference to `std::string::operator[](unsigned) const' >E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0x11d):gchtest.h: undefined reference to `std::ios_base::Init::Init()' >E:\DOCUME~1\Martin\LOCALS~1\Temp/cc08baaa.o(.text+0x138):gchtest.h: undefined reference to `std::ios_base::Init::~Init()' >E:/MinGW/bin/../lib/gcc/mingw32/3.4.0/../../../libmingw32.a(main.o)(.text+0x97): >main.c: undefined reference to `WinMain@16' >collect2: ld returned 1 exit status > > >It seems gcc treats the header file "gchtest.h" as a C++ file, compiles it, and automatically invokes the linker instead of generating the precompiled header file! > > >I tried one more variation of command line arguments: > >...\gchtest>gcc -x c++ -c gchtest.h > >This one doesn't print an error message, but it generates an object file "gchtest.o" instead of the "gchtest.h.gch" file. > > >So there seems to be a bug in the MinGW g++ frontent regarding precompiled header support. Can anyone confirm this or even fix the problem? > > >Regards, > > Martin > > >------------------------------------------------------- >This SF.Net email is sponsored by: SourceForge.net Broadband >Sign-up now for SourceForge Broadband and get the fastest >6.0/768 connection for only $19.95/mo for the first 3 months! >http://ads.osdn.com/?ad_id%62&alloc_ida84&op=click >_______________________________________________ >MinGW-users mailing list >Min...@li... > >You may change your MinGW Account Options or unsubscribe at: >https://lists.sourceforge.net/lists/listinfo/mingw-users > > > > Hi, This is wat the relaese notes say: Also please note that precompiled headers do not work on mingw32. regards Michael. |