Author Topic: Can't compile a simple helloworld plugin  (Read 7608 times)

Offline WillyCat

  • Single posting newcomer
  • *
  • Posts: 5
Can't compile a simple helloworld plugin
« on: May 20, 2012, 12:52:27 pm »
Hi,

I use the latest Code::Blocks svn build. I installed it via the Jens packages for Debian Squeeze.

I began my interest of creating a plugin. So, i created a plugin project via the project wizard. And during the compile stage, errors appear:

usr/include/codeblocks/globals.h:192: erreur: variable or field ‘SaveTreeState’ declared void
/usr/include/codeblocks/globals.h:192: erreur: ‘wxTreeCtrl’ was not declared in this scope
/usr/include/codeblocks/globals.h:192: erreur: ‘tree’ was not declared in this scope
/usr/include/codeblocks/globals.h:192: erreur: expected primary-expression before ‘const’
/usr/include/codeblocks/globals.h:192: erreur: expected primary-expression before ‘&’ token
/usr/include/codeblocks/globals.h:192: erreur: ‘nodePaths’ was not declared in this scope
/usr/include/codeblocks/globals.h:192: erreur: expected primary-expression before ‘&’ token
/usr/include/codeblocks/globals.h:192: erreur: ‘selectedItemPaths’ was not declared in this scope
/usr/include/codeblocks/globals.h:193: erreur: variable or field ‘RestoreTreeState’ declared void
/usr/include/codeblocks/globals.h:193: erreur: ‘wxTreeCtrl’ was not declared in this scope
/usr/include/codeblocks/globals.h:193: erreur: ‘tree’ was not declared in this scope
/usr/include/codeblocks/globals.h:193: erreur: expected primary-expression before ‘const’
/usr/include/codeblocks/globals.h:193: erreur: expected primary-expression before ‘&’ token
/usr/include/codeblocks/globals.h:193: erreur: ‘nodePaths’ was not declared in this scope
/usr/include/codeblocks/globals.h:193: erreur: expected primary-expression before ‘&’ token
/usr/include/codeblocks/globals.h:193: erreur: ‘selectedItemPaths’ was not declared in this scope
/usr/include/codeblocks/globals.h:197: attention : ‘ChooseDirectory’ initialized and declared ‘extern’
/usr/include/codeblocks/globals.h:197: erreur: ‘wxWindow’ was not declared in this scope
/usr/include/codeblocks/globals.h:197: erreur: ‘parent’ was not declared in this scope
/usr/include/codeblocks/globals.h:198: erreur: expected primary-expression before ‘const’
/usr/include/codeblocks/globals.h:199: erreur: expected primary-expression before ‘const’
/usr/include/codeblocks/globals.h:200: erreur: expected primary-expression before ‘const’
/usr/include/codeblocks/globals.h:201: erreur: expected primary-expression before ‘bool’
/usr/include/codeblocks/globals.h:202: erreur: expected primary-expression before ‘bool’

can someone tell me where the problem is ?

Thanks,

Willy.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9603
Re: Can't compile a simple helloworld plugin
« Reply #1 on: May 20, 2012, 02:15:21 pm »
can someone tell me where the problem is ?
First of all, please post the full build log, not only snippets. You should have read the forums rules in the beginning to avoid such mistakes in the first place.

Besides I believe you wxWidgets installation / setup is most likely wrong, maybe you missed to install the wxWidgets dev package. I could tell better, if you provide the full build log. :P

Please also note this:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29

This should give you enough help to fix it yourself.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline WillyCat

  • Single posting newcomer
  • *
  • Posts: 5
Re: Can't compile a simple helloworld plugin
« Reply #2 on: May 20, 2012, 03:02:57 pm »

First of all, please post the full build log, not only snippets. You should have read the forums rules in the beginning to avoid such mistakes in the first place.

Besides I believe you wxWidgets installation / setup is most likely wrong, maybe you missed to install the wxWidgets dev package. I could tell better, if you provide the full build log. :P


Sorry for the mistake.

Here is the complete build log:

Code: [Select]

-------------- Build: default in HelloWorld (compiler: GNU GCC Compiler)---------------

g++  -I/usr/include/codeblocks -I/usr/include/codeblocks/tinyxml -I/usr/include/codeblocks/scripting/include -I/usr/include/codeblocks/scripting/bindings -I/usr/include/codeblocks/scripting/sqplus -I/usr/include/codeblocks/wxscintilla/include    -I/usr/lib/wx/include/base-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DwxUSE_GUI=0 -pthread  -g     -c /home/willy/Projets/Développement/codeblocks/myplugins/HelloWorld/HelloWorld.cpp -o .objs/HelloWorld.o
In file included from /usr/include/codeblocks/configurationpanel.h:9,
                 from /home/willy/Projets/Développement/codeblocks/myplugins/HelloWorld/HelloWorld.cpp:2:
/usr/include/codeblocks/globals.h:192: erreur: variable or field ‘SaveTreeState’ declared void
/usr/include/codeblocks/globals.h:192: erreur: ‘wxTreeCtrl’ was not declared in this scope
/usr/include/codeblocks/globals.h:192: erreur: ‘tree’ was not declared in this scope
/usr/include/codeblocks/globals.h:192: erreur: expected primary-expression before ‘const’
/usr/include/codeblocks/globals.h:192: erreur: expected primary-expression before ‘&’ token
/usr/include/codeblocks/globals.h:192: erreur: ‘nodePaths’ was not declared in this scope
/usr/include/codeblocks/globals.h:192: erreur: expected primary-expression before ‘&’ token
/usr/include/codeblocks/globals.h:192: erreur: ‘selectedItemPaths’ was not declared in this scope
/usr/include/codeblocks/globals.h:193: erreur: variable or field ‘RestoreTreeState’ declared void
/usr/include/codeblocks/globals.h:193: erreur: ‘wxTreeCtrl’ was not declared in this scope
/usr/include/codeblocks/globals.h:193: erreur: ‘tree’ was not declared in this scope
/usr/include/codeblocks/globals.h:193: erreur: expected primary-expression before ‘const’
/usr/include/codeblocks/globals.h:193: erreur: expected primary-expression before ‘&’ token
/usr/include/codeblocks/globals.h:193: erreur: ‘nodePaths’ was not declared in this scope
/usr/include/codeblocks/globals.h:193: erreur: expected primary-expression before ‘&’ token
/usr/include/codeblocks/globals.h:193: erreur: ‘selectedItemPaths’ was not declared in this scope
/usr/include/codeblocks/globals.h:197: attention : ‘ChooseDirectory’ initialized and declared ‘extern’
/usr/include/codeblocks/globals.h:197: erreur: ‘wxWindow’ was not declared in this scope
/usr/include/codeblocks/globals.h:197: erreur: ‘parent’ was not declared in this scope
/usr/include/codeblocks/globals.h:198: erreur: expected primary-expression before ‘const’
/usr/include/codeblocks/globals.h:199: erreur: expected primary-expression before ‘const’
/usr/include/codeblocks/globals.h:200: erreur: expected primary-expression before ‘const’
/usr/include/codeblocks/globals.h:201: erreur: expected primary-expression before ‘bool’
/usr/include/codeblocks/globals.h:202: erreur: expected primary-expression before ‘bool’
/usr/include/codeblocks/globals.h: In function ‘wxBitmap LoadPNGWindows2000Hack(const wxString&)’:
/usr/include/codeblocks/globals.h:219: erreur: return type ‘struct wxBitmap’ is incomplete
/usr/include/codeblocks/globals.h:219: erreur: invalid use of incomplete type ‘struct wxBitmap’
/usr/include/wx-2.8/wx/gdicmn.h:30: erreur: forward declaration of ‘struct wxBitmap’
/usr/include/codeblocks/globals.h: At global scope:
/usr/include/codeblocks/globals.h:231: attention : ‘IsWindowReallyShown’ initialized and declared ‘extern’
/usr/include/codeblocks/globals.h:231: erreur: ‘wxWindow’ was not declared in this scope
/usr/include/codeblocks/globals.h:231: erreur: ‘win’ was not declared in this scope
/usr/include/codeblocks/globals.h:265: erreur: variable or field ‘PlaceWindow’ declared void
/usr/include/codeblocks/globals.h:265: erreur: ‘wxTopLevelWindow’ was not declared in this scope
/usr/include/codeblocks/globals.h:265: erreur: ‘w’ was not declared in this scope
/usr/include/codeblocks/globals.h:265: erreur: expected primary-expression before ‘mode’
/usr/include/codeblocks/globals.h:265: erreur: expected primary-expression before ‘bool’
In file included from /usr/include/wx-2.8/wx/window.h:23,
                 from /usr/include/wx-2.8/wx/toplevel.h:21,
                 from /usr/include/wx-2.8/wx/dialog.h:17,
                 from /usr/include/codeblocks/scrollingdialog.h:15,
                 from /usr/include/codeblocks/configurationpanel.h:11,
                 from /home/willy/Projets/Développement/codeblocks/myplugins/HelloWorld/HelloWorld.cpp:2:
/usr/include/wx-2.8/wx/cursor.h: In constructor ‘wxBusyCursorSuspender::wxBusyCursorSuspender()’:
/usr/include/wx-2.8/wx/cursor.h:65: erreur: ‘wxIsBusy’ was not declared in this scope
/usr/include/wx-2.8/wx/cursor.h:67: erreur: ‘wxBusyCursor’ has not been declared
/usr/include/wx-2.8/wx/cursor.h: In destructor ‘wxBusyCursorSuspender::~wxBusyCursorSuspender()’:
/usr/include/wx-2.8/wx/cursor.h:72: erreur: ‘wxIsBusy’ was not declared in this scope
/usr/include/wx-2.8/wx/cursor.h:74: erreur: ‘wxBusyCursor’ has not been declared
In file included from /usr/include/wx-2.8/wx/window.h:26,
                 from /usr/include/wx-2.8/wx/toplevel.h:21,
                 from /usr/include/wx-2.8/wx/dialog.h:17,
                 from /usr/include/codeblocks/scrollingdialog.h:15,
                 from /usr/include/codeblocks/configurationpanel.h:11,
                 from /home/willy/Projets/Développement/codeblocks/myplugins/HelloWorld/HelloWorld.cpp:2:
/usr/include/wx-2.8/wx/region.h: In member function ‘bool wxRegionBase::Intersect(const wxRect&)’:
/usr/include/wx-2.8/wx/region.h:251: erreur: invalid use of incomplete type ‘struct wxRegion’
/usr/include/wx-2.8/wx/gdicmn.h:38: erreur: forward declaration of ‘struct wxRegion’
/usr/include/wx-2.8/wx/region.h: In member function ‘bool wxRegionBase::Subtract(const wxRect&)’:
/usr/include/wx-2.8/wx/region.h:256: erreur: invalid use of incomplete type ‘struct wxRegion’
/usr/include/wx-2.8/wx/gdicmn.h:38: erreur: forward declaration of ‘struct wxRegion’
/usr/include/wx-2.8/wx/region.h: In member function ‘bool wxRegionBase::Xor(const wxRect&)’:
/usr/include/wx-2.8/wx/region.h:261: erreur: invalid use of incomplete type ‘struct wxRegion’
/usr/include/wx-2.8/wx/gdicmn.h:38: erreur: forward declaration of ‘struct wxRegion’
In file included from /usr/include/wx-2.8/wx/toplevel.h:21,
                 from /usr/include/wx-2.8/wx/dialog.h:17,
                 from /usr/include/codeblocks/scrollingdialog.h:15,
                 from /usr/include/codeblocks/configurationpanel.h:11,
                 from /home/willy/Projets/Développement/codeblocks/myplugins/HelloWorld/HelloWorld.cpp:2:
/usr/include/wx-2.8/wx/window.h: At global scope:
/usr/include/wx-2.8/wx/window.h:82: erreur: field ‘font’ has incomplete type
/usr/include/wx-2.8/wx/window.h:85: erreur: field ‘colFg’ has incomplete type
/usr/include/wx-2.8/wx/window.h:89: erreur: field ‘colBg’ has incomplete type
/usr/include/wx-2.8/wx/window.h:920: erreur: ‘wxUpdateUIEvent’ has not been declared
/usr/include/wx-2.8/wx/window.h:1116: erreur: ‘wxSysColourChangedEvent’ has not been declared
Process terminated with status 1 (0 minutes, 5 seconds)
50 errors, 0 warnings (0 minutes, 5 seconds)

And the installed Debian packages related to Code::Blocks:

Code: [Select]
[email protected]:~/Divers/codeblocks$ dpkg-query -l "*codeblock*" | grep -e "^ii"
ii  codeblocks                              10.05svn7965-1                     Code::Blocks integrated development environment (IDE)
ii  codeblocks-additional                   10.05svn7965-1                     additional plugins for Code::Blocks IDE
ii  codeblocks-additional-common            10.05svn7965-1                     additional plugins for Code::Blocks IDE
ii  codeblocks-common                       10.05svn7965-1                     common files for Code::Blocks IDE
ii  codeblocks-contrib                      10.05svn7965-1                     contrib plugins for Code::Blocks IDE
ii  codeblocks-contrib-common               10.05svn7965-1                     common files for the contrib plugins for Code::Blocks IDE
ii  codeblocks-dev                          10.05svn7965-1                     Code::Blocks development libraries (SDK)
ii  codeblocks-headers                      10.05svn7965-1                     Code::Blocks development headers (SDK)
ii  codeblocks-libwxcontrib0                10.05svn7965-1                     Code::Blocks shared libraries for wxContribItems
ii  libcodeblocks0                          10.05svn7965-1                     Code::Blocks shared libraries

[email protected]:~/Divers/codeblocks$ dpkg-query -l "*wx*" | grep -e "^ii"
ii  codeblocks-libwxcontrib0                10.05svn7965-1                     Code::Blocks shared libraries for wxContribItems
ii  libwxbase2.6-0                          2.6.3.2.2-5+b1                     wxBase library (runtime) - non-GUI support classes of wxWidgets toolkit
ii  libwxbase2.6-dev                        2.6.3.2.2-5+b1                     wxBase library (development) - non-GUI support classes of wxWidgets toolkit
ii  libwxbase2.8-0                          2.8.12.1-0                         wxBase library (runtime) - non-GUI support classes of wxWidgets toolkit
ii  libwxbase2.8-dev                        2.8.12.1-0                         wxBase library (development) - non-GUI support classes of wxWidgets toolkit
ii  libwxgtk2.6-0                           2.6.3.2.2-5+b1                     wxWidgets Cross-platform C++ GUI toolkit (GTK+ runtime)
ii  libwxgtk2.6-dev                         2.6.3.2.2-5+b1                     wxWidgets Cross-platform C++ GUI toolkit (GTK+ development)
ii  libwxgtk2.8-0                           2.8.12.1-0                         wxWidgets Cross-platform C++ GUI toolkit (GTK+ runtime)
ii  libwxgtk2.8-dev                         2.8.12.1-0                         wxWidgets Cross-platform C++ GUI toolkit (GTK+ development)
ii  libwxsmithlib0                          10.05svn7965-1                     wxSmith shared library (Code::Blocks plugin for RAD GUI editing)
ii  libwxsmithlib0-dev                      10.05svn7965-1                     wxSmith development metapackage
ii  wx2.6-headers                           2.6.3.2.2-5+b1                     wxWidgets Cross-platform C++ GUI toolkit (header files)
ii  wx2.8-doc                               2.8.12.1-0                         wxWidgets Cross-platform C++ GUI toolkit (documentation)
ii  wx2.8-examples                          2.8.12.1-0                         wxWidgets Cross-platform C++ GUI toolkit (examples)
ii  wx2.8-headers                           2.8.12.1-0                         wxWidgets Cross-platform C++ GUI toolkit (header files)
ii  wx2.8-i18n                              2.8.12.1-0                         wxWidgets Cross-platform C++ GUI toolkit (i18n support)
ii  wxsmith-dev                             10.05svn7965-1                     wxSmith development files (libraries)
ii  wxsmith-headers                         10.05svn7965-1                     wxSmith development files (headers)

the "HelloWorld.cpp" file:

Code: [Select]
#include <sdk.h> // Code::Blocks SDK
#include <configurationpanel.h>
#include "HelloWorld.h"
#include "logmanager.h"

// Register the plugin with Code::Blocks.
// We are using an anonymous namespace so we don't litter the global one.
namespace
{
    PluginRegistrant<HelloWorld> reg(_T("HelloWorld"));
}

// constructor
HelloWorld::HelloWorld()
{
    // Make sure our resources are available.
    // In the generated boilerplate code we have no resources but when
    // we add some, it will be nice that this code is in place already ;)
    if(!Manager::LoadResource(_T("HelloWorld.zip")))
    {
        NotifyMissingFile(_T("HelloWorld.zip"));
    }
}

// destructor
HelloWorld::~HelloWorld()
{
}

void HelloWorld::OnAttach()
{
    // do whatever initialization you need for your plugin
    // NOTE: after this function, the inherited member variable
    // m_IsAttached will be TRUE...
    // You should check for it in other functions, because if it
    // is FALSE, it means that the application did *not* "load"
    // (see: does not need) this plugin...
}

void HelloWorld::OnRelease(bool appShutDown)
{
    // do de-initialization for your plugin
    // if appShutDown is true, the plugin is unloaded because Code::Blocks is being shut down,
    // which means you must not use any of the SDK Managers
    // NOTE: after this function, the inherited member variable
    // m_IsAttached will be FALSE...
}

int HelloWorld::Execute()
{
    if( !IsAttached() )
        return -1;
    Manager::Get()->GetLogManager()->Log( _("Hello World!") );
    return 0;
}

the "HelloWorld.h" file:

Code: [Select]
/***************************************************************
 * Name:      HelloWorld
 * Purpose:   Code::Blocks plugin
 * Author:    WillyCat ([email protected])
 * Created:   2012-05-20
 * Copyright: WillyCat
 * License:   GPL
 **************************************************************/

#ifndef HELLOWORLD_H_INCLUDED
#define HELLOWORLD_H_INCLUDED

// For compilers that support precompilation, includes <wx/wx.h>
#include <wx/wxprec.h>

#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif

#include <cbplugin.h> // for "class cbToolPlugin"

class HelloWorld : public cbToolPlugin
{
    public:
        /** Constructor. */
        HelloWorld();
        /** Destructor. */
        virtual ~HelloWorld();

        /** @brief Execute the plugin.
          *
          * This is the only function needed by a cbToolPlugin.
          * This will be called when the user selects the plugin from the "Plugins"
          * menu.
          */
        virtual int Execute();
    protected:
        /** Any descendent plugin should override this virtual method and
          * perform any necessary initialization. This method is called by
          * Code::Blocks (PluginManager actually) when the plugin has been
          * loaded and should attach in Code::Blocks. When Code::Blocks
          * starts up, it finds and <em>loads</em> all plugins but <em>does
          * not</em> activate (attaches) them. It then activates all plugins
          * that the user has selected to be activated on start-up.\n
          * This means that a plugin might be loaded but <b>not</b> activated...\n
          * Think of this method as the actual constructor...
          */
        virtual void OnAttach();

        /** Any descendent plugin should override this virtual method and
          * perform any necessary de-initialization. This method is called by
          * Code::Blocks (PluginManager actually) when the plugin has been
          * loaded, attached and should de-attach from Code::Blocks.\n
          * Think of this method as the actual destructor...
          * @param appShutDown If true, the application is shutting down. In this
          *         case *don't* use Manager::Get()->Get...() functions or the
          *         behaviour is undefined...
          */
        virtual void OnRelease(bool appShutDown);
};

#endif // HELLOWORLD_H_INCLUDED

Thanks for the reply,

Willy.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6996
    • My Best Post
Re: Can't compile a simple helloworld plugin
« Reply #3 on: May 20, 2012, 03:48:18 pm »
You are compiling with the wxWidgets GUI disabled.
Find the cause of that; and the plugin will likely be fixed.

Code: [Select]
-DwxUSE_GUI=0

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7253
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Can't compile a simple helloworld plugin
« Reply #4 on: May 20, 2012, 04:04:32 pm »
What's the output of wx-config --list ?

Offline WillyCat

  • Single posting newcomer
  • *
  • Posts: 5
Re: Can't compile a simple helloworld plugin
« Reply #5 on: May 20, 2012, 06:26:52 pm »
Thanks for your replies.

Finally, it works. I think i forgot to restart Code::Block after installing the required packages.

Willy