Author Topic: Mac OS development  (Read 20520 times)

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Mac OS development
« Reply #15 on: January 26, 2010, 10:00:57 am »
If you use pch on mac, try to delete them manually and see if it works.

Precompiled headers is the default, yes, unless using --disable-pch.
(There's also an old bug that it keeps the .gch files in the source dir,
instead of in the proper build directories but I've patched that locally
as I'm doing Universal Binary builds and thus doing more than one build)

But it built with these modifications:
Code: svn diff
Index: src/sdk/wxscintilla/src/scintilla/src/ExternalLexer.h
===================================================================
--- src/sdk/wxscintilla/src/scintilla/src/ExternalLexer.h (revision 6113)
+++ src/sdk/wxscintilla/src/scintilla/src/ExternalLexer.h (arbetskopia)
@@ -14,6 +14,8 @@
 #define EXT_LEXER_DECL
 #endif
 
+#include <string>
+
 #ifdef SCI_NAMESPACE
 namespace Scintilla {
 #endif
Index: src/include/infowindow.h
===================================================================
--- src/include/infowindow.h (revision 6113)
+++ src/include/infowindow.h (arbetskopia)
@@ -26,6 +26,7 @@
     #include <wx/popupwin.h>
     typedef wxPopupWindow wxInfoWindowBase;
 #else
+    #include "scrollingdialog.h"
     typedef wxScrollingDialog wxInfoWindowBase;
 #endif
 
Index: src/plugins/contrib/wxSmith/propgrid/Makefile.am
===================================================================
--- src/plugins/contrib/wxSmith/propgrid/Makefile.am (revision 6113)
+++ src/plugins/contrib/wxSmith/propgrid/Makefile.am (arbetskopia)
@@ -1,4 +1,5 @@
 INCLUDES = $(WX_CXXFLAGS) \
+ -I$(top_srcdir)/src/include \
  -I$(srcdir)/contrib/include
 
 AM_CPPFLAGS = -DWXMAKINGLIB_PROPGRID -DwxPG_USE_WXMODULE=0
Index: src/plugins/contrib/wxSmith/propgrid/contrib/src/propgrid/odcombo.cpp
===================================================================
--- src/plugins/contrib/wxSmith/propgrid/contrib/src/propgrid/odcombo.cpp (revision 6113)
+++ src/plugins/contrib/wxSmith/propgrid/contrib/src/propgrid/odcombo.cpp (arbetskopia)
@@ -104,6 +104,7 @@
 #else
     #undef USE_TRANSIENT_POPUP
     #define USE_TRANSIENT_POPUP 0
+    #include "scrollingdialog.h"
 #endif
 
 // For versions < 2.6.2, don't enable transient popup. There may be

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Mac OS development
« Reply #16 on: January 26, 2010, 10:22:10 am »
But it built with these modifications:
...
Jens and I have committed the modification to trunk. Can you please try again?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Mac OS development
« Reply #17 on: January 26, 2010, 10:11:38 pm »
Hi Jens and others!

I finally build Codeblocks from source on a Mac 10.6.2!

1)
Though it can't get focus when I run it which is a wxWidgets problem because I did not create a bundle for my  codeblocks executable yet.  I'm reading about bundles but am I correct when I say that I can but libraries in the codeblocks.app/Contents/MacOS dir? And I've also seen the comment about this on http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Mac_OS_X#FYI:_Universal_Binaries where they use the install_name_tool. Now I'm wondering what this install_name_tool actually does and if there is a build/make script which does this for you in the Code::Blocks repository?

- snip -
2)
I just copied some things and created my own codeblocks.app directory and now I can run codeblocks!
Though it still crashes when I try to open the File > New Project wizard.  I haven't used the install_name_tool and Code::Blocks still runs, why?

3)
And in the CodeBlocks.app file I downloaded from www.codeblocks.org there are some Icon files in the bundle. Are they part of the repository?

Roxlu

Offline eranif

  • Regular
  • ***
  • Posts: 256
Re: Mac OS development
« Reply #18 on: January 26, 2010, 11:38:25 pm »
I haven't used the install_name_tool and Code::Blocks still runs, why?
Because all the paths exists under your local machine. AFAIR, the install_name_tool replaces the replaces the hard coded absolute path with something like

(Assuming you copies the dylib to be located under the same path as the exe)
Code
install_name_tool -change /some/abs/path/wx-some-dylib @executable_path/wx-some-dylib ${file}

but since you compiled the binary on your machine the absolute paths will work OK as well - but they will probably fail on another Mac machine

Eran

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Mac OS development
« Reply #19 on: January 27, 2010, 09:31:20 am »
Hi Jens and others!

I finally build Codeblocks from source on a Mac 10.6.2!

Congratulations :-) As you might have noticed I'm using the 10.4u SDK for portability.

Quote
1)
Though it can't get focus when I run it which is a wxWidgets problem because I did not create a bundle for my  codeblocks executable yet.  I'm reading about bundles but am I correct when I say that I can but libraries in the codeblocks.app/Contents/MacOS dir?

Yeah, this is a generic problem with Mac OS X and not something specific to wxWidgets. For instance when you are running a Python program that wants an Aqua graphic user interface you have to use "pythonw" (which is a symlink into such a bundle) rather than just "python" which is a regular program. There's some hacks around it (as noted on the Wiki page), but the "easiest" (only supported) way is to make an app bundle. BTW, it should be called "CodeBlocks.app" as you are now allowed case sensitivity...

Quote
And I've also seen the comment about this on http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Mac_OS_X#FYI:_Universal_Binaries where they use the install_name_tool. Now I'm wondering what this install_name_tool actually does and if there is a build/make script which does this for you in the Code::Blocks repository?

The install_name_tool part is so that it can run from /Developer/Applications or ~/Applications or wherever the user wants it, instead of having to be installed under /usr/local which is hidden by the Finder and thus most users. There is a build script that does it, but not in the repository (yet) - at least not the latest version. I'll try to put it up after the next "nightly", when I've fixed some extra helper libraries needed by wxSmith.

Quote
- snip -
2)
I just copied some things and created my own codeblocks.app directory and now I can run codeblocks!
Though it still crashes when I try to open the File > New Project wizard.  I haven't used the install_name_tool and Code::Blocks still runs, why?

Presumably it can still find some things in /usr/local ? You'll need to copy the resources into the bundle, though.

Quote
3)
And in the CodeBlocks.app file I downloaded from www.codeblocks.org there are some Icon files in the bundle. Are they part of the repository?

The icons are hidden under ./src/src/resources/*.icns. They need to be located in Resources in the app bundle.

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Mac OS development
« Reply #20 on: January 27, 2010, 07:12:46 pm »
Hi afb,

Thanks for your clear answer! Could you maybe share the script witch creates the bundle?
Though i'm not sure if I can use it as I'm compiling against a local (as in same directory and not the default installation in /usr/local/...) wxWidgets installation. If I understood it correctly I can use the install_name_tool to tell MacOS to use the libs in the MacOS directory of application bundle?

Thanks
roxlu
« Last Edit: January 27, 2010, 07:14:27 pm by roxlu »

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Mac OS development
« Reply #21 on: January 28, 2010, 09:39:11 am »
Thanks for your clear answer! Could you maybe share the script witch creates the bundle?

Will do, just have to clear it up a bit for general use and add the wxSmithContribItems directory...

Quote
Though i'm not sure if I can use it as I'm compiling against a local (as in same directory and not the default installation in /usr/local/...) wxWidgets installation. If I understood it correctly I can use the install_name_tool to tell MacOS to use the libs in the MacOS directory of application bundle?

Sure, I can change it to use two different prefixes for wxWidgets and for Code::Blocks, if needed.

Currently I'm using /usr/local for all the "before", but it does use @executable_path for the "after"...
Then Mac OS X will replace this magic string with the current value for the executable's directory.

This is similar to using GetModuleFilename on Windows or BinReloc on Linux, to make relocatable apps.

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Mac OS development
« Reply #22 on: January 28, 2010, 10:03:32 am »
Hi Afb!

Great! I cant wait to try out your script! Then I'll finally have a nice clean build environment for C::B on Mac! I think
lot's of people will enjoy using the newest version from SVN! I'm using the openFrameworks libraries (www.openframeworks.cc) which has a quite big community. Most of the users of openFrameworks will love a stable C::B on Mac!

Roxlu

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Mac OS development
« Reply #23 on: January 30, 2010, 10:37:23 am »
Afb, could you maybe upload the script which creates the CodeBlocks.app file for Mac?

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Mac OS development
« Reply #24 on: January 31, 2010, 12:53:35 pm »
Hi everyone!

I'm almost done with compiling Code::Blocks from svn (so from source and the latest version) from mac and create an application bundle form it. There are still two strange things :

1) When I compile C::B against my custom build of wxWidgets 2.8, and everything is ready, I see,using "otool -L bin/codeblocks" that the libwx_macu_**.dylib to which is linked is / usr/local/lib/libwx_macu... which is strange as I specified '--with-wxdir' and '--with-wx-config' to be pointing to my custom build.

2) Although C::B links to my system installation of wxWidgets I can run C::B w/o problems. The only thing which is strange, is that when I want to create a new project, I don't see any projects (or icons) in the project type selection window. Why is that?

Thanks,
Roxlu

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Mac OS development
« Reply #25 on: February 01, 2010, 06:01:55 pm »
Afb, could you maybe upload the script which creates the CodeBlocks.app file for Mac?

Sent as a PM, haven't gotten time to update it for wxContribItems just yet.

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
Re: Mac OS development
« Reply #26 on: February 05, 2010, 10:40:22 pm »
Hi everyone!,

I finally finished the script I was working on. When you run it, you'll be asked a couple of questions.  You need to download the svn versions of codeblocks and wxwidgets once before you can do anything.

It will compile wxWidgets for Mac 10.6 (with XCode installed previously) and C::B with all plugins (this will take a while). When everyting has been build it will create an application bundle and reset all the dynamic link locations using install_name_tool.

There is only one tiny thing left. When I try to create a new project, there are no projects to select from? (no icons maybe??)  
update: Everything works now! I've got all the plugins!



The script can be found here:
note that it's create for my needs and needs to be tested/tweaked when other people want to use it.

Code
#!/bin/sh
#set -x
root_dir=${PWD}

if [ -d wxwidgets_svn ]
then
read -p "Remove wxWidgets 2.8 directory to start clean install? [y/n]: " continue
if test "${continue}" == "y" ; then
rm -r wxwidgets_svn
mkdir wxwidgets_svn
fi
else
mkdir wxwidgets_svn
fi

if [ -d codeblocks_svn ]
then
read -p "Remove CodeBlocks directory to start clean install? [y/n]: " continue
        if test "${continue}" == "y";  then
                rm -r codeblocks_svn
                mkdir codeblocks_svn
        fi
else
mkdir codeblocks_svn
fi

read -p "Download CodeBlocks from svn? [y/n]: " continue
if test "${continue}" == "y"; then
cd codeblocks_svn
svn co http://svn.berlios.de/svnroot/repos/codeblocks/trunk .
cd ..
fi

read -p "Download wxWidgets 2.8 from svn? [y/n]: " continue
if test "${continue}" == "y"; then
cd wxwidgets_svn
svn co http://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH .
fi


#------------------------- wxWidgets ---------------------------------------
read -p "Configure wxWidgets 2.8? [y/n]: " continue
if test "${continue}" == "y"; then
if [ ! -d ${root_dir}/wxwidgets_svn ]; then
echo "No wxWidgets directory found"
exit
fi

cd ${root_dir}/wxwidgets_svn
if [ -d build_custom ]; then
rm -r build_custom
fi

mkdir build_custom
cd build_custom
./../configure --enable-shared \
--enable-monolithic \
--enable-unicode \
--with-png=builtin \
--with-jpeg=builtin \
--with-tiff=builtin \
--with-expat=builtin/configure \
--enable-shared \
--enable-monolithic \
--enable-unicode \
--with-mac \
--with-expat=builtin \
CFLAGS="-arch i386" CXXFLAGS="-arch i386" CPPFLAGS="-arch i386" \
LDFLAGS="-arch i386" OBJCFLAGS="-arch i386" OBJCXXFLAGS="-arch i386"
fi

read -p "Compile wxWidgets 2.8 [y/n]: " continue
if test "${continue}" == "y"; then
cd ${root_dir}/wxwidgets_svn/build_custom
make
fi

read -p "Bootstrap Code::Blocks [y/n]: " continue
if test "${continue}" == "y"; then
cd ${root_dir}/codeblocks_svn
./bootstrap
fi

read -p "Configure Code::Blocks [y/n]: " continue
if test "${continue}" == "y"; then
if [ ! -d ${root_dir}/codeblocks_svn ]; then
echo "No CodeBlocks directory found"
exit
fi

cd ${root_dir}/codeblocks_svn

if [ -d custom_build ]; then
rm -r custom_build
fi

mkdir custom_build
cd custom_build
./../configure \
--prefix=${root_dir}/codeblocks_svn/custom_build/ \
--with-wxdir=./../../wxwidgets28_from_svn/custom_build/ \
CFLAGS="-arch i386" CXXFLAGS="-arch i386" \
CPPFLAGS="-arch i386" LDFLAGS="-arch i386" \
OBJCFLAGS="-arch i386" \
OBJCXXFLAGS="-arch i386" \
--with-contrib-plugins=all \
--enable-static \
--enable-debug \
--with-macosx \
--with-wxdir=${root_dir}/wxwidgets_svn/build_custom/ \
--with-wx-config=${root_dir}/wxwidgets_svn/build_custom/wx-config \
--with-wx-prefix=${root_dir}/wxwidgets_svn/build_custom/
fi

read -p "Compile and make Code::Blocks [y/n]: " continue
if test "${continue}" == "y"; then
cd ${root_dir}/codeblocks_svn/custom_build
make
fi

read -p "Create CodeBlocks.app bundle? [y/n]: " continue
if test "${continue}" == "y"; then
if [ -d ${root_dir}/app/CodeBlocks.app ]; then
read -p "An Codeblocks.app bundle already exists, remove first? [y/n]: " continue
if test "${continue}" == "y"; then
rm -r ${root_dir}/app/CodeBlocks.app
fi
fi

app_dir=${root_dir}/app/CodeBlocks.app
cb_dir=${root_dir}/codeblocks_svn
wx_dir=${root_dir}/wxwidgets_svn

mkdir -p ${app_dir}/Contents/MacOS
mkdir -p ${app_dir}/Contents/Resources/share/codeblocks
cp ${cb_dir}/custom_build/codeblocks.plist ${app_dir}/Contents/Info.plist
cp ${cb_dir}/src/src/resources/icons/*.icns ${app_dir}/Contents/Resources/
cp -r ${cb_dir}/custom_build/share/codeblocks/* ${app_dir}/Contents/Resources/share/codeblocks/
cp ${cb_dir}/custom_build/bin/codeblocks ${app_dir}/Contents/MacOS/CodeBlocks
cp ${cb_dir}/custom_build/lib/libcodeblocks.0.dylib ${app_dir}/Contents/MacOS/
cp ${cb_dir}/custom_build/lib/libwxsmithlib.0.dylib ${app_dir}/Contents/MacOS/
cp ${wx_dir}/build_custom/lib/libwx_macu-2.8.0.dylib ${app_dir}/Contents/MacOS/
chmod 777 ${app_dir}/Contents/MacOS/CodeBlocks
fi

read -p "Change dynamic lib paths? [y/n]: " continue
if test "${continue}" == "y"; then

# copy the plugins
cd ${root_dir}/codeblocks_svn/custom_build/src/plugins
mkdir -p ${root_dir}/app/CodeBlocks.app/Contents/Resources/share/codeblocks/plugins/
for dir in `find -type d . -mindepth 1 -maxdepth 1`; do
        name=${dir##*/}
        plugin=${root_dir}/codeblocks_svn/custom_build/src/plugins/${name}/.libs/lib${name}.so
        if [ -f ${plugin} ]; then
                cp ${plugin} ${root_dir}/app/CodeBlocks.app/Contents/Resources/share/codeblocks/
        fi
done

cd ${root_dir}/app/CodeBlocks.app/Contents
install_name_tool -id @executable_path/libcodeblocks.0.dylib MacOS/libcodeblocks.0.dylib
install_name_tool -id @executable_path/libwxsmith.0.dylib MacOS/libwxsmithlib.0.dylib

  install_name_tool -change ${root_dir}/codeblocks_svn/custom_build/lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib MacOS/CodeBlocks
install_name_tool -change ${root_dir}/codeblocks_svn/custom_build//lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib MacOS/CodeBlocks
  install_name_tool -change /usr/local/lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib MacOS/libwxsmithlib.0.dylib
install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib MacOS/CodeBlocks
install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib MacOS/libcodeblocks.0.dylib
install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib MacOS/libwxsmithlib.0.dylib

for so in Resources/share/codeblocks/*.so; do
      libcodeblocks=$(otool -L ${so} | grep libcodeblocks)
      libcodeblocks=${libcodeblocks%%(*}
      install_name_tool -change ${libcodeblocks} @executable_path/libcodeblocks.0.dylib ${so}
     
      libwxsmith=$(otool -L ${so} | grep libwxsmithlib)
      libwxsmith=${libwxsmith%%(*}
      if test "${libwxsmith}" != ""; then
      install_name_tool -change ${libwxsmith} @executable_path/libwxsmithlib.0.dylib ${so}
      fi
     
      libwx=$(otool -L ${so} | grep libwx_macu)
      libwx=${libwx%%(*}
      if test "${libwx}" != ""}; then
      install_name_tool -change ${libwx} @executable_path/libwx_macu-2.8.0.dylib ${so}
      fi
     
#install_name_tool -change /usr/local/lib/libcodeblocks.0.dylib @executable_path/libcodeblocks.0.dylib ${so}
#install_name_tool -change /usr/local/lib/libwxsmithlib.0.dylib @executable_path/libwxsmithlib.0.dylib ${so}
#install_name_tool -change /usr/local/lib/libwx_macu-2.8.0.dylib @executable_path/libwx_macu-2.8.0.dylib ${so}
done
fi


Roxlu
« Last Edit: February 06, 2010, 12:31:33 pm by roxlu »