KiCad OS X nightly development builds are back

After about eight months of not running I have fixed my nightly builds of KiCad for OS X. I have finally found the time to switch my KiCad repository over to the Bazaar and launchpad system that the KiCad developers have been using for some time now.

After a few changes here and there and updating wxWidgets to 2.9.1 I have the nightly build system back up and running. The build script I am using is given at the end of this post in Listing 4.

The KiCad compiling instructions for OS X have been updated and now work a lot better. You should be able to find the latest version over at launchpad here.

In case anyone else runs into similar problems I have repeated some of the errors and my hacks/work-arounds solutions below.

The nightly builds themselves are here as usual.

Getting it to compile again.

After following the compilation instructions referred to above, I ran into the following error. After a bit of web crawling and reading development lists I found that I needed to use the XML library built into wxWidgets rather than the system one.

The error looked like this:

Linking CXX executable eeschema.app/Contents/MacOS/eeschema
Undefined symbols:
“_XML_GetErrorCode”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_ErrorString”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetUnknownEncodingHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetCharacterDataHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetUserData”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_ParserFree”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetCdataSectionHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetCommentHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_Parse”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetElementHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_ParserCreate”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_GetCurrentLineNumber”, referenced from:
_StartCdataHnd in libwx_osx_cocoau-2.9.a(monolib_xml.o)
_CommentHnd in libwx_osx_cocoau-2.9.a(monolib_xml.o)
_TextHnd in libwx_osx_cocoau-2.9.a(monolib_xml.o)
_StartElementHnd in libwx_osx_cocoau-2.9.a(monolib_xml.o)
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
“_XML_SetDefaultHandler”, referenced from:
wxXmlDocument::Load(wxInputStream&, wxString const&, int)in libwx_osx_cocoau-2.9.a(monolib_xml.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [eeschema/eeschema.app/Contents/MacOS/eeschema] Error 1
make[1]: *** [eeschema/CMakeFiles/eeschema.dir/all] Error 2
make: *** [all] Error 2

Error 1: Missing XML library

This was fixed by adding the --with-expat=builtin option when configuring wxWidgets.

This then lead me to another error to do with wxWidgets headers using anonymous enums and anonymous types. Part of this second error is shown below.

/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h: In member function ‘bool wxComboPopup::IsCreated() const’:
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: ‘‘ is/uses anonymous type
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: trying to instantiate ‘template struct boost::polygon::is_polygon_90_set_type’
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: ‘‘ is/uses anonymous type
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: trying to instantiate ‘template struct boost::polygon::is_polygon_45_or_90_set_type’
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: ‘‘ is/uses anonymous type
/opt/wxwidgets-svn/include/wx-2.9/wx/combo.h:774: error: trying to instantiate ‘template struct boost::polygon::is_any_polygon_set_type’
make[2]: *** [gerbview/CMakeFiles/gerbview.dir/class_gerber_draw_item.cpp.o] Error 1
make[1]: *** [gerbview/CMakeFiles/gerbview.dir/all] Error 2
make: *** [all] Error 2

Error 2: Anonymous enums using anonymous types being marked as errors by the compiler

Rather than figure out which flag to set on the cmake/compiler/linker mess, I went for a brute-force approach that I found here after a small amount of searching. I have expanded from the script given to the ones below to account for the particular style used in the wxWidgets header files.

for i in `grep -l ‘enum {‘ *.h | sed -e ‘s/\.h//g’` ; \
do \
perl -pi -e \
“s/enum {/’enum en_$i’ . int(rand(100)) .’ {‘/eg” $i.h; \
done

Listing 1: Small script to replace all occurances of “enum {” with “enum en_filenameXX {“

Listing 1 is the original script given which enumerates the anonymous enums with a name consisting of the filename (without the extension) and a random number from 0-99.

This next command I adapted from the first to account for the fact that the style of the wxWidgets header files meant that a lot of the enums were declared with the keyword enum alone on a line with the rest of the declaration on the following line. This finds those declarations and assigns them a name similar to the first script but with a number from 100-199 to ensure we don’t repeat names already given. It is shown below in Listing 2.

for i in `grep -l ‘^enum en_.*$’ *.h | sed -e ‘s/\.h//g’` ;\
do \
perl -pi -e \
“s/^enum$/’enum en_$i’ . int(rand(100)+100) .”/eg” $i.h;\
done

Listing 2: Small script to replace all occurrences of “enum” with “enum en_filename1XX ” where “enum” occurs by itself on a line and assuming the rest of the declaration continues on the following line.

The problem with the previous two scripts is that they use a random number to assign the unique identifier. Being random there is the possibility that this number can come up twice.
This last command (Listing 3) helps us check for duplicate names generated by the previous scripts. We then need to go in and fix the duplicates by hand.

grep ‘enum en’ *.h | sort | uniq -c | sort -n

Listing 3: Command to check for duplicate names created by previous two scripts.

A single script could be written to give unique identifiers to all the anonymous enums and ensure that the identifiers are unique. But as this was a quick enough process and solved my problems I haven’t bothered to refine it further. Perhaps next time I update wxWidgets I’ll give it another thought. I thought this was a useful enough hack to share.

Automating the builds

Listing 4 below shows my daily build script which automatically updates the code to the latest development snapshot via Bazaar. Next it will check if the version has changed and if so build and package the latest version. If this all goes well we compress the new version into an archive and upload it to the website. If the compilation does not complete according to plan then the error log and some other useful information is uploaded to the website instead. Note that all usernames and passwords have been changed to placeholders in this version. This is run every day (or night depending on your time zone) by a cron job.

#!/bin/sh
#
. /Users/nick/.bashrc

#Make a nightly build of KiCad

#update from launchpad using bazaar
cd /Temp/kicad.bzr/kicad/
bzr update

new_version=`bzr revno`
old_version=`cat /temp/install/version.txt`
if [ $new_version -gt $old_version ]
then

#build it
cd build/release

cmake ../../ -DwxWidgets_CONFIG_EXECUTABLE=”/usr/local/bin/wx-config” -DwxWidgets_ROOT_DIR=”/opt/wxwidgets-svn/include/wx-2.9/” -DCMAKE_INSTALL_PREFIX=”/temp/install” -DCMAKE_OSX_ARCHITECTURES=”ppc -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk/ -mmacosx-version-min=10.5″ -DCMAKE_CXX_FLAGS=”-D__ASSERTMACROS__” -DCMAKE_OSX_SYSROOT=”/Developer/SDKs/MacOSX10.5.sdk”

# make clean
if make > /temp/kicad_errors-${new_version}.txt 2>> /temp/kicad_errors-${new_version}.txt && make install
then
file=kicad_osx_v${new_version}
echo $new_version > /temp/install/version.txt
mv /temp/kicad_errors-${new_version}.txt /temp/install/build_log.txt

#bundle
cd /temp/
cp -rf install ${file}
tar -czf ${file}.tgz ${file}

#upload
curl -T ${file}.tgz ftp://user:password@ftp.brokentoaster.com/
rm -rf ${file}

# cd /temp/kicad-sources/build/release/
# /Developer/usr/bin/packagemaker –doc osx-package.pmdoc –title ‘Kicad’ -o ${file}.mpkg
# curl -T ${file}.mpkg ftp://user:password@ftp.brokentoaster.com/

else

#insert some useful debug info
echo “*** GCC Version Info ***”>> /temp/kicad_errors-${new_version}.txt
gcc -v >> /temp/kicad_errors-${new_version}.txt

echo “*** wxWdgets Version Info ***”>> /temp/kicad_errors-${new_version}.txt
wx-config –list >> /temp/kicad_errors-${new_version}.txt
head /Volumes/Store/wxWidgets-2.9.1/osxbuild/config.log >> /temp/kicad_errors-${new_version}.txt

curl -T /temp/kicad_errors-${new_version}.txt ftp://user:password@ftp.brokentoaster.com/
fi

# go to sleep
if [ ! -e /Users/nick/Applications/insomnia.flag.true ]
then
open /Users/nick/Applications/SleepNow.app
fi
else
echo “KiCad is up to date : ) ”
fi

Listing 4: BASH script to update, build and upload KiCad. This is run daily via a cron job

So if you want to test the latest developer build of KiCad on OS X then look no further than here.

10 Responses to “KiCad OS X nightly development builds are back”

  1. David says:

    Thanks for supplying these nightlies and getting them back to work. I have some issues I’d like to share though. This applies to build 2876

    1. When starting eeschema I get the following error(s)

    ../include/wx/strvararg.h(449): assert “(argtype & (wxFormatStringSpecifier::value)) == argtype” failed in wxArgNormalizer(): format specifier doesn’t match argument type
    Do you want to stop the program?
    You can also choose [Cancel] to suppress further warnings.

    After pressing cancel, the following comes up:
    2. The following libraries could not be found:
    [then a list of all libraries]

    I haven’t been able to find the location of the libraries. Actually, I haven’t been able to find the libraries at all. Are they included in your binaries? Or can I get them from somewhere?

  2. Nick says:

    Hi David,
    The assert warning message is kind of normal with the debug builds. I would question about it on the developers mailing list if you want to know more.
    (https://launchpad.net/~kicad-developers)

    I also get that message but have some libraries under /usr/local/kicad/ but these will have been installed some time previously. There are no libraries distributed with the nightly builds. The easiest way to get the libraries will be to download the latest official Linux distribution file from http://iut-tice.ujf-grenoble.fr/cao/kicad-2010-05-05-BZR2356-stable-UBUNTU_9.10.tgzand extract the libraries from that (look in /kicad/share/library).

    You will then want to add the corresponding path to your libraries path in kicad (look in the Preferences Menu).

    More libraries can be found at http://www.kicadlib.org/index.php

    Hope this helps.

    Nick.

  3. David says:

    Hi Nick,

    Thanks man! I’ve got it working using the libraries from the Ubuntu stable release. Can you recommend a certain build for OS X? I’m using 2893 at the moment, but especially pcbnew is very buggy. I’m going to first try out the stable release on Ubuntu in VMware.

    I’ve joined the mailing list and will keep an eye on it in the next few days/weeks. It would be nice if there is anything I can do to help make KiCad a viable alternative to Eagle. There are not that many options for EDA suites for Mac users.

    Cheers,

    David

  4. Nick says:

    I’ll see if I can get a compile of the stable branch up this weekend (2766).
    It’s building now….

    Try version 2806 and see how that works. I still find it is much faster to use the windows version under wine than the native mac version.

    Let me know how you get on.

  5. David says:

    Thanks, 2806 is a lot better than the latest ones in terms of stability. It is still a bit too slow for real work. As I said, I will be having a go at KiCAD under Linux and Windows and see if it is usable for some designs I’m working on.

  6. Nick says:

    KiCad is definitely usable under Linux and Windows. It is usable under wine on OS X as well.

  7. David says:

    Wow! I am impressed. I have just finished a design using KiCad on Ubuntu. The workflow is a lot better than Eagle. I especially like the looser coupling between parts and footprints and the better GUI.

    I have been following the mailing list for a couple of days, but it is hard to get an overview of which developments are going on. Do you know if KiCad for OSX is under active development? As I said before, it would be great if there was a viable OSX EDA alternative to Eagle.

  8. Nick says:

    I agree the workflow is much nicer. I do like the way eagle does things at times though and the scripts are great.

    I believe OSX is under active development but not as higher priority as linux and windows.

    Try https://launchpad.net/~jerryjacobs for more info on OSX Development of KiCAD.

  9. shaneburrell says:

    I’ve build 2933 by hand using 10.6 and 10.7 SDKs. Any interest in updating the script or newer build. 2933 is much more responsive and the build I did it doesn’t have the wxWidgets warning on schema editor.

  10. Nick says:

    Hi Shane, unfortunately I am building on a ppc 10.5 machine, (I think) this means I do not have access to newer SDKs.

    I will try and build a non development version of the wxwidgets to use with the stable builds.

    Are you able to post your configuration for cmake when building kicad on you machine? What system we you building on? Where did you get the 10.7 SDK from?

    Any information you can give will help me improve the build scripts.

    Cheers,

    Nick.

Leave a Reply

You must be logged in to post a comment.