User forums > Using Code::Blocks

Building Code::Blocks with wxWidgets 2.6.1 on Mac OS X

(1/4) > >>

xjluo:
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:
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

--- End code ---

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

--- End code ---

maybe be the right thing to do

xjluo:
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:
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

xjluo:
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.

Navigation

[0] Message Index

[#] Next page

Go to full version