Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Michael on April 04, 2006, 09:07:18 pm

Title: Workaround to compile wxWidgets 2.6.3 with GCC 4.1.0 (MinGW)
Post by: Michael on April 04, 2006, 09:07:18 pm
Hello,

Until now, I and other wxWidgets's users could not build wxWidgets 2.6.3 with GCC 4.1.0 on Windows (MinGW). Some minutes ago, I got an interesting e-mail from wx-users@lists.wxwidgets.org with a possible workaround :D. I think it could be interesting for some users:

Quote
[...]
I also encountered this issue using my CygWin-hosted, MinGW-targetting build of the latest GCC 4.1 snapshot, when trying to build wxWidgets from CVS HEAD.

A little investigation revealed that, for some reason, the culprits are the implementations of virtual functions AddRef and Release, present in several of the interfaces used in src/msw/ole/activex.cpp.

Since I currently have no use for the ActiveX technology, my private workaround is to comment out (until a proper solution is found) the bodies of those two functions, like this:

Index: src/msw/ole/activex.cpp
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/src/msw/ole/activex.cpp,v
retrieving revision 1.21
diff --unified -r1.21 activex.cpp
--- src/msw/ole/activex.cpp     2006/03/23 10:11:05     1.21
+++ src/msw/ole/activex.cpp     2006/04/04 17:43:56
@@ -79,7 +79,7 @@
          ((IUnknown * )(*ppvObject))->AddRef();\
          return S_OK;\
      }\
-    ULONG STDMETHODCALLTYPE cls::AddRef()\
+    /*ULONG STDMETHODCALLTYPE cls::AddRef()\
      {\
          InterlockedIncrement(&refCount.l);\
          return refCount.l;\
@@ -98,7 +98,7 @@
          }\
          else\
              return 0;\
-    }\
+    }*/\
      ULONG STDMETHODCALLTYPE cls::AddLock()\
      {\
          InterlockedIncrement(&lockCount.l);\

This allows for the rest of the library files to compile.

Best regards.

--
Wlodek Szafran

Best wishes,
Michael
Title: Re: Workaround to compile wxWidgets 2.6.3 with GCC 4.1.0 (MinGW)
Post by: Michael on April 06, 2006, 04:52:14 pm
Hello,

After trying the workaround, I have discovered that it does not work as I wanted :(. The problem is that it works, but to compile wxWidgets 2.6.3 and not to build it. Commenting out the implementation of two functions in the activex.cpp file make the linker throws undefined reference exceptions :(.

I have tried some alternatives, but all failed. May be if C::B does make use of non-monolithic version, it could be possible (at list in theory) to just skip the activex stuff.

Moreoever, after some investigation, the author posted this message:

Quote
I've done some more digging and it turns out that this problem has nothing to do with ActiveX/COM or MinGW directly.  It seems that in a multiple inheritance situation, when the virtual functions have the attribute __stdcall__ applied, the compiler is improperly generating the vtable.   I've put together a small program which doesn't know anything about wxWidgets or ActiveX or Win API, in which I can reproduce this erroneous behaviour.  One of these days, time permitting, I'm going to submit a problem report to the GCC developers.

The problem seems related to the compiler and not to ActiveX/COM or MinGW (not directly at least). If there was just a solution to get rid of activex...

Sorry for the false hope :oops:. I will correct the title from "to build" into "to compile".

Best wishes,
Michael
Title: Re: Workaround to compile wxWidgets 2.6.3 with GCC 4.1.0 (MinGW)
Post by: David Perfors on April 07, 2006, 09:43:24 am
Did you try it with the patch? http://wxwidgets.org/patch.htm#patches263 (http://wxwidgets.org/patch.htm#patches263)
Title: Re: Workaround to compile wxWidgets 2.6.3 with GCC 4.1.0 (MinGW)
Post by: Michael on April 07, 2006, 10:39:44 am
Did you try it with the patch? http://wxwidgets.org/patch.htm#patches263 (http://wxwidgets.org/patch.htm#patches263)

Yes. I have tried even with the latest CVS wxWidgets. The problem seems to be compiler-specific. I just wonder if a cross-compiling in Linux could work...

Best wishes,
Michael
Title: Re: Workaround to compile wxWidgets 2.6.3 with GCC 4.1.0 (MinGW)
Post by: Tactive on April 19, 2006, 02:03:25 pm
Hello,

I would like to know where you got the GCC 4.1.0 from? Actually candidate for GCC of the MinGW project is 3.4.x as I can see on the homepage. Did you compile GCC yourself?

- Tactive
Title: Re: Workaround to compile wxWidgets 2.6.3 with GCC 4.1.0 (MinGW)
Post by: Michael on April 19, 2006, 03:32:49 pm
I would like to know where you got the GCC 4.1.0 from? Actually candidate for GCC of the MinGW project is 3.4.x as I can see on the homepage. Did you compile GCC yourself?

I got it from here (http://forums.codeblocks.org/index.php?topic=2499.0). Look at Ceniza's signature :).

Best wishes,
Michael
Title: Re: Workaround to compile wxWidgets 2.6.3 with GCC 4.1.0 (MinGW)
Post by: Michael on July 03, 2006, 04:36:36 pm
Hello,

I just got this message (http://wxforum.shadonet.com/viewtopic.php?p=40684#40684) from the wxWidgets forum:

Quote
My solution is to put "#if 0" at the top of src/msw/ole/activex.cpp, and "#endif" at the bottom.

Seriously, that's what I did. I compiled it and am using it. It works fine. Of course, I'm not using ActiveX or OLE.

I hope someone is working on it, but it won't affect me either way.

Hope it really works and that we can build wxWidgets 2.6.3 with GCC 4.1.1 :)

Best wishes,
Michael