I wish to install OpenVPN on OpenBSD 5.5 using OpenVPN source tarball.

According to the instructions here, I have to install lzo and

add CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" directives to "configure", since gcc will not find them otherwise.

I have googled extensively for guide on how to do the above on OpenBSD but there is none.

This is what I plan to do:

  1. Untar the source tarball to a freshly created directory
  2. Issue the command
    ./configure CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"
  3. Issue the command make
  4. Issue the command make install

Which of the following syntax is correct?

./configure CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"


./configure --CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"


./configure --CFLAGS="-I/usr/local/include" --LDFLAGS="-L/usr/local/lib"

5 Answers 5


The correct way is:

./configure CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"

but this may not work with all configure scripts. It's probably better to set environment variables such as CPATH and LIBRARY_PATH (see gcc man page).

An example:

export CPATH=/usr/local/include
export LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH=/usr/local/lib

in your .profile, for instance. The LD_LIBRARY_PATH can be needed in case of shared libraries if a run path is not used (this depends on the OS, the build tools and the options that are used, but it shouldn't hurt).

  • Thanks for your answer. Is gcc installed by default in the base system of OpenBSD 5.5? If it isn't I'm not going to install a third-party package as it may contain bugs or security vulnerabilities.
    – user66229
    Aug 9, 2014 at 10:30
  • 1
    @user66229 if you did a default install then yes, gcc-4.2.1 (unless you're on really old machines like vaxen) is in comp55.tgz. There are packages for gcc-4.8 and 4.9, and also llvm/clang 3.0. The former aren't included mainly for licensing reasons (GPLv2 vs GPLv3), the latter isn't used because it doesn't support all the platforms that OpenBSD currently supports.
    – damien
    Aug 9, 2014 at 10:50
  • 1
    @user66229 I've edited my answer. This is just an example, there may be other ways to do it, and you might already have some settings. Check first with echo $CPATH and so on.
    – vinc17
    Aug 9, 2014 at 11:58
  • 1
    Thanks for the "but this may not work with all configure scripts" comment - I just ran into a case, where after several dependencies compiled with CFLAGS, the last dependency crashes when CFLAGS is specifies (and indeed, grep CFLAGS configure returns blank from that configure script).
    – sdaau
    Sep 27, 2015 at 20:03
  • 1
    I would be very careful with LD_LIBRARY_PATH: xahlee.info/UnixResource_dir/_/ldpath.html.
    – skalee
    Mar 22, 2019 at 21:11

The first syntax is correct.

./configure CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"

However, it is strongly recommended to either use binary packages(7) or, if for whatever reason you absolutely need to build from source, make use of the ports(7) infrastructure, as explained by the FAQ section 15.

Set up the ports tree as detailed in the FAQ. Then look for an openvpn port:

cd /usr/ports
make search key=openvpn

This will output a number of ports containing the term openvpn. One of them is openvpn-2.3.2 with path net/openvpn.

cd net/openvpn
sudo make install clean

This will have the benefit that the dependencies (here only lzo2) will be properly installed without clobbering your system and you will get additional instructions on how to use openvpn on OpenBSD.

  • Thanks for your answer. OpenBSD 5.5 already has an OpenVPN (binary) package but it's old at version 2.3.2. I wish to compile and install the latest version 2.3.4 which is only available from OpenVPN's GitHub.
    – user66229
    Aug 9, 2014 at 10:23
  • As you mentioned lzo, I noticed there are three binary packages available: lzo-1.08p3.tgz, lzo2-2.06p0.tgz and lzop-1.03.tgz. Which one of these 3 is the dependency for OpenVPN?
    – user66229
    Aug 9, 2014 at 10:34
  • 1
    @user66229: That would be lzo2-2.06p0.tgz. Here's a patch that upgrades the port of openvpn from 2.3.2 to 2.3.4, but there is hardly a change relevant to OpenBSD between the two versions (read the entire thread). I would really, really recommend that you just go with the binary package.
    – damien
    Aug 9, 2014 at 10:44
  • @damien Thanks for your answer and the link to the patch. I read the patch's contents and what got me worried is the fact there's no maintainer at OpenBSD for OpenVPN. Please help me guess the answer as to how the binary package openvpn-2.3.2.tgz got on to OpenBSD's official download mirrors?
    – user66229
    Aug 9, 2014 at 11:35
  • 1
    @user66229 here you can see the entire revision list for the Makefile of the port. As Stuart Henderson (one of the main package maintainers) said in that thread, not many of those changes are actually relevant for OpenBSD.
    – damien
    Aug 9, 2014 at 12:06

It completely depends on the configure script. If the configure script was generated by autoconf, then the "correct" way to ensure that /usr/local/lib and /usr/local/include are used in the build is to use CONFIG_SITE. That is, either make it global for all you configure invocations by defining CONFIG_SITE in your shell startup files and doing:

CFLAGS="-I/usr/local/include $CFLAGS"
LDFLAGS="-L/usr/local/lib $LDFLAGS"

or set it only for those configure invocations that use /usr/local as their prefix by adding the above content to /usr/local/etc/config.site. Any invocation of configure that uses --prefix=/usr/local will read /usr/local/etc/config.site (or /usr/local/share/config.site, if you prefer to use that path). Since the default prefix is /usr/local, creating /usr/local/etc/config.site will cause the assignment to be made for any invocation of configure that does not otherwise define a prefix.

Again, note that this is only if the configure script was generated by autoconf.

./configure CFLAGS="-I/usr/include/libxml2/"

doesn't work for my configure

In the source tree i have seen a Config

Added CFLAGS there, as

echo "CFLAGS=${PKG_CFLAGS}" >> Config



If you have a "./configure" to run previously to make you can do:
./configure CFLAGS="-I/usr/include/libxml2/"

  • 1
    Welcome to the site, and thank you for your contribution. Please note that your answer is rather similar to other existing answers, including the accepted answer (save for the fact that you are explicitly adding the libxml2 directory to the include paths, although that was mentioned nowhere in the question). Please consider editing your answer to explain how your approach is different from the other ones.
    – AdminBee
    Jun 29, 2020 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.