wiki:AppDev

Version 9 (modified by davea, 10 years ago) (diff)

--

Application development tips

Cross-platform functions

Most POSIX calls are supported on Unix and Windows. For areas that are different (e.g. scanning directories) BOINC supplies some generic functions with implementations for all platforms. Similar code may be available from other open-source projects.

double dtime()
return Unix time with fractional seconds
double dday()
return Unix time at start of this day
void boinc_sleep(double)
sleep for given period
read_file_string(const char*, string)
read file into string

etc. See lib/util.h and lib/filesys.h for others.

Windows-specific issues

  • Visual Studio: set 'Create/Use Precompiled Header' to 'Automatically Generate' (/YX) in C/C++ Precompiled Header project properties.
  • Visual Studio: change 'Compile As' to 'Compile as C++ Code (/TP)' in C/C++ 'Compile As' project properties.

Unix-specific issues

Shared libraries

Your application can use shared libraries (.so). Include these as separate files. They will reside in your project's directory on the client host. The BOINC client appends the project directory to LD_LIBRARY_PATH, so your program will find them and run correctly.

A problem may arise if you support multiple platforms (say, Linux32 and Linux64). You need different versions of the shared library for each platform. These libraries must have distinct physical names - say, libfoo_1.1_linux32.so and libfoo_1.1_linux64.so.

But what if there are multiple shared libraries, and some depend on others? It may be difficult to change the Makefiles to use these distinct names. Here's what you can do to solve this problem:

  • Give each shared library its 'natural' name (e.g., libfoo.so) as its logical name.
  • Give shared libraries the "copy_file" attribute.

The client will then copy these libraries into the app's execution directory, giving it the logical name.