= Building BOINC applications = [[PageOutline]] When building a BOINC application, you typically * want versions for several platforms (Windows, Mac OS X, Linux); * want each version to run on a wide range of volunteered computers (e.g. the Linux/x86 version should run on Linux systems of many ages and types). Achieving these goals can be challenging. However, BOINC provides tools and example files that simplify the task. Whether you're creating a new application or adapting an existing application to BOINC, we recommend that you start by building the BOINC sample application '''example_app''' on all the platforms you want to support. When this is done, you can use the example application and its associated project files as a basis for your own application. The first step in building the example application on a given host is to check out the boinc and boinc_samples modules on that host. Put them in the same parent directory. == Windows == We use Windows XP for builds (other Windows versions may work too). === Microsoft Visual Studio === Go to boinc_samples/win_build. If you're using Visual Studio 2005, open samples.sln. If you're using Visual Studio 2003, open samples_2003.sln. Select 'Build/Build Solution', or hit F7. That's it! There is a free version, [http://msdn2.microsoft.com/en-us/express/aa975050.aspx Visual C++ 2008 Express Edition], which works with the BOINC project file (after it is converted). You'll also need the [http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en Microsoft Platform SDK] and some [http://msdn2.microsoft.com/en-us/express/aa700755.aspx changes to your Visual Studio Express] installation to include the SDK. Warning: you cannot use more recent versions of the SDK (which do not include glaux). If you use your own project file: * It must compile BOINC .C files as C++. To do this: in Properties, see C/C++ -> Advanced -> Compile As. * If your application uses graphics, go to Properties -> Linker -> Input. In Delay Loaded DLLs add {{{ GDI32.DLL;OPENGL32.DLL;GLU32.DLL }}} and in Additional Dependencies add {{{ delayimp.lib }}} * Configure your project to use ANSI strings rather than Unicode. === Cygwin === Cygwin is an alternative to Visual Studio for building Windows apps. In order to run a cygwin application from BOINC, you need to supply all the cygwin DLLs that the application requires in addition to the executable. You can get LISTDLLS from http://www.sysinternals.com/. It will tell you what DLLs a running executable has loaded. Note that Cygwin is GPL software. If you link to the cygwin DLL, then either your application has to be GPL as well, or you will have to buy a commercial license from Red Hat. TODO: links to required software? TODO: develop a Makefile for building example_app under Cygwin. It can assume that the libraries in boinc/lib and boinc/api have already been built. Verify that _autosetup/configure/make work in boinc/. Information from CERN is [https://uimon.cern.ch/twiki/bin/view/LHCAtHome/BoincPort#WinInstr here]. {{{ #!comment === Dev-C++ === [http://www.bloodshed.net/devcpp.html Dev-C++] is an open-source development environment based on the GCC compilers. TODO: develop a project file for Dev-C++. It should be similar to the Visual Studio project file (i.e. it should include what it needs from boinc/). SETI@home used Dev-C++ for its Windows build; you can get the [http://setiathome.berkeley.edu/cgi-bin/cvsweb.cgi/seti_boinc/client/win_build/Attic/seti_boinc.dev?rev=1.1.2.23;content-type=text%2Fplain.dev project file] on SETI CVS repository. (''outdated''). }}} === Symbol Stores === To obtain useful stack traces in the event of an application crash, symbols are needed. Normally symbols are "stripped" from executables. Without symbols, callstacks are just a list of memory addresses. You then must load the un-stripped executable in memory using the same operating system and similar processor to jump to that memory address in order to determine the function name and parameters. This is very labor intensive. Microsoft created a technology called a 'Symbol Store' which allows Windows debuggers to locate and download compressed symbol files to diagnose problems and convert function pointers into human readable text. This greatly speeds up the process of diagnosing and fixing bugs. With the BOINC Runtime Debugger for Windows framework a project can publish their symbol files and only have to distribute the application to each of the BOINC clients. When a crash event occurs the runtime framework will download the symbol file from the symbol store and then proceed to dump as much diagnostic information as possible to help projects diagnose the failure. ==== Requirements ==== You'll need the latest stable release of the [http://www.microsoft.com/whdc/devtools/debugging/default.mspx Debugging Tools for Windows. ] Verify that your executable is setup to generate PDB debugging symbols for a release build. Verify that the advance linker option to generate a checksum is enabled for a release build. You'll need to explicitly name both your EXE and PDB before compilation since the debugger bases the name of the PDB file off of information that is stored in the executable header. ==== Project Symbol Store ==== Add a symstore element to your config.xml file for the project: {{{ http://sample.example.com/symstore }}} ==== Adding symbols to the symbol store ==== [http://msdn.microsoft.com/en-us/library/cc266480.aspx Symstore] is a utility to manage symbol stores. You'll want to create a local symbol store on your Windows build machine in which you'll initially add new symbol files with each revision of your application. Symstore will compress the symbol file and then copy it into your local symbol store. Below is an example command which you can run from the Windows command line or cygwin command line. {{{ symstore.exe add /l /f c:\SampleSrc\*.pdb /s c:\symstore /compress /t "Sample" /v "5.02" /o /c "Application Release" }}} ==== Uploading symbols to the symbol store ==== Most projects tend to use scp to copy files between Windows machines and their project server. The example below copies the entire symstore to the target location. After the copy operation you can delete all the subdirectories except '000Admin' to save time uploading for future application symbols. {{{ pscp.exe -r -C -batch c:\symstore sample@project.example.com:projects/sample/html/user/symstore }}} == Mac OS X == Instructions for building applications on Mac OS X are on a [BuildMacApp separate page]. == Linux/x86 == If you build an application on a recent Linux distribution, it won't run on older Linux distributions because of library incompatibilities. The only solution we've discovered is to build applications on a host with an old Linux and an old gcc. Setting up such a host, however, is a giant pain. Our recommended approach is not to build directly on a Linux host, but rather: * Install [http://www.microsoft.com/windows/virtualpc/ Microsoft Virtual PC 2004] on a Windows XP machine (preferably one that's fast and has lots of disk). * Download the [VirtualMachines#compatibility Compatibility] virtual machine module. This is a Debian Linux system with the appropriate (old) version of gcc. * Run this system under Virtual PC. * Install the boinc and boinc_samples modules in the same parent directory on the virtual host. * Build the BOINC libraries: go to the boinc/directory and type {{{ _autosetup ./configure --disable-client --disable-server make }}} Do not 'make install'. * go to the boinc_samples/uppercase directory and type {{{ ln -s `g++ -print-file-name=libstdc++.a` make }}} == Other UNIX systems == * [SoftwarePrereqsUnix Software prerequisites] * [BuildSystem configure/build] === GLUT notes === Freeglut 2.2, freeglut 2.4 and OpenGL Utility Toolkit (GLUT) libraries are supported. === X11 notes === To get the X11 support, select the relevant options when you're installing Linux, or (Redhat) go to System Settings/Add Software.