Author Topic: HelloWorld Plugin on Ubuntu 11.04  (Read 19009 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #15 on: May 31, 2011, 05:17:24 pm »
Yes, the last g++ command (the one with -shared flag) is calling the linker for you.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline hibbity

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #16 on: May 31, 2011, 05:37:53 pm »
Now linking against wxsmithlib and adding linker option '-z defs', result is much more manageable.
Build log:

-------------- Build: default in CustomButton ---------------
g++  -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/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread   -march=i586   -I/usr/local/include/wx-2.8 -I/usr/include/wxsmith/contrib/include -Iwxthings/include -I/usr/local/include/wx-2.8 -I/usr/include/wxsmith/contrib/include -Iwxthings/include  -c /home/guest/custom_widgets/wxlinux/wxthings/custombutton.cpp -o .objs/custombutton.o
g++  -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/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread   -march=i586   -I/usr/local/include/wx-2.8 -I/usr/include/wxsmith/contrib/include -Iwxthings/include -I/usr/local/include/wx-2.8 -I/usr/include/wxsmith/contrib/include -Iwxthings/include  -c /home/guest/custom_widgets/wxlinux/wxthings/wxscustombutton.cpp -o .objs/wxscustombutton.o
g++ -shared  .objs/custombutton.o .objs/wxscustombutton.o   -o custombutton.so -z defs -lcodeblocks    -pthread -Wl,-Bsymbolic-functions  -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8   -z defs  -lwxsmithlib -lwxsmithlib
.objs/wxscustombutton.o: In function `wxsCustomButton::OnBuildPreview(wxWindow*, long)':
/home/guest/custom_widgets/wxlinux/wxthings/wxscustombutton.cpp:202: undefined reference to `wxCustomButton::CreateBitmapDisabled(wxBitmap const&) const'
/home/guest/custom_widgets/wxlinux/wxthings/wxscustombutton.cpp:207: undefined reference to `wxCustomButton::SetMargins(wxSize const&, bool)'
/home/guest/custom_widgets/wxlinux/wxthings/wxscustombutton.cpp:212: undefined reference to `wxCustomButton::SetLabelMargin(wxSize const&, bool)'
/home/guest/custom_widgets/wxlinux/wxthings/wxscustombutton.cpp:217: undefined reference to `wxCustomButton::SetBitmapMargin(wxSize const&, bool)'
.objs/wxscustombutton.o: In function `wxCustomButton':
/home/guest/custom_widgets/wxlinux/wxthings/wxthings/include/wx/things/toggle.h:143: undefined reference to `vtable for wxCustomButton'
/home/guest/custom_widgets/wxlinux/wxthings/wxthings/include/wx/things/toggle.h:145: undefined reference to `wxCustomButton::Init()'
/home/guest/custom_widgets/wxlinux/wxthings/wxthings/include/wx/things/toggle.h:146: undefined reference to `wxCustomButton::Create(wxWindow*, int, wxString const&, wxBitmap const&, wxPoint const&, wxSize const&, long, wxValidator const&, wxString const&)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 2 seconds)
7 errors, 0 warnings

It seems that ../wxthings/wxthings/.libs/libwxcustombutton.so is not being linked in.
 
« Last Edit: May 31, 2011, 05:45:35 pm by hibbity »

Offline hibbity

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #17 on: May 31, 2011, 05:58:20 pm »
Cool, now it compiles, links and installs.

For the final steps, I added  wxthings/.libs to the Search directories -->Linker
and added libwxcustombutton to the Linker settings-->Link libraries.

Thanks for the help, much appreciated.   :)
« Last Edit: May 31, 2011, 06:01:29 pm by hibbity »

Offline hibbity

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #18 on: June 02, 2011, 10:51:21 pm »
Discovered that placing a CustomButton widget into a project, and linking against libwxscustombutton causes problems -- the app does not exit properly, and when it does, a return code of "-1" is given.

Too bad, because now I'm back where I started -- trying to find a widget plugin that is simple, and "just works".

Offline hibbity

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #19 on: June 03, 2011, 12:20:55 am »
Custom control widgets are made available in wxSmith as shared library plugins. 

Why shared?  Is it not possible to static link a plugin into a GUI application?  It would make debugging easier, for one.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #20 on: June 03, 2011, 01:12:28 am »
What is the difference in terms of debugging?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #21 on: June 03, 2011, 03:07:44 am »
Why shared?  Is it not possible to static link a plugin into a GUI application?  It would make debugging easier, for one.

A plugin is something designed to be added or removed at runtime. If statically linked it can NOT be added or removed.

Tim S.
« Last Edit: June 03, 2011, 03:10:50 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline hibbity

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #22 on: June 09, 2011, 05:42:00 pm »
What is the difference in terms of debugging?


Here is an example.  wxCustomButton has been added to a GUI.  There are no build errors, no runtime errors, except for this one nagging problem.
After OnExit() has been called, the app hangs.  This is attributable to the newly added wxCustomButton widget, because it never occurred before it was added to the GUI project.  So, how then do you go about debugging this -- when the problem exists in a shared library.  For example how would you set a breakpoint?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #23 on: June 09, 2011, 05:50:26 pm »
What will be the difference if wxCustomButton was a static lib instead of shared lib?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline hibbity

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #24 on: June 09, 2011, 06:02:41 pm »
What will be the difference if wxCustomButton was a static lib instead of shared lib?

Both present the same challenge in terms of debugging.  Speaking for myself (who is just learning to use the gnu debugger).

Offline hibbity

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #25 on: June 09, 2011, 06:52:58 pm »
Following OnExit, the gui app continues to execute into wxEntry(...) and never returns, as illustrated in debugging session:

GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2
This GDB was configured as "i686-linux-gnu".

Reading symbols from ../wx_test/bin/Debug/wx_test...done.
(gdb) break 78
Breakpoint 1 at 0x8050f5a: file ../wx_test/wx_testApp.cpp, line 78.
(gdb) run -i./test.ini
Starting program: ../wx_test/bin/Debug/wx_test -i./test.ini
[Thread debugging using libthread_db enabled]
OnInitCmdLine()
OnCmdLineParsed()
Parsing iniFile: ./test.ini
[New Thread 0xb7cb1b70 (LWP 14414)]
[New Thread 0xb72ffb70 (LWP 14415)]
OnInit()
Test GUI:  pid 14411
OnExit()

Breakpoint 1, wx_testApp::OnExit (this=0x80ca958)
    at ../wx_test/wx_testApp.cpp:78
78       return 0;
(gdb) step
79   }
(gdb) step
0x00840c87 in wxEntry(int&, wchar_t**) () from /usr/lib/libwx_baseu-2.8.so.0
(gdb) step
Single stepping until exit from function _Z7wxEntryRiPPw,
which has no line number information.
[Thread 0xb7cb1b70 (LWP 14414) exited]
<<<File->Quit causes OnExit(), (Thread 14415 has not exited); execution is hung here, no return to gdb command prompt.>>>

I would need to rebuild libwx_baseu-2.8 with debugging symbols to be able to trace into it.
« Last Edit: June 09, 2011, 06:58:41 pm by hibbity »

Offline hibbity

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: HelloWorld Plugin on Ubuntu 11.04
« Reply #26 on: June 10, 2011, 08:17:15 pm »
I followed tips found in http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks
 i.e. compiler build settings (enable debugging symbols), no optimization or symbol stripping.

Then rebuild wxCustomButton, reinstall wxCustomButton, Rebuild test GUI, Debug test GUI.
Result is the same as before.  GUI app uses the same shared library as before.

Code
0x00840c87 in wxEntry(int&, wchar_t**) () from /usr/lib/libwx_baseu-2.8.so.0

This should read, "libwx_baseud-2.8.so.0" instead (i.e. the debug version of the shared library).  How do I change it?