Skip to content

Instantly share code, notes, and snippets.

@nohal
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nohal/69d6780ee7513d0fea52 to your computer and use it in GitHub Desktop.
Save nohal/69d6780ee7513d0fea52 to your computer and use it in GitHub Desktop.
Building wxWidgets and OpenCPN on a Mac using Xcode 6.1, targeting OS X 10.7 and higher

Prerequisities

  • Xcode
  • Xcodelegacy script (https://github.com/devernay/xcodelegacy)
  • Legacy packages for Xcode (see above)
  • Homebrew (http://brew.sh)
  • brew install cmake
  • brew install gettext
  • symlinks to msgmerge and msgfmt from gettext's bin directory in /usr/local/bin
  • wxWidgets source
  • OpenCPN source

Environment

Xcode says: Version 6.1 (6A1052d)

knutintosh:wxWidgets-3.0.2 nohal$ g++ -v

Result:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
knutintosh:wxWidgets-3.0.2 nohal$ cc -v

Result:

Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
knutintosh:wxWidgets-3.0.2 nohal$ gcc -v

Result:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
knutintosh:Data nohal$ ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/

MacOSX10.10.sdk MacOSX10.9.sdk

Install the legacy SDKs

knutintosh:Data nohal$ ./XcodeLegacy.sh buildpackages

Takes time...

knutintosh:Data nohal$ sudo ./XcodeLegacy.sh install

Result:

Info: found Xcode >= 4.3
installed XcodePluginGCC40.tar.gz
installed XcodePluginGCC42.tar.gz
installed XcodePluginLLVMGCC42.tar.gz
installed XcodePPCas.tar.gz
installed Xcode3ld.tar.gz
installed Xcode104SDK.tar.gz
installed Xcode105SDK.tar.gz
installed Xcode106SDK.tar.gz
installed Xcode107SDK.tar.gz
installed Xcode108SDK.tar.gz
not installing xcode_3.2.6_gcc4.0.pkg (found installed in /usr/bin/gcc-4.0, uninstall first to force install)
not installing xcode_3.2.6_gcc4.2.pkg (found installed in /usr/bin/gcc-4.2, uninstall first to force install)
not installing xcode_3.2.6_llvm-gcc4.2.pkg (found installed in /usr/bin/llvm-gcc-4.2, uninstall first to force install)

Note: I already had the legacy stuff installed before in Xcode 6.0.1, which is the probable reason for the “not installed” messages

knutintosh:Data nohal$ ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/

MacOSX10.10.sdk MacOSX10.5.sdk MacOSX10.7.sdk MacOSX10.9.sdk MacOSX10.4u.sdk MacOSX10.6.sdk MacOSX10.8.sdk

Start building

wxWidgets

knutintosh:Data nohal$ cd ~/source/wxWidgets-3.0.2/
knutintosh:wxWidgets-3.0.2 nohal$ make distclean
knutintosh:wxWidgets-3.0.2 nohal$ ./configure --enable-unicode --with-osx-cocoa --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/ --with-macosx-version-min=10.7 --enable-aui --disable-debug --enable-opengl

Result:

...
Configured wxWidgets 3.0.2 for `x86_64-apple-darwin13.4.0'

  Which GUI toolkit should wxWidgets use?                 osx_cocoa
  Should wxWidgets be compiled into single library?       no
  Should wxWidgets be linked as a shared library?         yes
  Should wxWidgets support Unicode?                       yes (using wchar_t)
  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              sys
                                       libmspack          no
                                       sdl                no

knutintosh:wxWidgets-3.0.2 nohal$ make

Completes without errors:

...
/Users/nohal/source/wxWidgets-3.0.2/bk-deps g++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.7 -c -o wxrc_wxrc.o -D__WXOSX_COCOA__      -I. -DWXUSINGDLL -DwxUSE_GUI=0 -Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wno-deprecated-declarations -D_FILE_OFFSET_BITS=64 -DwxDEBUG_LEVEL=0 -I/Users/nohal/source/wxWidgets-3.0.2/lib/wx/include/osx_cocoa-unicode-3.0 -I../../include -DWX_PRECOMP -O2 -fno-strict-aliasing -fno-common  ./wxrc.cpp
g++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/ -mmacosx-version-min=10.7 -o wxrc wxrc_wxrc.o    -L/Users/nohal/source/wxWidgets-3.0.2/lib  -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL   -lwx_baseu_xml-3.0 -lexpat -lwx_baseu-3.0     -lwxregexu-3.0  -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL  -lz -lpthread -liconv  -lz -lpthread -liconv
Running ld for x86_64 ...
SetFile -t APPL wxrc
knutintosh:wxWidgets-3.0.2 nohal$ sudo make install

Completes without errors:

...
 ------------------------------------------------------
 
 The installation of wxWidgets is finished.  On certain
 platforms (e.g. Linux) you'll now have to run ldconfig
 if you installed a shared library and also modify the
 LD_LIBRARY_PATH (or equivalent) environment variable.
 
 wxWidgets comes with no guarantees and doesn't claim
 to be suitable for any purpose.
 
 Read the wxWindows Licence on licencing conditions.
 
 ------------------------------------------------------

OpenCPN

knutintosh:wxWidgets-3.0.2 nohal$ cd ~/source/OpenCPN/build
knutintosh:build nohal$ rm -rf *
knutintosh:build nohal$ export MACOSX_DEPLOYMENT_TARGET=10.7
knutintosh:build nohal$ cmake ..

Result:

-- The C compiler identification is AppleClang 6.0.0.6000054
-- The CXX compiler identification is AppleClang 6.0.0.6000054
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- *** Build Architecture is x86_64
-- *** Staging to build OpenCPN 3.3.2118 ***
-- *** Package will include documentation ***
-- *** Package will include GSHHS basechart level: CRUDE ***
-- *** Package will include tide and current data ***
-- Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/OpenGL.framework  
-- Found OpenGL...
--     Lib: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/AGL.framework/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/OpenGL.framework
--     Include: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/OpenGL.framework
-- Found wxWidgets: TRUE  
-- Found wxWidgets...
-- -L/usr/local/lib;;;-framework IOKit;-framework Carbon;-framework Cocoa;-framework AudioToolbox;-framework System;-framework OpenGL;-lwx_baseu-3.0;-lwx_osx_cocoau_core-3.0;-lwx_baseu_net-3.0;-lwx_baseu_xml-3.0;-lwx_osx_cocoau_html-3.0;-lwx_osx_cocoau_adv-3.0;-lwx_osx_cocoau_aui-3.0;-lwx_osx_cocoau_gl-3.0
-- 
-- *** Staging to build OpenCPN  ***
-- Build type: Release
-- *** Will install to /usr/local  ***
-- Found Gettext: /usr/local/bin/msgmerge (found version "0.19.2") 
-- Found BZip2: /usr/lib/libbz2.dylib (found version "1.0.6") 
-- Looking for BZ2_bzCompressInit in /usr/lib/libbz2.dylib
-- Looking for BZ2_bzCompressInit in /usr/lib/libbz2.dylib - found
-- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.5") 
-- Could NOT find TinyXML (missing:  TINYXML_INCLUDE_DIR TINYXML_LIBRARIES) 
-- tinyxml library not found
-- S57 ENC support: enabled
-- Garmin Host Mode support: enabled
-- Compiling texture compression library with sse support
-- 
-- *** Staging to build PlugIns ***
-- 
-- *** Staging to build dashboard_pi ***
-- *** Staging to build grib_pi ***
-- Writing spec file...
-- Configuring done
CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   dashboard_pi
   grib_pi

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/nohal/source/OpenCPN/build
knutintosh:build nohal$ make

Completes without errors:

...
[100%] Building CXX object plugins/grib_pi/CMakeFiles/grib_pi.dir/__/__/src/wxJSON/jsonwriter.cpp.o
Linking CXX shared library libgrib_pi.dylib
Running ld for x86_64 ...
[100%] Built target grib_pi
knutintosh:build nohal$ ./OpenCPN.app/Contents/MacOS/OpenCPN 

OpenCPN starts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment