Author Topic: Trying to build callswizard plug-in (help needed, got stuck)  (Read 9459 times)

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Trying to build callswizard plug-in (help needed, got stuck)
« on: October 29, 2005, 12:51:38 pm »
While struggling on my own plug-ins I got the bright idea to see how the pro's are doing it.
So I was looking at the source code of the classwizard (build in) plug-in.
I created a cbp for it and started compiling. So far, so good.
I replace my dll, which seems to be 150 KB instead of 300KB : starting to be smelly ..., for the original one.
Start cb, choose the plug-in, getting the GUI part. BUT at that point everything is frozen.

The problem has to be in my cbp file, some compiler/linker switches missing ?

Who can help me out, and tell me what's wrong and what's needed.

This is my hand-made cbp file :
<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_project_file>
<CodeBlocks_project_file>
   <FileVersion major="1" minor="1"/>
   <Project>
      <Option title="classwizard"/>
      <Option makefile="Makefile"/>
      <Option makefile_is_custom="0"/>
      <Option compiler="0"/>
      <Build>
         <Target title="default">
            <Option output="classwizard.dll"/>
            <Option working_dir="."/>
            <Option object_output=".objs"/>
            <Option deps_output=".deps"/>
            <Option type="3"/>
            <Option compiler="0"/>
         </Target>
         <Environment>
            <Variable name="WX_VER" value="26"/>
            <Variable name="WX_DIR" value="C:\wxWidgets-2.6.1"/>
            <Variable name="WX_CFG" value="NonUnicode"/>
            <Variable name="CB_SDK" value="C:\Program Files\CodeBlocks"/>
         </Environment>
      </Build>
      <Compiler>
         <Add option="-Wall"/>
         <Add option="-D__GNUWIN32__"/>
         <Add option="-DWXUSINGDLL"/>
         <Add option="-DBUILDING_PLUGIN"/>
         <Add directory="$(WX_DIR)\include"/>
         <Add directory="$(WX_DIR)\lib\gcc_dll\msw"/>
         <Add directory="$(WX_DIR)\lib\gcc_dll$(WX_CFG)\msw"/>
         <Add directory="$(WX_DIR)\contrib\include"/>
         <Add directory="$(CB_SDK)\include"/>
         <Add directory="$(CB_SDK)\sdk\include"/>
         <Add directory="$(CB_SDK)\sdk\include\wxscintilla\include"/>
      </Compiler>
      <Linker>
         <Add library="wxmsw$(WX_VER)"/>
         <Add library="codeblocks"/>
         <Add directory="$(CB_SDK)\sdk\lib"/>
      </Linker>
      <Unit filename="classwizard.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="classwizard.h">
         <Option compilerVar=""/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="classwizarddlg.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="classwizarddlg.h">
         <Option compilerVar=""/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
   </Project>
</CodeBlocks_project_file>


I saw in some other projects stuff like this, but don't know what it means.
         <Add option="-Winvalid-pch"/>
         <Add option="-mthreads"/>
         <Add option="-include &quot;sdk.h&quot;"/>
         <Add option="-DCB_PRECOMP"/>
         <Add option="-DWX_PRECOMP"/>
         <Add option="-DHAVE_W32API_H"/>
         <Add option="-D__WXMSW__"/>
         <Add option="-DcbDEBUG"/>
         <Add option="-DTIXML_USE_STL"/>


I gues, the pch and PRECOMP have to do with precompiled headers (bah)
I link against the wx lib provied in the cb-sdk. And to get the setup.h of wx I builded wx 2.6.1.

Many thanks,
Lieven

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #1 on: October 29, 2005, 01:07:43 pm »
Hand-made? Heaven! Don't do that :lol:
Never do something by hand at the risk of messing up things if a program does it for you in a safe, reliable way, anyway :)

Use the plugin wizard, so you get a complete, reliably working .cbp file. Plugins made with the plugin wizard work.
Or, at your option, copy the file from the original plugin, remove the sources and add your own sources.

What must be in your project is "build as dll" under Targets-->Options (obviously), at least the following compiler flags : __GNUWIN32__ WXUSINGDLL BUILDING_PLUGIN, and the link libraries wxmsw26 and codeblocks.

Also, you should absolutely make sure that you...

either compile your own wxWidgets and compile your own Code::Blocks to use the plugin

or build your plugin for use with "official" RC2 -- in that case you must use the link library that comes with the SDK.

A plugin linked against your selfmade wxmsw26 and used with RC2 will crash as soon as the plugin is loaded. Every time.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: Trying to build cllaswizard plug-in (help needed, got stuck)
« Reply #2 on: October 29, 2005, 01:42:01 pm »
Well actually it was indeed a semi hand made. The cbp file was the result of the plug-in wizard and replaced the sources/units.
And I do link with the wx lib from the sdk (RC2), as you can see in the pasted cbp content. In the linker section I have even removed the dir directives to the wx directory, so I won't use the 'self compiled wx'. The only links left to the self made wx is the include paths for the compiler ('wx' headers and that setup.h).

I build the stuff on windows XP SP2.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #3 on: October 29, 2005, 05:58:33 pm »
killerbot

You're not alone. I'm having the same problem. C::B RC2 can
recompile the distributed RC2 plugins but I have not been
able to get any of them to run once re-compiled. They
hang C::B.

I was able to get them to run when I re-built Codeblocks from
source. But that makes my C::B something like "myRC2". Not the
distributed version.

I wanted to modify pluginwizard source, then walk the code to
learn both C::B plugins and wxWidgets. But so far I've
been unsuccessful.

But.. unfortunately, I'm glad to see I'm not alone in the
universe here...

thanks for the info
Pecan

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #4 on: October 29, 2005, 07:15:23 pm »
I've had problems rebuilding codeblocks on my own. If I rebuild codeblocks and try to run (while using the distributed wxwidgets lib) things get awry. May be the compiler version, the wxwidgets version, a minor flag compiling wxwidgets, a minor flag compiling a library or plugin... or the setup.h. I really don't know.

Edit: This was a while ago, haven't tried with RC2.

So, this makes me wonder if the SDK distribution is sufficient for rebuilding a plugin...

Anyway, while if this problem is not solved, just try downloading the full Codeblocks sourcecode.

« Last Edit: October 29, 2005, 08:01:57 pm by rickg22 »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: Trying to build classwizard plug-in (help needed, got stuck)
« Reply #5 on: October 29, 2005, 08:00:46 pm »
So it seems that more of us are running into problems.
Let's hope Yiannis can shed some light on this issue.

From my experiments it has to do with wxWidgets.
And most probably the moment you are using dialogs.

Since my MatchinBrace plug-in still works (recompiled and a minor change in the code), the only thing it does wrt wx , is adding some menu entries and talking with scintilla objects.

In my other plug-in for ClearCase everything works fine, untill I added my first dialog. There all my problems started. Because I was not sure if I did everythingcorrectly, I decided to rebuild a core plug-in(class wizard). And the problems remain.

Now for using a library, you need header files (downloaded from wxWidgets : 2.6.1), so I guess these are OK, and import library.
Now some areas where the problem can be originating from :
 - the headers being included are behaving differently by lack of, or by having extra, preprocessor defines
 - different setup.h (which contains eg version strings for wx : this file is the result of building wx !!!)

On the subject of what (sh)(c)ould be belonging to the sdk : import libraries for the used dll's in cb, for sure setup.h !!!
And maybe a little note telling which preprocessor defines should be issued/provided.

Hope we crack this issue soon  :wink:

Lieven

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #6 on: October 29, 2005, 08:55:29 pm »
One possible thing to check is that you 're not having other wx DLLs lying around in the system paths (e.g. in \windows\system32). The point is that the same wx DLL must be used by the app *and* the plugins.

Because you 're having problems when adding a dialog, this indicates trouble with the message (modal) loop. This can be caused by a plugin linked statically to wx or using the wrong wx DLL...

This is the reason C::B only works with wx as a DLL and not as a static lib. It needs to have *only* one main message loop.

I 'll repeat this here once again:
In a "clean" machine (i.e. nothing programming-related installed) everything works as expected.
In my development machine, everything works as expected (obviously :P).

If you 're having trouble, start by deleting every wx DLL you have lying around, except wxmsw26_gcc_cb.dll in codeblocks folder...

Use these options (not all are needed, but I 'm giving the exact same options I use):
Code: [Select]
Compiler:

-Wall
-g
-pipe
-mthreads
-fmessage-length=0
-fexceptions
-DHAVE_W32API_H
-D__WXMSW__
-DWXUSINGDLL
-DcbDEBUG
-DTIXML_USE_STL
-DBUILDING_PLUGIN

Libs:

libcodeblocks.a
libwxscintilla.a
libwxmsw26.a

As far as wx/setup.h is concerned I haven't edited it.
« Last Edit: October 29, 2005, 08:57:15 pm by mandrav »
Be patient!
This bug will be fixed soon...

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #7 on: October 29, 2005, 11:31:26 pm »
killerbot

I applied the patches for wxWidgets 2.6.1 Now all is working well.
I also re-compiled ClassWizard, and it also works fine with
the patches.

wxWidgets Patches
Patches for 2.6.1. Various wxMSW fixes. This patch fixes the following problems
... Please download wxWidgets-2.6.1-Patch01.zip and unarchive from the top ...
www.wxwindows.org/patch.htm - 6k - Cached - Similar pages

ftp://biolpc22.york.ac.uk/pub/2.6.1/wxWidgets-2.6.1-Patch01.zip

I noticed that some of the headers (window.h etc) are used
all over the place.

Thanks
Pecan
« Last Edit: October 29, 2005, 11:38:38 pm by Pecan »

Offline Zlika

  • Plugin developer
  • Multiple posting newcomer
  • ****
  • Posts: 59
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #8 on: October 30, 2005, 09:25:06 am »
Great news! I'll test it quickly.
You should update the wiki ("Compiling wxWidgets 2.6.1 to develop Code::Blocks" tutorial) with this critical information!

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5193
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #9 on: October 30, 2005, 10:40:02 am »
Pecan,

Excellent, I am able to build the class wizard AND have it running without crashing.
Many thanks for your solution !!!

I am glad to know that I did not screw up with import lib's and dll's, I was very sure I was doing that part correctly.

Since during the build of plug-in dll, the only references to wx are the header files, the problem should be in one of those.
The patch contains new versions of :
.cpp (should be of no importance to our issue) :
  window.cpp
  tbar95.cpp
  splitter.cpp
  notebook.cp
  helpchm.cpp
  grid.cpp

.h (the problem was probably in here)
  listbox.h                 (2 changes, from which 1 code change)
  notebook.h            (seems to be unchanged)
  uxthemep.h           (1 change / different include)
  window.h              (2 changes, from which 1 code change)

The generated setup.h is identical.


Just an idea :
Maybe we could have some people testing the sdk part of the delivery, a test suite could be : compile all build-in plug-ins by using the sdk. We do need for every plug-in then a cbp project file, preferably as minimal as possible.
So compiler switches and include paths which are not needed should be out of the cbp. This way thinks become more clearer, and one get's more focus on the thing that do matter.
You can count me in for such a testing group.

And indeed the wiki needs to be updated to contain this kind of information. Do note, that the wiki entry is going all te hawy, even building cb, and then maybe the problems won't happen, since then everything is really using the same sources, dunno ??


Change for window.h : added
    // some controls (e.g. wxListBox) need to set the return value themselves
    //
    // return true to let parent handle it if we don't, false otherwise
    virtual bool MSWShouldPropagatePrintChild()
    {
        return true;
    }

Change for uxtheme.h :
#include <commctrl.h>   
  becomes
#include "wx/msw/wrapcctl.h"

Change for listbox.h : added
    // under XP when using "transition effect for menus and tooltips" if we
    // return true for WM_PRINTCLIENT here then it causes noticable slowdown
    virtual bool MSWShouldPropagatePrintChild()
    {
        return false;
    }


What do the core developers think of this, ensuring to get an ever better usable sdk ?

kind regards,
Lieven
« Last Edit: October 30, 2005, 10:46:42 am by killerbot »

Offline Zlika

  • Plugin developer
  • Multiple posting newcomer
  • ****
  • Posts: 59
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #10 on: October 30, 2005, 11:13:43 am »
It works! I can now compile my plugins!!
We must add this info in the wiki or people will spend hours to find out what is the problem!

Zlika

Offline artoj

  • Almost regular
  • **
  • Posts: 206
  • Location: Supporting my team
    • http://ajonsson.kapsi.fi/
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #11 on: October 30, 2005, 12:17:15 pm »
Could someone provide a mirror for the patch or attach it to this topic because the download link appears to be dead.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Zlika

  • Plugin developer
  • Multiple posting newcomer
  • ****
  • Posts: 59
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #13 on: October 30, 2005, 12:58:50 pm »
The link is not dead. Check that your firewall doesn't block FTP access from your web browser...

Offline artoj

  • Almost regular
  • **
  • Posts: 206
  • Location: Supporting my team
    • http://ajonsson.kapsi.fi/
Re: Trying to build callswizard plug-in (help needed, got stuck)
« Reply #14 on: October 30, 2005, 01:20:16 pm »
Ok, it works now.