Author Topic: [wxSmith] wxSmithContribItems not loaded on Mac OS X  (Read 14316 times)

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
[wxSmith] wxSmithContribItems not loaded on Mac OS X
« on: April 20, 2007, 05:59:18 pm »
The current Makefile is trying to link the wxSmithContribItems with wxSmith, using the static linker. This doesn't work on Mac OS X, where the plugins are loaded using the dynamic linker.

Code: [Select]
ERROR: /Users/afb/codeblocks/CodeBlocks.app/Contents/Resources/share/codeblocks/plugins/libwxsmithcontribitems.so: not loaded (missing symbols?)
It is trying to load a shared library that doesn't exist:

Code: [Select]
CodeBlocks.app/Contents/Resources/share/codeblocks/plugins/libwxsmithcontribitems.so:
        @executable_path/libcodeblocks.0.dylib (compatibility version 1.0.0, current version 1.1.0)
        @executable_path/libwx_macu-2.6.0.dylib (compatibility version 3.0.0, current version 3.1.0)
        /usr/local/share/codeblocks/plugins/libwxsmith.dylib (compatibility version 0.0.0, current version 0.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.4)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

Will remove this later, for now I just patched the Makefile so that it compiles in order to not break build.

Hopefully it will find the symbols, by loading wxSmith bundle.

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #1 on: April 20, 2007, 06:11:04 pm »
Never mind, fixed it. wxSmith had the same issue, so neither would load.

EDIT: Nope, not fixed. Still needs a solution, wxSmith{,ContribItems}
doesn't load now for Mac OS X, until a new Makefile.am can be written.
« Last Edit: April 20, 2007, 09:32:00 pm by afb »

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #2 on: April 23, 2007, 11:20:13 pm »
Hmm, what's that "new Makefile.am" ?

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #3 on: April 23, 2007, 11:41:33 pm »
For some reason wxSmith now builds as a dylib, not as a bundle.

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #4 on: April 23, 2007, 11:49:04 pm »
For some reason wxSmith now builds as a dylib, not as a bundle.

I've recently removed <tt>-module</tt> option from <tt>libwxsmith_la_LDFLAGS</tt>, maybe that's the reason. Before removing this flag, there was some warning while linking wxSmithContribItems on linux.

BYO

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #5 on: April 24, 2007, 12:31:29 am »
Without -module / as a dylib, the plugin cannot be loaded by Code::Blocks...

Would it be possible to split wxSmith into one library and one plugin, and then have both plugins (libwxsmith.so and libwxsmithcontribitems.so) link with this library (libwxsmith.dylib) - kinda like how the other plugins do with libcodeblocks.dylib ?

Because if wxSmith is built without -module, it can't be loaded as a plugin (by the dynamic linker). And if it is built with -module, it can't be linked as a library (by the static linker) in the Makefile by for instance by wxSmithContribItems.

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #6 on: April 24, 2007, 11:25:18 am »
Splitting the module works OK, I called the library "wxsmithlib":
http://www.algonet.se/~afb/wx/codeblocks-wxsmithlib.patch

The Makefile isn't perfect, seems like you can only have one
"libdir" so it installed libwxsmith.so into lib instead of plugins...
You might want to do a different split, I just extracted as little
code as possible out from wxsmith.cpp and wxsmithmime.cpp.

But doing it this way makes wxSmith load again on Mac OS X.
(including the wxSmithMime and wxSmithContribItems plugins)

Code: Text
  1. 4.0K    /usr/local/lib/libwxsmithlib.0.0.1.dylib -> libwxsmithlib.0.dylib
  2. 119M    /usr/local/lib/libwxsmithlib.0.dylib
  3. 4.0K    /usr/local/lib/libwxsmithlib.dylib -> libwxsmithlib.0.dylib
  4. 4.0K    /usr/local/lib/libwxsmithlib.la
  5. 4.0K    /usr/local/share/codeblocks/plugins/libwxsmith.la
  6. 728K    /usr/local/share/codeblocks/plugins/libwxsmith.so
  7. 4.0K    /usr/local/share/codeblocks/plugins/libwxsmithcontribitems.la
  8. 7.4M    /usr/local/share/codeblocks/plugins/libwxsmithcontribitems.so
  9.  
« Last Edit: April 24, 2007, 11:30:00 am by afb »

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #7 on: April 24, 2007, 10:04:30 pm »
Hmm, patch looks fine, simillar to my idea:



+-- wxSmith base -------------------------------------------------+
|                                                                 |
|    +------------------------+        +-----------------------+  |
|    |     Plugin classes     |        |    wxSmith engine     |  |
|    |  * wxSmith             | =====> |  (all other wxSmith's |  |
|    |  * wxSmithMime         |        |   classes)            |  |
|    +------------------------+        +-----------------------+  |
|                                          /\      /\             |
|                                          ||      ||             |
+------------------------------------------||------||-------------+
                                           ||      ||
          ===================================      ||
          ||                                       ||
+-- Contrib items 1 ----+              +-- Contrib items 2 ----+   
|                       |              |                       |   
|                       |              |                       |   
+-----------------------+              +-----------------------+   



So plugin classes are put into .so, they would only forward calls from Code::Blocks into wxSmith engine. The Engine itself would be .dylib object (just like wxsmithlib in your patch) and contrib item classes would connect through engine.

That may have few drawbacks (it won't be able to create .cbplugin for wxSmith), but currently they wont cause any problems.

I'll try to implement this by using your patch (I'm not familliar enough with Makfiles to rely on my own knowledge ;) ) and hope that this will work. And I'll leave one dll in windows since it works fine.

Regards
  BYO

EDIT: I just forgot to mention that current content of wxSmith class will be put into wxSmithEngine because some components my use it's functionality. Old wxSmith class will be only a wrapper for wxSmithEngine - that's the main difference between my solution and yours ;)
« Last Edit: April 24, 2007, 10:08:08 pm by byo »

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #8 on: April 24, 2007, 10:18:09 pm »
Ok, I studied your patch a little bit better and it looks like I misunderstood few things  :oops:. Looks like everything is right there :) Maybe those two plugin registrands could be put intside one file.

BYO

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #9 on: April 25, 2007, 11:58:22 am »
Maybe those two plugin registrands could be put intside one file.

Tried that, but then C++ barfed on two nameless namespaces in one file.

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #10 on: April 25, 2007, 05:46:23 pm »
Maybe those two plugin registrands could be put intside one file.

Tried that, but then C++ barfed on two nameless namespaces in one file.

Two different names for registrants are enough, I've committed that already. Could you check if it works ? (it ompiles and run on linux)

BYO

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #11 on: April 25, 2007, 10:38:36 pm »
Seems to have worked, but one was missing:

Code: [Select]
*** Warning: Linking the shared library libwxsmithcontribitems.la against the loadable module
*** libwxsmith.so is not portable!
** Warning, lib libwxsmith.so is a module, not a shared library
...
Code: [Select]
/usr/bin/ld: ../wxSmith/.libs/libwxsmith.so is input for the dynamic link editor, is not relocatable by the static link editor again

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #12 on: April 25, 2007, 11:31:20 pm »
Seems to have worked, but one was missing:

Code: [Select]
*** Warning: Linking the shared library libwxsmithcontribitems.la against the loadable module
*** libwxsmith.so is not portable!
** Warning, lib libwxsmith.so is a module, not a shared library
...
Code: [Select]
/usr/bin/ld: ../wxSmith/.libs/libwxsmith.so is input for the dynamic link editor, is not relocatable by the static link editor again

 :? What that could mean ?

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #13 on: April 26, 2007, 09:30:37 am »
:? What that could mean ?

It means that you cannot link to libwxsmith.so bundle from another module,
but only to the libwxsmithlib.dylib shared library. As in: why I changed it... ?

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: [wxSmith] wxSmithContribItems not loaded on Mac OS X
« Reply #14 on: April 26, 2007, 10:27:19 am »
Still need to fix the bug where the .so module ends up
in the wrong directory. Maybe just "mv" it after install ?

Code: [Select]
/usr/local/lib/libwxsmith.so
/usr/local/share/codeblocks/plugins/libwxsmithcontribitems.so