Author Topic: patch to get the correct mingw gcc include search paths  (Read 12742 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
patch to get the correct mingw gcc include search paths
« on: July 06, 2011, 04:45:59 pm »
Code
Index: nativeparser.cpp
===================================================================
--- nativeparser.cpp (revision 7280)
+++ nativeparser.cpp (working copy)
@@ -1060,7 +1060,7 @@
     // both works fine in Windows and linux
 
 #ifdef __WXMSW__
-    wxString Command = cpp_compiler + _T(" -v -E -x c++ -< nul");
+    wxString Command = _T("cmd /c \"") + cpp_compiler + _T(" -v -E -x c++ -< nul\"");
 #else
     wxString Command = cpp_compiler + _T(" -v -E -x c++ -< /dev/null");
 #endif

I found that if we use the old command, sometimes we will failed to correct the gcc include paths. e.g. with gcc4.6, it will failed to collect the include paths.
see below:
nativiparser.cpp, line 1079
when running the command:
Code
 if (wxExecute(Command, Output, Errors, wxEXEC_SYNC | wxEXEC_NODISABLE) == -1)
Quote
> output Errors
8 count of wxArrayString = {
 
  • = 0xb791a4 L"Using built-in specs.",
  • [1] = 0xb79214 L"COLLECT_GCC=E:\\code\\cb\\gcc\\MinGW_gcc4.6.1release_static_win32\\MinGW\\bin\\g++.exe",
      [2] = 0xb792e4 L"COLLECT_LTO_WRAPPER=e:/code/cb/gcc/mingw_gcc4.6.1release_static_win32/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.1/lto-wrapper.exe",
      [3] = 0xb79434 L"g++.exe: error: unrecognized option '-<'",
      [4] = 0xb794c4 L"Target: i686-pc-mingw32",
      [5] = 0xb7a014 L"Configured with: ./configure --prefix=/mingw --host=i686-pc-mingw32 --build=i686-pc-mingw32 --target=i686-pc-mingw32 --with-lto-plugin --with-host-libstdcxx=-lstdc++ --disable-bootstrap --disable-werror --with-arch=i686 --with-tune=generic --enable-languages=c,c++,fortran --enable-libgomp --enable-threads=win32 --enable-lto --with-system-zlib --enable-libstdcxx-debug --enable-version-specific-runtime-libs --enable-fully-dynamic-string --disable-sjlj-exceptions --with-dwarf2 --disable-symvers --enable-checking=release --enable-plugins --enable-cloog-backend=isl --enable-static --disable-shared --disable-nls --disable-win32-registry --with-pkgversion=pcx32",
      [6] = 0xb79f34 L"Thread model: win32",
      [7] = 0xb79534 L"gcc version 4.6.1 (pcx32) "
look, we will get failed on running this command on mingw gcc 4.6.1.

I have test this patch on both mingw gcc 4.5.x and gcc 4.6.1(pcx), both works fine.

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: patch to get the correct mingw gcc include search paths
« Reply #1 on: July 06, 2011, 05:21:22 pm »
Ollydbg: test also the "official" 4.4.x + older compilers 4.1 or something like that.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: patch to get the correct mingw gcc include search paths
« Reply #2 on: July 08, 2011, 06:39:43 am »
I 'm disposed to change to :
Code
wxString Command = cpp_compiler + _T(" -v -E -x c++ -dD nul");
This can avoid "-<" output error in wxWidgets, and the content to output is much more, which contains all pre-defined compiler macros, and that can be a better supplement of CC plugin. The CC plugin may use "-dD" to distinguish the value of these pre-defined compiler macros.
Regards,
xunxun

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: patch to get the correct mingw gcc include search paths
« Reply #3 on: July 08, 2011, 06:51:52 am »
what does "-<" means?
I can't find this option from: http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html

But I don't think -dD is need, because CC has another function to collect the predefined macros.
look at:
bool NativeParser::AddCompilerPredefinedMacros(cbProject* project, Parser* parser)
it use:
const wxString args(_T(" -dM -E -< nul")); under mingw.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: patch to get the correct mingw gcc include search paths
« Reply #4 on: July 08, 2011, 07:03:59 am »
add a ref:
http://forums.codeblocks.org/index.php/topic,10598.msg72620.html#msg72620
But there is no such "-<"?
Maybe, morten can say something about this. :D

Edit:
the command options list: (I can't find any usage of "-<")...
http://technet.microsoft.com/en-us/library/bb490982.aspx
« Last Edit: July 08, 2011, 07:07:20 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: patch to get the correct mingw gcc include search paths
« Reply #5 on: July 08, 2011, 07:15:44 am »
what does "-<" means?
I can't find this option from: http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html

But I don't think -dD is need, because CC has another function to collect the predefined macros.
look at:
bool NativeParser::AddCompilerPredefinedMacros(cbProject* project, Parser* parser)
it use:
const wxString args(_T(" -dM -E -< nul")); under mingw.

Yes, I know that. But "-< nul" has something error in wx. This also uses wxExecute:
Code
wxExecute(cpp_compiler + args, output, wxEXEC_SYNC | wxEXEC_NODISABLE) == -1

"-dM -E -< nul" may have some errors in some compiler (including my gcc 4.6.1).
So I suggest all avoid "-<".
Regards,
xunxun

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: patch to get the correct mingw gcc include search paths
« Reply #6 on: July 08, 2011, 07:24:02 am »
So I suggest all avoid "-<".
Or we should report this error to wx.
Regards,
xunxun

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: patch to get the correct mingw gcc include search paths
« Reply #7 on: July 08, 2011, 10:11:36 am »
Try this patch?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: patch to get the correct mingw gcc include search paths
« Reply #8 on: July 08, 2011, 10:56:02 am »
Try this patch?
Test on mingw 4.6.x and 4.5.x, both work fine!
No time to test other mingw version :D...
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: patch to get the correct mingw gcc include search paths
« Reply #9 on: July 08, 2011, 11:02:56 am »
Try this patch?
Test on mingw 4.6.x and 4.5.x, both work fine!
No time to test other mingw version :D...

I also test it, then my used editions work fine.
Regards,
xunxun