Compiling and linking Helix Server applications
The following sections tell you how to build your application on the target platform.
To build p4api.cc, include clientapi.h, which
includes all the necessary header files for the sample client
application.
Additional script libraries for Helix Core extensions
To learn about this technology, see the Helix Core Extensions Developer Guide.
|
Name |
Description |
|---|---|
libp4script.a
|
For the code common to server and client |
libp4script_c.a
|
For the client-side |
libp4script_curl
|
If you already have a copy of curl, you can skip linking to this version |
libp4script_sqlite
|
If you already have a copy of SQLite, you can skip linking to this version |
Link order
The link libraries distributed with P4API must be linked explicitly in the following order:
|
UNIX |
Windows |
|
|---|---|---|
| 1 | libclient.a
|
libclient.lib
|
| 2 | librpc.a
|
librpc.lib
|
| 3 | libsupp.a
|
libsupp.lib
|
SSL support
P4API libraries must be linked against the OpenSSL libraries from http://www.openssl.org/.
OpenSSL Library Version
We recommend keeping current with the latest minor version matching the
version referenced in the
Helix C/C++ API
file librpc.a (or librpc.lib on Windows). To
see which version is referenced by the library, run the following command
on UNIX variants or Macintosh:
strings librpc.a | grep ^OpenSSL
On Windows:
strings librpc.lib | findstr /B OpenSSL
This command will produce an output similar to the following:
OpenSSL 1.0.1p 9 Jul 2015
In this example, you would use the latest minor version of OpenSSL that matches version 1.0.1.
Link order for SSL support
To enable SSL support, link with the ssl and crypto libraries from OpenSSL. This results in the following link order:
libclient.alibrpc.alibsupp.alibssl.alibcrypto.a
On Windows, the ssl and crypto OpenSSL libraries are named
ssleay32.lib and libeay32.lib respectively.
Compiler support
UNIX
For all UNIX platforms, you can use the gcc compiler
to compile client applications with the
Helix C/C++ API.
Note that clientapi.h includes stdhdrs.h,
which might attempt to set platform-specific defines. To ensure these
defines are set properly, compile with the
-DOS_ flag, where XXX is the
platform name as specified by
Perforce. (Use
XXXp4 -V to display the platform name; for example, for
LINUX52X86, specify -DOS_LINUX.)
Some platforms require extra link libraries for sockets. Solaris requires the following compiler flags:
-lsocket -lnsl
Linux
Some platforms require extra link libraries for runtime support. Linux requires the following compiler flag:
-lrt
Windows
Using Microsoft Visual Studio (VC++), compile your client application with the following flags:
/DOS_NT /MT /DCASE_INSENSITIVE
For debugging, compile with the /MTd flag for multithreading.
Do not
compile with /MD or /MDd, because these flags can cause undefined
behavior.
Link with the following libraries:
libcmt.liboldnames.libkernel32.libws2_32.libadvapi32.lib
Sample Jamfile
The following example shows a Jamfile that can be used to build
p4api.cc, a
Helix Server
application. (This example is in the
api subdirectory.)
CFLAGS = -g -D_GNU_SOURCE ; LINK = c ;OPTIM = ; Main p4api : p4api.cc ; ObjectHdrs p4api : api ; LinkLibraries p4api : api/libclient.a api/librpc.a api/libsupp.a
For more about jam, see
Building with Jam.
Sample Makefile
The following is a GNU make file for building
p4api.cc, a
Helix Server
application. (The example assumes the API is installed in the
api subdirectory.)
SOURCES = p4api.cc
INCLUDES = -Iapi
OBJECTS = ${SOURCES:.cc=.o}
LIBRARIES = api/libclient.a api/librpc.a api/libsupp.a
BINARY = p4api
RM = /bin/rm -f
C = c
CFLAGS = -c -g -D_GNU_SOURCE
LINK = c
LINKFLAGS =
.cc.o :
${C} ${CFLAGS} $< ${INCLUDES}
${BINARY} : ${OBJECTS}
${LINK} -o ${BINARY} ${OBJECTS} ${LIBRARIES}
clean :
- ${RM} ${OBJECTS} ${BINARY}






