Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 API for Go Documentation | 2025.1

# Integrate P4 API for Go on Windows

To integrate P4 API for Go on windows, follow these steps:

- Download the relevant files

- Build OpenSSL libraries

- Configure build flags

## Download the relevant files

Download P4 API for Go from either the Perforce website or GitHub.

To integrate P4 API for Go on Windows, you need the correct version of P4 API for C/C++ and to create pre built binaries for OpenSSL.

The application versions of P4 API for Go and P4 API for C/C++ must align.

For example, P4 API for Go 2025.1 requires P4 API for C/C++ r25.1.

Download the relevant version of P4 API for C/C++ from the Perforce archive.

For Windows with MinGW-w64 (x86_64 target), the P4 API for C/C++ file to download is called `p4api-openssl<SSLVER>-<GCCVER>-win32_seh.zip` where:

- <SSLVER> is the OpenSSL version number.

- <GCCVER> is the GCC version number.

For example, Windows with OpenSSL 3 and GCC version 8, requires the following P4 API for C/C++ version: `p4api-openssl3_gcc8_win32_seh.zip`.

Use the Command Prompt to find the version numbers for OpenSSL and GCC.

To find the OpenSSL version installed on your system, enter openssl version -a .

To find the GCC version installed on your system, enter gcc --version .

If you are Integrating P4 API for Go 2025.1, search the `r25.1` directory in the Perforce archive to find the version of P4 API for C/C++ to download.

In this example, the version of P4 API for C/C++ for Windows with MinGW-w64 is found in the following location:

`https://ftp.perforce.com/perforce/r25.1/bin.mingw64x64/p4api-openssl3_gcc8_win32_seh.zip`

## Build OpenSSL libraries

When you have the relevant version of P4 API for C/C++, ensure that you have prebuilt binaries that are tailored for your specific platform. For Windows, OpenSSL libraries must be built using `MinGW-w64` targeting`x86_64`.

## Configure build flags

Configure the following build flags in the command prompt.

Copy

    1
    2
    3
    go env -w CGO_ENABLED=1
    go env -w CGO_CPPFLAGS="-I<absolute path to P4 API for C++>/include -DOS_NT -g"
    go env -w CGO_LDFLAGS="-L<absolute path to P4 API for C++>/lib -L<OpenSSLPath> -lp4api -lssl -lcrypto -lcrypt32 -lws2_32  -lole32 -lshell32 -luser32 -ladvapi32 -lole32 -pthread -v"

Replace:

- `<OpenSSLPath>` with the absolute path to OpenSSL libraries matching the OpenSSL version used to build the P4 API for C/C++.

- `<absolute path to P4 API for C++>` with the absolute path to the P4 API for C/C++

Your search for returned results