Author Topic: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X  (Read 17537 times)

xjluo

  • Guest
Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« on: September 02, 2005, 03:18:51 am »
Dear all,

I got my Code::Blocks running on an iBook G4 with Mac OS X. Here are the steps I had done on my iBook.

Requirements:
wxWidgets: 2.6.1 (Mac version named wxMac-2.6.1, you can download it at: http://prdownloads.sourceforge.net/wxwindows/wxMac-2.6.1.tar.gz )
Code::Blocks: tarball version 1.0-RC1-1 (You can download it at: http://prdownloads.sourceforge.net/codeblocks/codeblocks-1.0-rc1-1.tar.gz?download )
XCode: 2.0 (You can download it at Apple Developer Corner)

1. Download & compiling wxWidgets 2.6.1
   > Download wxMac-2.6.1.tar.gz and decompress it with:
       tar xvfz wxMac-2.6.1.tar.gz
   > Change to the wxMac-2.6.1 directory, make a sub-directory named build:
       cd wxMac-2.6.1
       mkdir build
   > Run configurate script:
       ../configure --with-mac --with-opengl --enable-xrc --enable-monolithic
   > Build wxMac libraries and install it with:
       make
       sudo make install
   > Build the contribute library and install it:
       cd contrib
       make
       sudo make install
   with these steps, you will install wxMac libraries and header files into /usr/local.

2. Download & building Code::Blocks
   > Download the tarball version of Code::Blocks from the website and decompress it with:
       tar xvfz codeblocks-1.0-rc1.tar.gz
   > Backup Makefile.unix.wx2.6 and then edit it as next steps;
   > Insert variable defination at the beginning:
=================================BEGIN===============================
MAC_CXXFLAGS = -DWX_PRECOMP -DNO_GCC_PRAGMA -D_FILE_OFFSET_BITS=64 \
          -D_LARGE_FILES `wx-config --cxxflags` \
          -O2 -Wall -Wno-ctor-dtor-privacy -fno-common \
          -fpascal-strings -I/Developer/Headers/FlatCarbon
MAC_LDFLAGS = `wx-config --libs` \
         -framework QuickTime -framework IOKit -framework Carbon \
         -framework Cocoa -framework System -framework WebKit \
         -lz -lpthread -liconv
MACDLL_CXXFLAGS = -dynamic -fPIC
MACDLL_LDFLAGS = -dynamiclib -single_module -headerpad_max_install_names
==================================END================================
   > Replace tinyXML_PROJECT_CFLAGS, src_PROJECT_CFLAGS, update_PROJECT_CFLAGS, doc_PROJECT_CFLAGS value with $(MAC_CXXFLAGS)
   > Replace sdk_PROJECT_CFLAGS, plugin_????_PROJECT_CFLAGS value with $(MAC_CXXFLAGS) $(MACDLL_CXXFLAGS)
   > Replace tinyXML_PROJECT_LDFLAGS, src_PROJECT_LDFLAGS, update_PROJECT_LDFLAGS, doc_PROJECT_LDFLAGS value with $(MAC_LDFLAGS)
   > Replace sdk_PROJECT_LDFLAGS, plugin_????_PROJECT_LDFLAGS value with $(MAC_LDFLAGS) $(MACDLL_LDFLAGS)
   > Append $(plugin_????_PROJECT_LDFLAGS) to all plugin_????_LDFLAGS variables (variable for ToDo and XPManifest plugin have already been appended)
   > Replace all wx_gtk2_stc with wx_mac_stc
   > Replace all .so with .dynalib
   > Remove all -shared
   > Insert line:
#include <wx/wx.h>
     before all other header files in sdk/editmanager.cpp sdk/messagemanager.cpp sdk/newfromtemplatedlg.cpp sdk/projectmanager.cpp
   > Insert line:
#include <wx/image.h>
     behind line:
#include <wx/notebook.h>
     in file src/app.cpp
   > Open sdk/editorbase.cpp in an editor, comment line 93~94:
    if (mypage != -1)
        Manager::Get()->GetEditorManager()->GetNotebook()->SetPageText(mypage, newTitle);
NOTE: these two lines will cause crash!
   > Now, you can make all with:
     make -f Makefile.unix.wx2.6
   > Convert update to unix format. You can use an editor (e.g. TextWrangler) to do the conversion. Open update in editor, replace all .so with .dylib, comment all 3 strip command line, then save it in unix format named update.unix .
   > Run commands:
     chmod +x update.unix
     ./update.unix
   > Sun is rising, :) . Let's do the final steps!
     cd output
     mkdir devel
     mv libcodeblocks.dylib devel
     `wx-config --rezflags` codeblocks.exe
     ./codeblock.exe

Aha, what do you find?

A modified version of Makefile and update are attached. You have to do the source modification by your self. Good luck!  :lol:
Though Code::Blocks can run on Mac OS X now, it's useless with following bugs, :(
Windows layout is mixed up.
Plugins can not be recognized.


[attachment deleted by admin]

grv575

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #1 on: September 02, 2005, 04:12:11 am »
If you want to try hacking the source again:

sdk\pluginmanager.cpp:96
Code
#ifdef __WXMSW__
#define PLUGINS_MASK _T("*.dll")
#else
#define PLUGINS_MASK _T("*.so")
#endif

which may explain plugins not loading...

wx-config --cflags will give you the right #define (probably __WXMAC__)
so:
Code
#ifdef __WXMSW__
#define PLUGINS_MASK _T("*.dll")
#elifdef __WXGTK__
#define PLUGINS_MASK _T("*.so")
#elifdef __WXMAC__
#define PLUGINS_MASK _T("*.dylib")
#endif

maybe be the right thing to do
« Last Edit: September 02, 2005, 04:18:59 am by grv575 »

xjluo

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #2 on: September 02, 2005, 04:32:09 am »
Yes. I think it's necessary. I tried it, but, it can not solve the plugin problem.

I think that I have not found the proper setting/option to compile dynamic library on Mac. I should do it from a simple program.  :?

grv575

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #3 on: September 02, 2005, 04:59:17 am »
Try removing that -dynamic* stuff and using -module to link.  guess mixing -single-module and -dynamiclib doesn't work too well...

http://64.233.167.104/search?q=cache:SxZyfGZ5oIMJ:trac.xiph.org/cgi-bin/trac.cgi/ticket/244+dynamic+library+mac&hl=en&client=firefox-a

Not sure if it should be compile with or without -fPIC btw

edit: actually before trying to build modules instead, try setting the run.sh script to set
DYLD_LIBRARY_PATH instead of  LD_LIBRARY_PATH.  Maybe it just can't find them...
http://64.233.167.104/search?q=cache:hMZTmkPjC2gJ:wiki.tcl.tk/2923+dynamic+library+mac&hl=en&client=firefox-a

edit: also if you want to get proper linker flags for dynamic libs then maybe download one of the packages listed in the following url and pass the --shared ./configure flag.  when you make it should give you which flags it uses...
http://64.233.167.104/search?q=cache:VwM33WOkf24J:www.paginar.net/matias/articles/gd_x_howto.html+dynamic+library+mac&hl=en&client=firefox-a
« Last Edit: September 02, 2005, 05:07:13 am by grv575 »

xjluo

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #4 on: September 02, 2005, 05:17:05 am »
Yes, rename LD_LIBRARY_PATH to DYLD_LIBRARY_PATH can sovle the path for libcodeblocks.dylib.

Sorry, I can not visit site 64.233.167.104

I will try later.

grv575

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #5 on: September 02, 2005, 05:21:46 am »

TheWizzard

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #6 on: September 02, 2005, 03:04:21 pm »
I get "Failed to load: <plugin> (Error 9: Bad File Descriptor)"

grv575

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #7 on: September 02, 2005, 06:52:23 pm »
Well my feeling is that it should work (to test try changing sdk\pluginmanager:ScanForPlugins()
Code
#ifdef __WXMSW__
#define PLUGINS_MASK _T("*.dll")
#else
#define PLUGINS_MASK _T("*.so")
#endif
to
Code
	#define PLUGINS_MASK _T("*.dylib")

then make clean and make.  The relevant code is all under sdk/pluginmanager.cpp
Code
int PluginManager::ScanForPlugins(const wxString& path)
void PluginManager::LoadAllPlugins()
cbPlugin* PluginManager::LoadPlugin(const wxString& pluginName)

The library calls:
Code
    wxDynamicLibrary* lib = new wxDynamicLibrary();
    lib->Load(pluginName);

and wx ref seems to support .dylib files...
http://www.wxwidgets.org/manuals/2.6.1/wx_wxdynamiclibrary.html

takeshimiya

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #8 on: September 05, 2005, 11:55:50 am »
Hi! I've noticed that the C::B CVS HEAD version still uses wxDockit 2.01

You'll probably want to compile C::B HEAD rather than VERSION_1 for Mac OS X, as it supports UNICODE, bug fixes, etc.

But wxDockit 2.01 is stopping that because it isn't unicode aware.

So my suggestion is to update to the latest wxDockit (wxDockit 2.1) as it fixes some bugs, supports better wx2.6, and have UNICODE support.

Here are some instructions on how to replace 2.01 with 2.1

Get wxDockit 2.1 from here.

macsmac

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #9 on: November 02, 2005, 09:20:50 pm »
hello,

gives there a good working "how to" compile C::B on Mac OS X for dummies?
I want to use wxWidgets for my next projects but I don't know enought abour make files and editing the C::B source code to make it work on a Mac :(
thnaks for your help.

regards,

MR

takeshimiya

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #10 on: November 02, 2005, 11:36:15 pm »
No one has got working 100% C::B in Mac OS X yet. Unfortunately there are very few users here have access to that OS.

takeshimiya

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #11 on: November 21, 2005, 03:04:14 am »
What's the current state of the Mac OS X port of Code::Blocks?
It works with the new build system?

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #12 on: February 22, 2006, 11:25:10 am »
A Mac snapshot is now in the download area of BerliOS.

Some info on how it was built can be found here:
http://wiki.codeblocks.org/index.php?title=Compiling_Code::Blocks_in_Mac_OS_X
(under construction, a few patches/details are missing)

And yes, it still has major problems with layout/plugins.

takeshimiya

  • Guest
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #13 on: February 22, 2006, 12:05:36 pm »
And yes, it still has major problems with layout/plugins.

About plugins, have you read this thread (and other threads -previous atempts to get C::B in MacOS X working) ?
Specially the part about
Code: cpp
#define PLUGINS_MASK _T("*.dylib")
and so.

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X
« Reply #14 on: February 22, 2006, 12:56:38 pm »
Yes, and working on getting anything beyond CALL_GENERIC
working in AngelScript for Darwin... (ideally both PPC / X86)

Plugins should definitely not have a ".dylib" suffix, but either
a ".so" (same as Linux) or preferrably a ".bundle" suffix...

Mac OS X differs between "shared libraries" and "loadable libraries".
Thus, wxWidgets and libcodeblocks are dylib while plugins are bundle.


Here is the "file" info for them:

Code
bin/codeblocks: Mach-O executable ppc

lib/libcodeblocks.0.0.1.dylib:  Mach-O dynamically linked shared library ppc
lib/libwxscintilla.0.0.1.dylib: Mach-O dynamically linked shared library ppc

share/codeblocks/plugins/libastyle.so:             Mach-O bundle ppc
share/codeblocks/plugins/libclasswizard.so:        Mach-O bundle ppc
share/codeblocks/plugins/libcodecompletion.so:     Mach-O bundle ppc
share/codeblocks/plugins/libcompiler.so:           Mach-O bundle ppc
share/codeblocks/plugins/libdebuggergdb.so:        Mach-O bundle ppc
share/codeblocks/plugins/libdefaultmimehandler.so: Mach-O bundle ppc
share/codeblocks/plugins/libpluginwizard.so:       Mach-O bundle ppc
share/codeblocks/plugins/libtodo.so:               Mach-O bundle ppc