Changes between Initial Version and Version 1 of CompileAppWin


Ignore:
Timestamp:
Apr 20, 2013, 3:01:49 PM (11 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CompileAppWin

    v1 v1  
     1= Building BOINC applications on Windows =
     2
     3== Microsoft Visual Studio == #vs
     4
     5There is a free version, [http://msdn2.microsoft.com/en-us/express/aa975050.aspx Visual C++ 2008 Express Edition],
     6which works with the BOINC project file (after it is converted).
     7You'll also need the [http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en Microsoft Platform SDK]
     8and some [http://msdn.microsoft.com/en-us/vstudio/aa700755.aspx changes to your Visual Studio Express]
     9installation to include the SDK.
     10Warning: you cannot use more recent versions of the SDK (which do not include glaux).
     11
     12If you use your own project file:
     13
     14 * If your application uses graphics, go to Properties -> Linker -> Input. In Delay Loaded DLLs add
     15{{{
     16GDI32.DLL;OPENGL32.DLL;GLU32.DLL
     17}}}
     18 and in Additional Dependencies add
     19{{{
     20delayimp.lib
     21}}}
     22 * Configure your project to use ANSI strings rather than Unicode.
     23
     24=== Microsoft Specific Changes ===
     25
     26Recent versions of Visual Studio include changes to the C Runtime Library which throw up this error when an invalid parameter is passed to various functions:
     27
     28[[Image(runtimerror.png)]]
     29
     30To prevent this dialog from being displayed and presenting a bad user experience on the BOINC platform, please add this to your applications initialization:
     31{{{
     32#if defined(_MSC_VER) && (_MSC_VER >= 1400)
     33        _set_invalid_parameter_handler(AppInvalidParameterHandler);
     34#endif
     35}}}
     36
     37Where AppInvalidParameterHandler() is defined as:
     38{{{
     39#if defined(_MSC_VER) && (_MSC_VER >= 1400)
     40void AppInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved ) {
     41        DebugBreak();
     42}
     43#endif
     44}}}
     45
     46
     47== MinGW and Dev-C++ == #devcpp
     48
     49If you can't or don't want to use Visual Studio to build applications,
     50the easiest alternative is
     51[http://www.bloodshed.net/devcpp.html Dev-C++], an open-source development environment based on the GCC compilers.
     52Use the MinGW compile option.
     53
     54SETI@home uses Dev-C++ for its Windows build;
     55you can get the project file
     56[https://setisvn.ssl.berkeley.edu/trac/browser/seti_boinc/client/win_build/seti_boinc.dev here].
     57
     58== MinGW command-line == #mingw-cli
     59
     60To build the BOINC library and API for Windows using [http://www.mingw.org/ MinGW] (on MSYS, Cygwin or cross-platform) compile with "make -f Makefile.mingw" while in the "lib" folder.
     61
     62Per default the targets ''libboinc_api.a''  ''libboinc.a'' and ''libboinc_graphics2.a'' are built.
     63Optional targets are ''libboinc_zip.a'' (requires the boinc_zip tree),
     64and the usual ''clean'', ''install'' and ''uninstall'' targets.
     65
     66The following environment variables influence the build:
     67 * CC and CXX : set to MinGW C and C++ compiler
     68 * AR and RANLIB : set to ''ar'' and ''ranlib'' of the ''target'' system when cross-compiling
     69 * BOINC_SRC : set to the root of the boinc source tree, defaults to .. (i.e. 'make -f Makefile.mingw' should work within lib/)
     70 * BOINC_PREFIX : set to destination if you want to use ''install'' and ''uninstall'' targets; defaults to /usr/local/boinc
     71 * NOCYGWIN : set to '-mno-cygwin' if you are building on Cygwin but for use on plain Windows (i.e. w/o cygwin.dll)
     72
     73== Cygwin == #cygwin
     74
     75[http://www.cygwin.com/ Cygwin] may be another alternative for building Windows apps.
     76There are several issues:
     77
     78 * If you build the API library directly, it will use use shared memory
     79  to communicate with the BOINC client.
     80  This won't work if you use the standard Windows client,
     81  which uses memory-mapped files rather than shared memory.
     82 * In order to run a cygwin application from BOINC,
     83 you need to supply all the cygwin DLLs that the application requires
     84 in addition to the executable.
     85 You can get LISTDLLS from http://www.sysinternals.com/.
     86 It will tell you what DLLs a running executable has loaded.
     87 *  Cygwin is GPL software.
     88 If you link to the cygwin DLL,
     89 then either your application has to be GPL as well,
     90 or you will have to buy a commercial license from Red Hat.
     91
     92However, it can be done.
     93Check the [https://twiki.cern.ch/twiki/bin/view/LHCAtHome/BoincPort cookbook from CERN]
     94(search for "Instructions to Port the application to Windows").
     95
     96== Symbol Stores == #symbol-stores
     97
     98To obtain useful stack traces in the event of an application crash, symbols are needed.
     99Normally symbols are "stripped" from executables.
     100Without symbols, callstacks are just a list of memory addresses.
     101You then must load the un-stripped executable in memory using the
     102same operating system and similar processor to jump to that memory address in order
     103to determine the function name and parameters.
     104This is very labor intensive.
     105
     106Microsoft created a technology called a 'Symbol Store' which allows Windows debuggers
     107to locate and download compressed symbol files to diagnose problems
     108and convert function pointers into human readable text.
     109This greatly speeds up the process of diagnosing and fixing bugs.
     110
     111With the BOINC Runtime Debugger for Windows framework a project can publish their
     112symbol files and only have to distribute the application to each of the BOINC  clients.
     113When a crash event occurs the runtime framework will download the symbol
     114file from the symbol store and then proceed to dump as much diagnostic information
     115as possible to help projects diagnose the failure.
     116
     117=== Requirements ===
     118You'll need the latest stable release of the  [http://www.microsoft.com/whdc/devtools/debugging/default.mspx Debugging Tools for Windows. ]
     119
     120Verify that your executable is setup to generate PDB debugging symbols for a release build.
     121
     122Verify that the advance linker option to generate a checksum is enabled for a release build.
     123
     124You'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.
     125
     126==== Project Symbol Store ====
     127
     128Add a symstore element to your config.xml file for the project:
     129
     130{{{
     131<boinc>
     132    <config>
     133        <symstore>http://sample.example.com/symstore</symstore>
     134    </config>
     135</boinc>
     136}}}
     137
     138=== Adding symbols to the symbol store ===
     139 [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.
     140
     141Symstore will compress the symbol file and then copy it into your local symbol store.
     142
     143Below is an example command which you can run from the Windows command line or cygwin command line.
     144
     145{{{
     146symstore.exe add /l /f c:\SampleSrc\*.pdb /s c:\symstore /compress /t "Sample" /v "5.02" /o /c "Application Release"
     147}}}
     148
     149=== Uploading symbols to the symbol store ===
     150
     151Most projects tend to use scp to copy files between Windows machines and their project server.
     152
     153The 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.
     154
     155{{{
     156pscp.exe -r -C -batch c:\symstore sample@project.example.com:projects/sample/html/user/symstore
     157}}}
     158