Author Topic: QtHelper plugin  (Read 23736 times)

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
QtHelper plugin
« on: April 23, 2009, 01:42:26 pm »
I created a little plugin that helps me to build Qt projects as clean C++ projects in CodeBlocks IDE. Natively CodeBlocks doesn't support Qt projects - user must generate makefile with qmake manually and list of files and settings can't be automaticaly extracted from IDE.
This became possible because C::B:
  • allows read all available data of project, it's targets, it's compiler and etc
  • allows save data to xml-like C::B project file
  • allows using custom makefile
  • allows change "make" command line
  • allows add settings pane to environment settings dialog
  • allows add settings pane to project settings dialog
  • allows create scripted wizards to start project with appropriate configuration

Now I only want to discuss my ideas with community about how to make it better and share sources using this forum
In future if some people support me this plugin can become popular

Plugin's sources for today are attached to this message (qthelper.zip).
It better to use it with scripted wizard, that also attached (scripted_wizard.zip).

For newer versions see other messages of the topic.

To add these project types:
  • copy these folders to directory <C::B folser>/share/CodeBlocks/templates/wizard/
  • add 2 lines to function RegisterWizards() in file <C::B folser>/share/CodeBlocks/templates/wizard/config.script
    • RegisterWizard(wizProject,     _T("qt4"),          _T("QT4 static project"),           _T("GUI"));
    • RegisterWizard(wizProject,     _T("qt4dll"),       _T("QT4 dll project"),    _T("GUI"));

This plugin works great when you don't need specific features of QT project file, because it extracts the following data from C::B project file:
  • headers
  • paths to them - include paths
  • sources
  • libs
  • paths to them
  • compiler options - flags
  • linker options - flags
  • output directory
  • object files directory
  • output file name
  • and etc

It works like QtWorkbench, but not at all.
It saves additional data (some config that can't be extracted from C::B project file) to C::B project file for further use.
And qmake's pro-file is only intermediate file as well as moc's, uic's and rcc's files.
Qt's intermediate files are stored in objects directory (in subfolders of the same name)

Now project is moved to http://code.google.com/p/qthelper/, i.e. all latest sources and binaries can be found there.

[attachment deleted by admin]
« Last Edit: April 20, 2010, 01:00:40 pm by critic »

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #1 on: April 23, 2009, 02:15:47 pm »
Additional information: this plugin allows to build debug target of project using release versions of libraries (Qt libs, for example).

But in latest nightlies C::B developers closed access to project build settings for projects that use custom makefile.
That's why usage of plugin became complex.
I need some ideas about how to improve functionality of plugin.

Offline cb_gotcha

  • Single posting newcomer
  • *
  • Posts: 3
Re: QtHelper plugin
« Reply #2 on: May 26, 2009, 07:24:20 am »
tried to compile qthelper and installed CB source and wxwidget source. I a final error that reads "ld.exe    cannot find -lcodeblocks". Should there be a static library codeblocks? all I can find is codeblocks.dll in the main dir but I can't find how to link that properly. Also I see only that a dll is build, so how is a cbplugin generated?
thanks
« Last Edit: May 26, 2009, 07:38:32 am by cb_gotcha »

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #3 on: May 29, 2009, 05:41:12 am »
I build plugin on Windows XP using the following:
  • wxWidgets 2.8.7
  • mingw 3.4.5
  • Codeblocks sources (from SVN. note! get only revisions that goes as nightly build releases (nightly builds forum))

To build wxWidgets library on Windows I used batch-file. It's contents:

set PATH=%PATH%;d:\bin\dev\compile\mingw3\bin;d:\bin\dev\compile\mingw3\include;d:\bin\dev\compile\mingw3\lib
cd build\msw
mingw32-make.exe -f makefile.gcc UNICODE=1 BUILD=release SHARED=1 MONOLITHIC=1 VENDOR=cb
pause


It must be placed in root directory of wxWidgets and paths to mingw must be yours.

After building wxWidgets open QtHelper project in CodeBlocks IDE (you must create global variable 'wx' in C::B (Settings -> Global Variables):
  • bin: <your wxWidgets root directory>
  • include: $(#wx)/include
  • lib: $(#wx)/devel
) and build plugin

Note! To create .cbplugin file you need zip.exe in your PATH environment variable (in system or in C::B). For more information see post-build steps in plugin project

That's all.

I will attach soon new sources of plugin that are make it possible configure includes, lib paths, libs and other in Qt project without movements described in first post

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #4 on: May 29, 2009, 05:51:30 am »
Sorry!  :oops:
In global variable 'wx' lib section must be '$(#wx)/lib'.

In addition you must create 'cb' global variable:
  • base: <your C::B sources root directory (where located 'include' dir)>
  • include: $(#CB)/include
  • lib: $(#CB)/devel

About building of C::B library:
if build is successful in output directory must be at least 2 files:
  • codeblocks.dll
  • libcodeblocks.dll.a

Good luck!  :)

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #5 on: June 03, 2009, 01:25:00 pm »
I made all changes to plugin and it can be loaded from attaches to this message  :D
Use it for free

[attachment deleted by admin]

Offline cb_gotcha

  • Single posting newcomer
  • *
  • Posts: 3
Re: QtHelper plugin
« Reply #6 on: June 03, 2009, 04:34:31 pm »
hi, your new zip seems to be missing exchndl.cpp ... but it compiles without this file?

the interface is much better allowing adding of libs and search paths, nice. moc and ui generation work fine. I get an error when opening a new static project: cannot find qtcore in qt\lib. I guess it should be looking for this in qt\bin?

thanks sofar, very helpful
« Last Edit: June 03, 2009, 05:06:53 pm by cb_gotcha »

Offline cb_gotcha

  • Single posting newcomer
  • *
  • Posts: 3
Re: QtHelper plugin
« Reply #7 on: June 06, 2009, 07:14:52 am »
trying it out for a while and it works great. :D
 just reporting back for hat its worth. Until now I used Borland so I am still figuring things out.
I just noticed that when you generate a static project the libs qtgui and qtcore are default in the QtHelper link-libs screen, and also the qt/include; qt/include/gui and qt/include/core in the QtHelper search path screen. If you compile the project you have 4 libs by default:
debug: -lQtCore4 -lQtGui4 -lQtGuid4 -lQtCored4
release: lQtCore4 -lQtGui4 -lQtGui4 -lQtCore4
and the include paths are specified twice.
This doesn't seem topose any problems btw. when I remove the default stuff from the qthelper interface the standard libs and includes are linked anyway so it compiles fine in both release and debug. Been trying this for the simple Qt examples.

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #8 on: June 24, 2009, 09:45:16 am »
Hello  :D
I made some improvements in plugin:
  • deleted lines with test message boxes
  • editor of search paths and others with use of global variables now don't convert to absolute path
  • added message to build options page

New sources can be downloaded from attached files   :wink:
Enjoy and send me offers of how to improve it if any.

[attachment deleted by admin]

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #9 on: September 01, 2009, 08:55:42 am »
Soon I will add new settings page that will contain textedit for additional pro-file data (it will be appended to resulting pro-file after data that generated from C::B project file).
I think that this part can contain C::B variables (global, environment and others) and while generating pro-file they will be converted to corresponding value.

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #10 on: October 21, 2009, 05:21:46 am »
OK! You can find new sources in attached file

[attachment deleted by admin]

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #11 on: February 12, 2010, 09:07:27 am »
I found a bug in the plugin:

in settings dialog when project data modified (of the root item in targets tree) and after this selected some target (for example, debug or release - not a root item) and user clicks `OK` - configuration of this target replaces project's configuration.

I fixed this bug. Sources are attached to this message.

Good luck!  :)

[attachment deleted by admin]

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #12 on: February 12, 2010, 09:25:48 am »
And else one less critical bug: on changing only `Execution working dir` made changes don't saved. Sources are attached.



[attachment deleted by admin]

Offline chameleon

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: QtHelper plugin
« Reply #13 on: March 04, 2010, 07:25:58 pm »
Can you provide binary for windows?
Because I hate to install SDKs and dependencies.

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #14 on: March 11, 2010, 12:27:15 pm »
I modified sources of plugin (they are attached)

Changes are:
  • now sorting of lists in project settings is disabled (because some libs must be linked in specified order)
  • added spinbutton to move elements of lists up and down

I think about creation of project at sourceforge site to publish binaries for windows and linux (I use only ubuntu - binaries will be only for ubuntu). Soon I'll make it.  :D


[attachment deleted by admin]

Offline critic

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: QtHelper plugin
« Reply #15 on: April 20, 2010, 12:57:53 pm »
Ok! I created project on Google Code here: http://code.google.com/p/qthelper/.
You can obtain plugin sources and download binaries, but discussion is going on here.

Genkaku

  • Guest
Re: QtHelper plugin
« Reply #16 on: September 19, 2010, 03:28:42 pm »
I've came across upon numerous problems when trying to compile QTHelper plugin.

I'm on 64bit Linux.

I've opened the project, added directories, so that codeblocks' sdk.h and others could be found, pressed "build" and
Code
cc1plus: error: unrecognized command line option "-mthreads"
, so I've deleted the line
<Add option="-mthreads" />
from qthelper.cbp. Obviously gcc 4.4 doesn't support that. What that option was supposed to do?

but there I've found these lines:
Code
 <Option host_application="D:\bin\dev\c++\CodeBlocks\codeblocks.exe" />
<Add option="-DHAVE_W32API_H" />
<Add option="-D__WXMSW__" />
<Add option="-DWXUSINGDLL" />
<Add directory="$(#wx.lib)\gcc_dll\mswu" />
<Add library="wxmsw28u" />
<Add directory="$(#wx.lib)\gcc_dll" />

These (I do not know if all of these) look windows-specific.

I guess that I don't need
<Add option="-DHAVE_W32API_H" />
<Add option="-D__WXMSW__" />
<Add option="-DWXUSINGDLL" />
So I deleted them, that way getting rid of some compilation errors, but new showed up:
Code
In file included from /usr/include/wx/wxprec.h:13,
                 from /usr/include/codeblocks/sdk_common.h:34,
                 from /usr/include/codeblocks/sdk_precomp.h:13,
                 from /usr/include/codeblocks/sdk.h:17,
                 from /home/me/CodeBlocks_projects/qthelper/qthelper-read-only/QtCfgDlg.cpp:10:
/usr/include/wx/defs.h:42:13: error: #error "No Target! You should use wx-config program for compilation flags!"

defs.h, around line 42:
Code
#ifdef __cplusplus
/*  Make sure the environment is set correctly */
#   if defined(__WXMSW__) && defined(__X__)
#       error "Target can't be both X and Windows"
#   elif defined(__WXMSW__) && defined(__PALMOS__)
#       error "Target can't be both PalmOS and Windows"
#   elif !defined(__WXMOTIF__) && \
         !defined(__WXMSW__)   && \
         !defined(__WXPALMOS__)&& \
         !defined(__WXGTK__)   && \
         !defined(__WXPM__)    && \
         !defined(__WXMAC__)   && \
         !defined(__WXCOCOA__) && \
         !defined(__X__)       && \
         !defined(__WXMGL__)   && \
         !defined(__WXDFB__)   && \
         !defined(__WXX11__)   && \
          wxUSE_GUI
#       ifdef __UNIX__
#           error "No Target! You should use wx-config program for compilation flags!"
#       else /*  !Unix */
#           error "No Target! You should use supplied makefiles for compilation!"
#       endif /*  Unix/!Unix */
#   endif
#endif /*__cplusplus*/

Line
<Add option="-D__X__" />
in the project file helped, but:

Code
In file included from /usr/include/wx/debug.h:18,
                 from /usr/include/wx/defs.h:521,
                 from /usr/include/wx/wxprec.h:13,
                 from /usr/include/codeblocks/sdk_common.h:34,
                 from /usr/include/codeblocks/sdk_precomp.h:13,
                 from /usr/include/codeblocks/sdk.h:17,
                 from /home/me/CodeBlocks_projects/qthelper/qthelper-read-only/QtCfgDlg.cpp:10:
/usr/include/assert.h:39:42: error: missing binary operator before token "("
/usr/include/assert.h:105:42: error: missing binary operator before token "("
In file included from /usr/include/libio.h:62,
                 from /usr/include/stdio.h:75,
                 from /usr/include/wx/wxchar.h:21,
                 from /usr/include/wx/debug.h:22,
                 from /usr/include/wx/defs.h:521,
                 from /usr/include/wx/wxprec.h:13,
                 from /usr/include/codeblocks/sdk_common.h:34,
                 from /usr/include/codeblocks/sdk_precomp.h:13,
                 from /usr/include/codeblocks/sdk.h:17,
                 from /home/me/CodeBlocks_projects/qthelper/qthelper-read-only/QtCfgDlg.cpp:10:
/usr/include/sys/cdefs.h:46:44: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:50:44: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:135:19: error: missing binary operator before token "("

At this point, I don't have a clue what to do.
Any suggestions?