-
Notifications
You must be signed in to change notification settings - Fork 443
CompileAppWin
There is a free version, Visual C++ 2008 Express Edition, which works with the BOINC project file (after it is converted). You'll also need the Microsoft Platform SDK and some 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:
- 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.
- Set 'Create/Use Precompiled Header' to 'Automatically Generate' (
/YX
) in C/C++ Precompiled Header project properties. - Change 'Compile As' to 'Compile as C++ Code (
/TP
)' in C/C++ 'Compile As' project properties.
Recent 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:
To prevent this dialog from being displayed and presenting a bad user experience on the BOINC platform, please add this to your applications initialization:
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
_set_invalid_parameter_handler(AppInvalidParameterHandler);
#endif
Where AppInvalidParameterHandler() is defined as:
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
void AppInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved ) {
DebugBreak();
}
#endif
You may be able to significantly (e.g. 2X) optimize your app by setting the following options in the project config:
General
- Platform Toolset
- Whole Program Optimization
Optimization
- Inline Function Expansion
- Enable Intrinsic Functions
- Favor Size Or Speed
- Omit Frame Pointers
- Whole Program Optimization
If you can't or don't want to use Visual Studio to build applications, the easiest alternative is Dev-C++, an open-source development environment based on the GCC compilers. Use the MinGW compile option.
SETI@home uses Dev-C++ for its Windows build; you can get the project file here.
To build the BOINC library and API for Windows using MinGW (on MSYS, Cygwin or cross-platform) compile with "make -f Makefile.mingw" while in the "lib" folder.
Per default the targets libboinc_api.a, libboinc.a, libboinc_graphics2.a and libboinc_opencl.a are built. Optional targets are libboinc_zip.a (requires the boinc_zip tree), wrapper and the usual clean, install and uninstall targets.
The following environment variables influence the build:
- MINGW : prefix to be used for build tools (gcc, g++, ar, ranlib) when cross-compiling (e.g. MINGW=x86_64-w64-mingw32 sets CC=x86_64-w64-mingw32-gcc automatically)
- alternatively you can also use CC, CXX, AR and RANLIB directly
- BOINC_SRC : set to the root of the boinc source tree, defaults to .. (i.e. 'make -f Makefile.mingw' should work within lib/)
- BOINC_PREFIX : set to destination if you want to use install and uninstall targets; defaults to
/usr/local/boinc
- NOCYGWIN : set to '-mno-cygwin' if you are building on Cygwin but for use on plain Windows (i.e. w/o cygwin.dll)
- LIBTOOL : specify which libtool script to use when building for target all-la (default:
$BOINC_SRC/libtool
) - ZIP_MINGW64_FIX: set to !* (empty) if the fix for 64bit boinc_zip should not be applied (default:
zip/__p___mb_cur_max.o
)
Cygwin may be another alternative for building Windows apps. There are several issues:
- If you build the API library directly, it will use use shared memory to communicate with the BOINC client. This won't work if you use the standard Windows client, which uses memory-mapped files rather than shared memory.
- 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.
- 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.
However, it can be done. Check the cookbook from CERN (search for "Instructions to Port the application to Windows").
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.
You'll need the latest stable release of the 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.
Add a symstore element to your config.xml file for the project:
<boinc>
<config>
<symstore>http://sample.example.com/symstore</symstore>
</config>
</boinc>
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"
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