Author Topic: HelloWorld example plugin  (Read 10188 times)

Offline anio

  • Single posting newcomer
  • *
  • Posts: 8
HelloWorld example plugin
« on: February 21, 2012, 10:21:11 am »
Hello,
I didnt find such a functionality in CB nor plugin for it, but i wanna be able when a text is selected in the editor and press button for brackets/commas this text to be wrapped instead of deleted. The same way as in Kate editor.
I am new in codeblocks so followed this tutorial to install it on my Ubuntu: http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Linux
CB is working good but when i started the tutorial to create my first plugin http://wiki.codeblocks.org/index.php?title=Creating_a_simple_%22Hello_World%22_plugin I cannot find linux equivalent for C:\CodeBlocks\sdk\include or C:\CodeBlocks\sdk\lib so i choose /home/user/devel/trunk/src/sdk but there are no lib or include dirs inside and i left /home/user/devel/trunk/src/sdk for both, but when select Install plugin it couldnt find the HelloWorld.so file.
Regards

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9488
Re: HelloWorld example plugin
« Reply #1 on: February 21, 2012, 11:03:13 am »
Another one stating nothing about version, platform etc... >:(

So I'll try to answer  in the same "generic" way:
Once downloaded/checked out the C::B sources from SVN, compile C::B completely to create  the libraries, then run the update script and you'll find the SDK libraries under the folder "devel".

Alternatively if you link against a nightly build, just use the folder, where codeblocks.dll is in.
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 jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: HelloWorld example plugin
« Reply #2 on: February 21, 2012, 11:19:00 am »
Alternatively if you link against a nightly build, just use the folder, where codeblocks.dll is in.

It should be libcodeblocks.so on linux.

Alternatively you can use my repo and install the development packages also. Or use the automake build-system to build and install C::B.
Then you can use pkg-config for your development.

Offline anio

  • Single posting newcomer
  • *
  • Posts: 8
Re: HelloWorld example plugin
« Reply #3 on: February 21, 2012, 11:22:47 am »
Sorry for this.
I checked out from here svn://svn.berlios.de/codeblocks/trunk
Platform: Ubuntu 11.10 32 bit, kernel 3.0.0-16
Compiler: gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3),  i686-linux-gnu

Code: [Select]
user@ubuntu:~/devel/trunk/src$ ./update
Creating output directory tree
Compressing core UI resources
Compressing plugins UI resources
Packing core UI bitmaps
Packing plugins UI bitmaps
Copying files
cp: cannot stat `devel/codeblocks': No such file or directory
cp: cannot stat `devel/*.so': No such file or directory
cp: cannot stat `devel/share/codeblocks/plugins/*.so': No such file or directory
Stripping debug info from output tree
strip: 'output/codeblocks': No such file
strip: 'output/*.so': No such file
strip: 'output/share/codeblocks/plugins/*.so': No such file
Creating launch-scripts

C::B is completely build and working (svn 7809)
Thanks

EDIT: libcodeblocks.so is in ~/devel/trunk/src/sdk/.libs/ but C::B directory select menu cannot navigate to .* directories

EDIT2:
in the update shell script:
line 95: cp -f devel/codeblocks${EXEEXT} output > /dev/null
лине 96: cp -f devel/*.${LIBEXT} output > /dev/null
there is no any *.so file in the devel dir. Only cb_console_runner,run.sh and share/
« Last Edit: February 21, 2012, 12:25:24 pm by anio »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: HelloWorld example plugin
« Reply #4 on: February 21, 2012, 12:41:40 pm »
How did you build C::B ?
If it was build with the automake-system, the update-script is not needed.
And you should have pkg-config files for C::B in <prefix>/lib/pkgconfig .

Offline anio

  • Single posting newcomer
  • *
  • Posts: 8
Re: HelloWorld example plugin
« Reply #5 on: February 21, 2012, 12:54:48 pm »
Yes, i build it with ./configure --prefix=/opt/wx/2.8  --enable-xrc  --enable-monolithic  --enable-unicode
but wx-config --prefix is giving me /usr instead of /opt/wx/2.8 and i added /opt/wx/2.8/lib to /etc/ld.so.conf

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: HelloWorld example plugin
« Reply #6 on: February 21, 2012, 01:41:35 pm »
How did you build C::B ?
If it was build with the automake-system, the update-script is not needed.
And you should have pkg-config files for C::B in <prefix>/lib/pkgconfig .

Yes, i build it with ./configure --prefix=/opt/wx/2.8  --enable-xrc  --enable-monolithic  --enable-unicode
but wx-config --prefix is giving me /usr instead of /opt/wx/2.8 and i added /opt/wx/2.8/lib to /etc/ld.so.conf
I did not ask how you build wx, but how you build Code::Blocks .
The ./configure parameters are for wxWidgets and not for C::B.

Do not build wxWidget's on your own, unless you know exactly what you do (and what you want from it).
Configuring wxWidgets can be a non-trivial task (as your wx-config output shows), and on most linux distros there are packages available, that are known to work flawlessly.

Offline anio

  • Single posting newcomer
  • *
  • Posts: 8
Re: HelloWorld example plugin
« Reply #7 on: February 21, 2012, 01:49:26 pm »
Well, i followed strictly http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Linux  with ./bootstrap and then make/make install

EDIT: I just tried to build the plugin in C::B. When the Install is throwing and error that cant find HelloWorld.so i found in the build log that there is actually libHelloWorld.so:
Quote
/usr/local/include/codeblocks/pluginmanager.h: In constructor ‘PluginManager::PluginRegistration::PluginRegistration()’:
/usr/local/include/codeblocks/pluginmanager.h:163:77: note: synthesized method ‘PluginInfo::PluginInfo()’ first required here
Linking dynamic library: libHelloWorld.so
Output size is 157,79 KB
Running target post-build steps
zip -j9 HelloWorld.zip manifest.xml
updating: manifest.xml (deflated 52%)
zip -j9 HelloWorld.cbplugin libHelloWorld.so HelloWorld.zip
updating: libHelloWorld.so
 (deflated 62%)
« Last Edit: February 21, 2012, 02:29:26 pm by anio »

Offline anio

  • Single posting newcomer
  • *
  • Posts: 8
Re: HelloWorld example plugin
« Reply #8 on: February 21, 2012, 03:52:29 pm »
There is some (probably) bug with the name of the *.so file. How Ive made it to work:
Quote
cp libHelloWorld.so HelloWorld.so
zip -j9 HelloWorld.cbplugin libHelloWorld.so HelloWorld.zip
Then I installed in with the plugin manager and run it:
Quote
Loaded 1 plugins
HelloWorld

Edit:
In the Project Build options. "Pre/Post build" tab -> "Post-build steps" i found this:
Quote
zip -j9 HelloWorld.zip manifest.xml
zip -j9 HelloWorld.cbplugin libHelloWorld.so HelloWorld.zip
« Last Edit: February 21, 2012, 03:55:18 pm by anio »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: HelloWorld example plugin
« Reply #9 on: February 21, 2012, 06:24:26 pm »
Change the output name in the project's properties (tab "Build targets") and uncheck "Autogenerate filename prefix".

Offline anio

  • Single posting newcomer
  • *
  • Posts: 8
Re: HelloWorld example plugin
« Reply #10 on: February 22, 2012, 09:11:08 am »
Change the output name in the project's properties (tab "Build targets") and uncheck "Autogenerate filename prefix".
Thank you for the help. Everything is working as expected now and im starting to learn how the plugins work.
Does the Log manager print his output to the Code::Blocks tab? None of these print anything there:
Code: [Select]
Manager::Get()->GetLogManager()->DebugLog(msg);
Manager::Get()->GetLogManager()->Log( msg );

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: HelloWorld example plugin
« Reply #11 on: February 23, 2012, 04:35:48 am »
I didnt find such a functionality in CB nor plugin for it, but i wanna be able when a text is selected in the editor and press button for brackets/commas this text to be wrapped instead of deleted. The same way as in Kate editor.
Feature already written as a patch :) -> see patch #3234.

Offline anio

  • Single posting newcomer
  • *
  • Posts: 8
Re: HelloWorld example plugin
« Reply #12 on: February 23, 2012, 12:19:46 pm »
Wonderful :) Thank you, I will patch my C::B.

Offline anio

  • Single posting newcomer
  • *
  • Posts: 8
Re: HelloWorld example plugin
« Reply #13 on: February 23, 2012, 04:19:59 pm »
Alpha, it works as expected. I think this feature should be added by default in C::B.
Thanks!