mac-osx.txt 7.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
Compiling KiCad on Apple Mac OS X
=================================
 First written: 2010-01-31
Last edited by: Jerry Jacobs <xor.gate.engineering[at]gmail[dot]com>


Snow Leopard
------------

Requirements
  * XCode Tools    (http://developer.apple.com/tools/xcode)
12
  * bzr (bazaar)
13 14 15
  * CMake          (http://www.cmake.org)
  * wxWidgets 2.9  (http://www.wxwidgets.org/downloads)
  * Doxygen        (http://www.doxygen.nl)
16
  * ccache         (http://www.macports.org)
17 18


19 20 21 22
Building wxWidgets 2.9 Universal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To check if your tools and libraries are installed check with file for architectures.

23
user@macosx$ file /Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystem.dylib
24 25 26 27 28 29 30 31 32

/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystem.dylib: Mach-O universal binary with 4 architectures
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystem.dylib (for architecture ppc7400):	Mach-O dynamically linked shared library stub ppc
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystem.dylib (for architecture ppc64)Mach-O 64-bit dynamically linked shared library stub ppc64
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystem.dylib (for architecture i386):Mach-O dynamically linked shared library stub i386
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libSystem.dylib (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library stub x86_64

You need the architectures what you are compiling for !

33 34 35 36 37 38 39 40
If you have problems that the 64bits library is not build you should add in
the configure file:

At time of writing (2009-01-16) this is on line 18381
       changing this: OSX_UNIV_OPTS="-arch ppc -arch i386"
           into this: OSX_UNIV_OPTS="-arch ppc -arch i386 -arch x86_64"

Building a universal monolib wxWidgets 2.9 with the following parameters:
41
./configure --enable-unicode=yes --enable-shared=no --enable-monolithic --with-opengl --with-expat=builtin  --enable-universal_binary --enable-aui --enable-debug --with-osx_cocoa   --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk/ --prefix=/opt/wxwidgets/<rev>
42 43

<rev> Should be subsituded with the revision from SVN
44

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
Then you should a message like this:

Configured wxWidgets 2.9.2 for `i686-apple-darwin10.4.0'

  Which GUI toolkit should wxWidgets use?                 osx_cocoa
  Should wxWidgets be compiled into single library?       yes
  Should wxWidgets be linked as a shared library?         no
  Should wxWidgets support Unicode?                       yes (using UTF-8)
  What level of wxWidgets compatibility should be enabled?
                                       wxWidgets 2.6      no
                                       wxWidgets 2.8      yes
  Which libraries should wxWidgets use?
                                       STL                no
                                       jpeg               builtin
                                       png                builtin
                                       regex              builtin
                                       tiff               builtin
                                       zlib               sys
                                       expat              builtin
                                       libmspack          no
                                       sdl                no


If you don't need the debugging symbols then you can remove the --enable-debug parameter.
69 70 71 72 73 74

Compiling and installing:
make
sudo make install


75 76 77 78 79
Move the old Mac OS X wxconfig and symlink it to the new compiled 2.9

sudo mv /usr/bin/wx-config /usr/bin/wx-config.osx
sudo ln -s /opt/wxwidgets-svn/bin/wx-config /usr

80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
Building KiCad
~~~~~~~~~~~~~~
Extract the sources or get them from subversion.

user@mac-osx$ cmake .

Regarding Kicad the only things i've changed are the Variables
in the generated CMakeCache.txt

It depends on which CMake version you use:

//Flags used by the compiler during all build types.
//This fixes also BOOST macro errors
CMAKE_CXX_FLAGS:STRING=-D__ASSERTMACROS__

95
//Build architectures for OSX
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
CMAKE_OSX_ARCHITECTURES:STRING=x86_64 -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -mmacosx-version-min=10.5

//The product will be built against the headers and libraries located
// inside the indicated SDK.
CMAKE_OSX_SYSROOT:PATH=/Developer/SDKs/MacOSX10.5.sdk

//Minimum OS X version to target for deployment (at runtime); newer
// APIs weak linked. Set to empty string for default value.
CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5

Or:

CMAKE_OSX_ARCHITECTURE = x86_64 -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -mmacosx-version-min=10.5
CMAKE_OSX_SYSROOT = /Developer/SDKs/MacOSX10.5.sdk
CMAKE_CXX_FLAGS = -D__ASSERTMACROS__


Then we invoke make:
user@mac-osx$ make

116 117 118 119
It is also possible to give all the options on the commandline and not to edit the CMakeCache.txt. This is a oneliner for Leopard and up:

cmake ~/Repositories/testing -DKICAD_TESTING_VERSION=ON -DCMAKE_OSX_ARCHITECTURES="i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.6" -DCMAKE_CXX_FLAGS="-D__ASSERTMACROS__" -DCMAKE_OSX_SYSROOT="/Developer/SDKs/MacOSX10.6.sdk"

120 121 122 123 124 125 126 127 128
Optional compiler cache
~~~~~~~~~~~~~~~~~~~~~~~
If you (re)compile often, you would love to use cache. The best is to install it using macports and set the libexec symlink
directory of ccache in your PATH variable.

Then start with a clean directory and invoke cmake, make sure that the C++ compiler points to /opt/local/libexec/ccache/g++

Further reading at http://trac.macports.org/wiki/howto/ccache

129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
Known Problems
~~~~~~~~~~~~~~
In file included from
/temp/kicad-sources/boost_1_38_0/boost/ptr_container/detail/reversible_ptr_container.hpp:22In
file included from
/temp/kicad-sources/boost_1_38_0/boost/ptr_container/detail/reversible_ptr_container.hpp:22,
                     from
/temp/kicad-sources/boost_1_38_0/boost/ptr_container/ptr_sequence_adapter.hpp:20,
                     from
/temp/kicad-sources/boost_1_38_0/boost/ptr_container/ptr_vector.hpp:20,
                     from
/temp/kicad-sources/kicad/include/board_item_struct.h:9,
                     from /temp/kicad-sources/kicad/include/pcbstruct.h:10,
                     from /temp/kicad-sources/kicad/3d-viewer/3d_viewer.h:29,
                     from /temp/kicad-sources/kicad/3d-viewer/3d_aux.cpp:23:
    /temp/kicad-sources/boost_1_38_0/boost/ptr_container/detail/static_move_ptr.hpp:154:50:
error: macro "check" passed 2 arguments, but takes just 1

147 148 149 150 151 152
CMAKE_CXX_FLAGS = -D__ASSERTMACROS__ fixes this :-)


configure:18585: gcc -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -mmacosx-version-min=10.5 -o conftest -arch i386 -arch x86_64 -arch ppc   -arch i386 -arch x86_64 -arch ppc  conftest.c  >&5
ld: warning: in /Developer/SDKs/MacOSX10.5.sdk//usr/lib/libSystem.dylib, missing required architecture ppc in file

jerryjacobs's avatar
jerryjacobs committed
153 154 155 156 157 158
Installing rosetta and xcode with all architectures fixes this "problem"


ld: warning: in /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks//QuickTime.framework/QuickTime, missing required architecture x86_64 in file

You get this error because the QuickTime 10.6 framework is not build with 64bit support. This not a real issue for KiCad because we don't use it anyway.
159 160 161 162 163 164 165 166 167

Undefined symbols:
  "TestForIntersectionOfStraightLineSegments(int, int, int, int, int, int, int, int, int*, int*, double*)", referenced from:
      clipLine(EDA_Rect*, int&, int&, int&, int&)in libcommon.a(gr_basic.cpp.o)

Make sure you marked the build type Release:

//Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
// CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
168
CMAKE_BUILD_TYPE:STRING=Release