Author Topic: Compiling plugin for Mac OSX  (Read 7324 times)

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Compiling plugin for Mac OSX
« on: October 12, 2009, 12:17:20 am »
Hi, I've created a plugin for Code::blocks on windows, that uses wxWidgets. On windows it compiles nice and works as it should. I've now downloaded the 8.02 tag from svn, compiled C::B from source (also wxMac) and I'm trying to compile my plugin, but it fails when it wants to link it. I'm using the `/usr/local/bin/wx-config --cppflags` and `/usr/local/bin/wx-config --libs` in my build options. Does someone knows how I can fix this?

This is the output of C::B

Code: [Select]
-------------- Build: default in OpenFrameworks ---------------

g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I/usr/local/lib/wx/include/mac-ansi-release-2.8/ -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinyxmlparser.cpp -o .objs/tinyxml/tinyxmlparser.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I/usr/local/lib/wx/include/mac-ansi-release-2.8/ -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/InstallParser.cpp -o .objs/InstallParser.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I/usr/local/lib/wx/include/mac-ansi-release-2.8/ -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cpp -o .objs/OpenFrameworks.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I/usr/local/lib/wx/include/mac-ansi-release-2.8/ -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/ProjectAnalyzer.cpp -o .objs/ProjectAnalyzer.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I/usr/local/lib/wx/include/mac-ansi-release-2.8/ -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinystr.cpp -o .objs/tinyxml/tinystr.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I/usr/local/lib/wx/include/mac-ansi-release-2.8/ -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinywxuni.cpp -o .objs/tinyxml/tinywxuni.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I/usr/local/lib/wx/include/mac-ansi-release-2.8/ -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinyxml.cpp -o .objs/tinyxml/tinyxml.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I/usr/local/lib/wx/include/mac-ansi-release-2.8/ -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinyxmlerror.cpp -o .objs/tinyxml/tinyxmlerror.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DWXUSINGDLL -DcbDEBUG -DCB_PRECOMP -DWX_PRECOMP -DwxUSE_UNICODE    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I/usr/local/lib/wx/include/mac-ansi-release-2.8/ -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/AddonDialog.cpp -o .objs/AddonDialog.o
g++ -shared -L/usr/local/include/devel -L/usr/local/lib/ -L/usr/local/lib  .objs/tinyxml/tinyxmlparser.o .objs/InstallParser.o .objs/OpenFrameworks.o .objs/ProjectAnalyzer.o .objs/tinyxml/tinystr.o .objs/tinyxml/tinywxuni.o .objs/tinyxml/tinyxml.o .objs/tinyxml/tinyxmlerror.o .objs/AddonDialog.o   -o OpenFrameworks.dylib -L/usr/local/lib   -framework IOKit -framework Carbon -framework Cocoa -framework System -framework QuickTime -framework OpenGL -framework AGL  -lwx_mac_richtext-2.8 -lwx_mac_aui-2.8 -lwx_mac_xrc-2.8 -lwx_mac_qa-2.8 -lwx_mac_html-2.8 -lwx_mac_adv-2.8 -lwx_mac_core-2.8 -lwx_base_carbon_xml-2.8 -lwx_base_carbon_net-2.8 -lwx_base_carbon-2.8    -lcodeblocks
i686-apple-darwin8-g++-4.0.1: unrecognized option '-shared'
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning -L: directory name (/usr/local/include/devel) does not exist
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: Undefined symbols:
_main
wxStringBase::InitWith(wchar_t const*, unsigned long, unsigned long)
wxStringBase::wxStringBase(unsigned long, wchar_t)
wxString::wxString(char const*, wxMBConv const&, unsigned long)
wxString::Printf(wchar_t const*, ...)
wxString::mb_str(wxMBConv const&) const
operator+(wchar_t const*, wxString const&)
wxStringBase::ConcatSelf(unsigned long, wchar_t const*, unsigned long)
wxString::Find(wchar_t const*) const
operator+(wxString const&, wchar_t const*)
wxFile::Access(wchar_t const*, wxFile::OpenMode)
wxFile::wxFile(wchar_t const*, wxFile::OpenMode)
wxString::Format(wchar_t const*, ...)
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 13 seconds)
0 errors, 0 warnings

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6665
    • My Best Post
Re: Compiling plugin for Mac OSX
« Reply #1 on: October 12, 2009, 01:07:49 am »
Code::Blocks is normally Unicode the log you showed looked like ANSI build of wxWidgets.
Which are you trying to do?
You can NOT easily mix the two!

The below define implies Unicode build
Code: [Select]
-DwxUSE_UNICODE
The folder name below implies ANSI build
Code: [Select]
mac-ansi-release-2.8
Tim S.
  
« Last Edit: October 12, 2009, 01:14:44 am by stahta01 »
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 afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Compiling plugin for Mac OSX
« Reply #2 on: October 12, 2009, 05:22:31 pm »
Quote
i686-apple-darwin8-g++-4.0.1: unrecognized option '-shared'

You need to use -bundle on Mac OS X, not -shared
(If making a shared library, it would be -dynamiclib)

Probably should use libtool to handle that for you... ?
(see the plugins bundled with codeblocks for examples)

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Compiling plugin for Mac OSX
« Reply #3 on: October 12, 2009, 08:32:51 pm »
hi afb, thanks a lot! Using dynamiclib and removing-DwxUSE_UNICODE did the trick.

Now I'm curious how I can create an installable plugin?

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Compiling plugin for Mac OSX
« Reply #4 on: October 12, 2009, 10:43:37 pm »
hi afb, thanks a lot! Using dynamiclib and removing-DwxUSE_UNICODE did the trick.

Now I'm curious how I can create an installable plugin?


Well, you need two things: the bundle (.so) and the resources (.zip)
Dynamic libs are only used for things such as libcodeblocks.0.dylib

Then you need to make sure it can find all the libraries it needs,
this you can check and correct with otool and install_name_tool.

Code: [Select]
$ otool -L libcompiler.so
libcompiler.so:
        @executable_path/libwx_macu-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        @executable_path/libcodeblocks.0.dylib (compatibility version 1.0.0, current version 1.1.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.10)
        /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)

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Compiling plugin for Mac OSX
« Reply #5 on: October 13, 2009, 08:49:20 pm »
Hi Afb,

I'm still trying to create a plugin for the mac.  I want to use Code::Blocks to to create this plugin as I'm doing that on Windows as well. There are maybe some issues which are Mac related; for example when I select "Dynamic library" (Project > Properties > Build targets) than it uses "-shared" instead of bundle. I fixed this by going to the advanced compiler settings and changing the -shared to -bundle. Than I try to rename the output to: OpenFrameworks.so instead of OpenFrameworks.dylib. I can edit the field, but the changed value is simple lost. Therefore I tried to use the post build commands to rename the compiled file to OpenFrameworks.so and than adding that to a zip.

This is my compilation output
Code: [Select]

-------------- Build: default in OpenFrameworks ---------------

g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DCB_PRECOMP -DWX_PRECOMP    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I"/usr/lib/wx/include/mac-unicode-debug-2.5 -I/usr/include/wx-2.5 /" -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinyxmlparser.cpp -o .objs/tinyxml/tinyxmlparser.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DCB_PRECOMP -DWX_PRECOMP    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I"/usr/lib/wx/include/mac-unicode-debug-2.5 -I/usr/include/wx-2.5 /" -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/InstallParser.cpp -o .objs/InstallParser.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DCB_PRECOMP -DWX_PRECOMP    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I"/usr/lib/wx/include/mac-unicode-debug-2.5 -I/usr/include/wx-2.5 /" -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cpp -o .objs/OpenFrameworks.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DCB_PRECOMP -DWX_PRECOMP    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I"/usr/lib/wx/include/mac-unicode-debug-2.5 -I/usr/include/wx-2.5 /" -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/ProjectAnalyzer.cpp -o .objs/ProjectAnalyzer.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DCB_PRECOMP -DWX_PRECOMP    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I"/usr/lib/wx/include/mac-unicode-debug-2.5 -I/usr/include/wx-2.5 /" -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinystr.cpp -o .objs/tinyxml/tinystr.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DCB_PRECOMP -DWX_PRECOMP    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I"/usr/lib/wx/include/mac-unicode-debug-2.5 -I/usr/include/wx-2.5 /" -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinywxuni.cpp -o .objs/tinyxml/tinywxuni.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DCB_PRECOMP -DWX_PRECOMP    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I"/usr/lib/wx/include/mac-unicode-debug-2.5 -I/usr/include/wx-2.5 /" -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinyxml.cpp -o .objs/tinyxml/tinyxml.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DCB_PRECOMP -DWX_PRECOMP    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I"/usr/lib/wx/include/mac-unicode-debug-2.5 -I/usr/include/wx-2.5 /" -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinyxmlerror.cpp -o .objs/tinyxml/tinyxmlerror.o
g++  -g -I/usr/local/lib/wx/include/mac-ansi-release-2.8 -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXMAC__  -DBUILDING_PLUGIN -D__WXMAC__ -DCB_PRECOMP -DWX_PRECOMP    -Itinyxml -I/usr/local/include/include -I/usr/local/include/include/wxscintilla/include -I"/usr/lib/wx/include/mac-unicode-debug-2.5 -I/usr/include/wx-2.5 /" -I/usr/local/include/wx-2.8 -I/usr/local/include/codeblocks/ -I/usr/local/include/codeblocks/wxscintilla/include/  -c /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/AddonDialog.cpp -o .objs/AddonDialog.o

Output size is 5.76 MB

And creating the bundle
Code: [Select]
g++ -bundle -L/usr/local/include/devel -L/usr/lib/ -L/usr/local/lib  .objs/tinyxml/tinyxmlparser.o .objs/InstallParser.o .objs/OpenFrameworks.o .objs/ProjectAnalyzer.o .objs/tinyxml/tinystr.o .objs/tinyxml/tinywxuni.o .objs/tinyxml/tinyxml.o .objs/tinyxml/tinyxmlerror.o .objs/AddonDialog.o   -o OpenFrameworks.dylib -L/usr/local/lib   -framework IOKit -framework Carbon -framework Cocoa -framework System -framework QuickTime -framework OpenGL -framework AGL  -lwx_mac_richtext-2.8 -lwx_mac_aui-2.8 -lwx_mac_xrc-2.8 -lwx_mac_qa-2.8 -lwx_mac_html-2.8 -lwx_mac_adv-2.8 -lwx_mac_core-2.8 -lwx_base_carbon_xml-2.8 -lwx_base_carbon_net-2.8 -lwx_base_carbon-2.8    -lcodeblocks

/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning -L: directory name (/usr/local/include/devel) does not exist

Output size is 5.76 MB

And the post build steps
Code: [Select]
Running target post-build steps
cp OpenFrameworks.dylib OpenFrameworks.so
zip -j9 OpenFrameworks.zip manifest.xml
updating: manifest.xml (deflated 53%)
zip -j9 OpenFrameworks.cbplugin OpenFrameworks.so OpenFrameworks.zip
updating: OpenFrameworks.zip (deflated 8%)
  adding: OpenFrameworks.so
 (deflated 82%)
Process terminated with status 0 (0 minutes, 13 seconds)
0 errors, 0 warnings

Than I used otool to check if there are broken dependencies
Code: [Select]
otool -L OpenFrameworks.so
OpenFrameworks.so:
        /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
        /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)
        /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.11)
        /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime (compatibility version 1.0.0, current version 1327.73.0)
        /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
        /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
        /usr/local/lib/libwx_mac_richtext-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/local/lib/libwx_mac_aui-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/local/lib/libwx_mac_xrc-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/local/lib/libwx_mac_qa-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/local/lib/libwx_mac_html-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/local/lib/libwx_mac_adv-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/local/lib/libwx_mac_core-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/local/lib/libwx_base_carbon_xml-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/local/lib/libwx_base_carbon_net-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/local/lib/libwx_base_carbon-2.8.0.dylib (compatibility version 7.0.0, current version 7.0.0)
        /usr/local/lib/libcodeblocks.0.dylib (compatibility version 1.0.0, current version 1.1.0)
        /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)

All seems well, so I try to install the plugin, but then I get the message that "one or more plugins could not be installed" and in the
console (I started C::B using: /usr/local/bin/codeblocks), I see this:
Code: [Select]
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaNoneSkipFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaPremultipliedFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaNoneSkipFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaPremultipliedFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaNoneSkipFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaPremultipliedFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaNoneSkipFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaPremultipliedFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
Failed
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaNoneSkipFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaPremultipliedFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaNoneSkipFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context
CGBitmapContextCreate: invalid data bytes/row: should be at least 4 for 8 integer bits/component, 3 components, kCGImageAlphaPremultipliedFirst.
CGContextConcatCTM: invalid context
CGContextConcatCTM: invalid context

When I google on those errors I find some pages to wxWidgets, but I'm not sure if that's the problem or how to solve it.. Someone?


Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Compiling plugin for Mac OSX
« Reply #6 on: October 13, 2009, 10:19:38 pm »
Okay I continued trying to figure out where/why I cannot install a plugin on the Mac. I get the feeling this part is maybe just not working on Mac as I actually don't see where the plugin is added to the internal list of plugins (m_plugins) in PluginManager.cpp. I added some debug info and tried to install the plugin again. I noticed that it searches for a file name "plugin.dylib", and not "plugin.so" as someone suggested I should use. If I'm correct I should use g++ -bundle to create a .so file and -dynamiclib when I want to create a .dylib.

This is the changed pluginmanager.cpp
http://paste-it.net/public/qe4041f/

And my output:
Code: [Select]
Initialize EditColourSet .....
Initialize EditColourSet: done.
Loading toolbar...
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libastyle.so
## Register a plugin: AStylePlugin
AStylePlugin: loaded
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libautosave.so
## Register a plugin: Autosave
Autosave: loaded
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libclasswizard.so
## Register a plugin: ClassWizard
ClassWizard: loaded
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libcodecompletion.so
## Register a plugin: CodeCompletion
CodeCompletion: loaded
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libcompiler.so
## Register a plugin: Compiler
Compiler: loaded
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libdebugger.so
## Register a plugin: Debugger
Debugger: loaded
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libdefaultmimehandler.so
## Register a plugin: FilesExtensionHandler
FilesExtensionHandler: loaded
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libopenfileslist.so
## Register a plugin: OpenFilesList
OpenFilesList: loaded
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libprojectsimporter.so
## Register a plugin: ProjectsImporter
ProjectsImporter: loaded
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libscriptedwizard.so
## Register a plugin: ScriptedWizard
ScriptedWizard: loaded
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libtodo.so
## Register a plugin: ToDoList
ToDoList: loaded
Source code formatter (AStyle) plugin activated
Autosave plugin activated
Class wizard plugin activated
Code completion plugin activated
Added compiler "GNU GCC Compiler"
Added compiler "Intel C/C++ Compiler"
Added compiler "SDCC Compiler"
Added compiler "Tiny C Compiler"
Added compiler "GDC D Compiler"
Compiler plugin activated
Debugger plugin activated
Files extension handler plugin activated
Open files list plugin activated
Foreign projects importer plugin activated
Project wizard added for 'Empty project'
Project wizard added for 'Console application'
Project wizard added for 'D application'
Project wizard added for 'FLTK project'
Project wizard added for 'GLFW project'
Project wizard added for 'GLUT project'
Project wizard added for 'GTK+ project'
Project wizard added for 'Irrlicht project'
Project wizard added for 'Lightfeather project'
Project wizard added for 'OpenGL project'
Project wizard added for 'Ogre project'
Project wizard added for 'Code::Blocks plugin'
Project wizard added for 'QT4 project'
Project wizard added for 'SDL project'
Project wizard added for 'Static library'
Project wizard added for 'Shared library'
Project wizard added for 'AVR Project'
Project wizard added for 'wxWidgets project'
Build-target wizard added for 'Console'
Build-target wizard added for 'Static library'
Build-target wizard added for 'wxWidgets'
File(s) wizard added for 'Empty file'
File(s) wizard added for 'C/C++ source'
File(s) wizard added for 'C/C++ header'
Scripted wizard plugin activated
To-Do List plugin activated
Initializing plugins...
## 1. Install plugin: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
## Plugin for all users
## We want the file to be named like: OpenFrameworks.dylib
ExtractFile:
Plugin filename: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
Source filename: OpenFrameworks.dylib
Destination filename: /usr/local/bin/../share/codeblocks/plugins/OpenFrameworks.dylib
Extracting...
File not found in plugin
## The file OpenFrameworks.dylib is mandatory and not found for plugin /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
## Error while extracting the plugin: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
Loading project file...
Parsing project file...
Loading target default
Loading target cb_8.02
Loading target cb_svn
Loading project files...
17 files loaded
Done loading project in 83ms
Project's base path: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/
Project's common toplevel path: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/
project data set for /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/ProjectAnalyzer.cpp
project data set for /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/InstallParser.cpp
project data set for /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/AddonDialog.cpp
project data set for /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/AddonDialog.h
project data set for /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/ProjectAnalyzer.h
project data set for /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cpp
project data set for /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.h
project data set for /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/InstallParser.h
project data set for /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinywxuni.cpp
Top Editor: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/tinyxml/tinywxuni.cpp
Add project OpenFrameworks in parsing queue
Caching result of `/usr/local/bin/wx-config --cppflags`
Cached
Caching result of `/usr/local/bin/wx-config --libs`
Cached
Caching internal gcc dirs for adding to parser...
Caching GCC dir: /usr/include/c++/4.0.0
Caching GCC dir: /usr/include/c++/4.0.0/i686-apple-darwin8
Caching GCC dir: /usr/include/c++/4.0.0/backward
Caching GCC dir: /usr/local/include
Caching GCC dir: /usr/lib/gcc/i686-apple-darwin8/4.0.1/include
Caching GCC dir: /usr/include
Caching GCC dir: /System/Library/Frameworks
Caching GCC dir: /Library/Frameworks
Passing list of files to parse
Starting batch parsing
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
## 1. Install plugin: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
## Plugin for all users
## We want the file to be named like: OpenFrameworks.dylib
ExtractFile:
Plugin filename: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
Source filename: OpenFrameworks.dylib
Destination filename: /usr/local/bin/../share/codeblocks/plugins/OpenFrameworks.dylib
Extracting...
Extracted
## Returning true for: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
Extracted plugin
ExtractFile:
Plugin filename: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
Source filename: OpenFrameworks.zip
Destination filename: /usr/local/bin/../share/codeblocks/OpenFrameworks.zip
Extracting...
Extracted
## Returning true for: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
Extracted resources
ExtractFile:
Plugin filename: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
Source filename: OpenFrameworks.png
Destination filename: /usr/local/bin/../share/codeblocks/images/settings/OpenFrameworks.png
Extracting...
File not found in plugin
## Returning true for: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
Extracted resources
ExtractFile:
Plugin filename: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
Source filename: OpenFrameworks-off.png
Destination filename: /usr/local/bin/../share/codeblocks/images/settings/OpenFrameworks-off.png
Extracting...
File not found in plugin
## Returning true for: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
Extracted resources
## Start extracting files for: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
## Reloading/scanning plugins: /Users/diederick/Desktop/tmp/codeblocks_plugin/trunk/OpenFrameworks.cbplugin
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libastyle.so
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libautosave.so
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libclasswizard.so
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libcodecompletion.so
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libcompiler.so
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libdebugger.so
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libdefaultmimehandler.so
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libopenfileslist.so
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libprojectsimporter.so
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libscriptedwizard.so
## LoadPlugin: /usr/local/bin/../share/codeblocks/plugins/libtodo.so
Failed


Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Compiling plugin for Mac OSX
« Reply #7 on: October 13, 2009, 10:29:29 pm »
Okay found something!

- C::B searching for a file called "pluginname.dylib" and copies this to the plugins directory
- when starting C::B it searches for "pluginname.so" files in the plugin directory.

So I created a .so file using g++ -bundle and copied this to the plugin directory manually
and my plugin works!

I think the pluginmanager and cbplugin handling is not correct? Someone?

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Compiling plugin for Mac OSX
« Reply #8 on: October 14, 2009, 07:17:41 pm »
Okay found something!

- C::B searching for a file called "pluginname.dylib" and copies this to the plugins directory
- when starting C::B it searches for "pluginname.so" files in the plugin directory.

So I created a .so file using g++ -bundle and copied this to the plugin directory manually
and my plugin works!

I think the pluginmanager and cbplugin handling is not correct? Someone?

You are correct, and it is broken (doesn't know about bundles).
On the other platforms there is no difference between the two...

But on Mac OS X it needs to be .so (or .bundle) to be dlopened,
and .dylib (or .framework) in order to be dynamically linked (-l).

Code: Text
  1. #ifdef __WXMSW__
  2.     const wxString FileFilters::DYNAMICLIB_EXT           = _T("dll");
  3.     const wxString FileFilters::EXECUTABLE_EXT           = _T("exe");
  4.     const wxString FileFilters::NATIVE_EXT               = _T("sys");
  5. #elif __WXMAC__
  6.     const wxString FileFilters::DYNAMICLIB_EXT           = _T("dylib");
  7.     const wxString FileFilters::EXECUTABLE_EXT           = _T("");
  8.     const wxString FileFilters::NATIVE_EXT               = _T("");
  9. #else
  10.     const wxString FileFilters::DYNAMICLIB_EXT           = _T("so");
  11.     const wxString FileFilters::EXECUTABLE_EXT           = _T("");
  12.     const wxString FileFilters::NATIVE_EXT               = _T("");
  13. #endif
  14.  

Code: Text
  1.     ctLinkExeCmd,           ///< Link executable command, e.g. "$linker $libdirs -o $exe_output $link_objects $libs -mwindows"
  2.     ctLinkConsoleExeCmd,    ///< Link console executable command, e.g. "$linker $libdirs -o $exe_output $link_objects $libs"
  3.     ctLinkDynamicCmd,       ///< Link dynamic (dll) lib command, e.g. "$linker -shared -Wl,--output-def=$def_output -Wl,--out-implib=$static_output -Wl,--dll $libdirs $link_objects $libs -o $dynamic_output"
  4.     ctLinkStaticCmd,        ///< Link static lib command, e.g. "ar -r $output $link_objects\n\tranlib $static_output"
  5.     ctLinkNativeCmd,        ///< Link native binary command
  6.  

So it needs to grow something like "loadable lib" or "plugin",
that would have the same value as "dynamic lib" on the others.

It's not possible to have it do the right thing on Mac OS X,
if there is only one setting for "dynamic lib" (of both kinds).