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]
If you want to try hacking the source again:
sdk\pluginmanager.cpp:96
#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:
#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
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. :?
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
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.
Oh sorry, those are the ips I get for google cache. Real addresses:
http://trac.xiph.org/cgi-bin/trac.cgi/ticket/244
http://wiki.tcl.tk/2923
http://www.paginar.net/matias/articles/gd_x_howto.html
I get "Failed to load: <plugin> (Error 9: Bad File Descriptor)"
Well my feeling is that it should work (to test try changing sdk\pluginmanager:ScanForPlugins()
#ifdef __WXMSW__
#define PLUGINS_MASK _T("*.dll")
#else
#define PLUGINS_MASK _T("*.so")
#endif
to
#define PLUGINS_MASK _T("*.dylib")
then make clean and make. The relevant code is all under sdk/pluginmanager.cpp
int PluginManager::ScanForPlugins(const wxString& path)
void PluginManager::LoadAllPlugins()
cbPlugin* PluginManager::LoadPlugin(const wxString& pluginName)
The library calls:
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
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 (http://wiki.codeblocks.org/index.php/Compiling_wxWidgets_2.6.1_to_develop_Code::Blocks_%28MSW%29#Building_codeblocks_from_source_.28using_makefile.29) are some instructions on how to replace 2.01 with 2.1
Get wxDockit 2.1 from here (http://prdownloads.sourceforge.net/wxextended/wxDockIt_2.1.zip?download).
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
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.
What's the current state of the Mac OS X port of Code::Blocks?
It works with the new build system?
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.
Quote from: afb on February 22, 2006, 11:25:10 AM
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
#define PLUGINS_MASK _T("*.dylib")and so.
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:
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
I have done some research on this and here is the apple developer page on there dynamic loader (http://developer.apple.com/documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html) for OS X. Here is the page on dlopen (http://developer.apple.com/documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html#//apple_ref/doc/uid/TP40001398-CH1g-BAJJDAGC). It appears you can use this on either dynamic libraries or bundles with dlopen. So you should just be able load the bundles with the properly specified mode.
EDIT: I realized that you probably realized this, so are the pluggins working?
Quote from: Game_Ender on February 27, 2006, 12:31:42 AM
I have done some research on this and here is the apple developer page on there dynamic loader (http://developer.apple.com/documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html) for OS X. Here is the page on dlopen (http://developer.apple.com/documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html#//apple_ref/doc/uid/TP40001398-CH1g-BAJJDAGC). It appears you can use this on either dynamic libraries or bundles with dlopen. So you should just be able load the bundles with the properly specified mode.
Plugin code-loading should be OK, for versions before Mac OS X 10.4 there is dlcompat (http://www.opendarwin.org/projects/dlcompat/) -
Apple only mention the latest and greatest stuff as usual (where dlopen is new for Tiger)
AngelScript needs a few more calling conventions for Darwin (ppc/x86),
as not all the plugins use GENERIC ? (at least that is how I understand it)