36

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"

or

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

or

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

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 '14 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 '14 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 '14 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 '15 at 20:03
  • 1
    I would be very careful with LD_LIBRARY_PATH: xahlee.info/UnixResource_dir/_/ldpath.html. – skalee Mar 22 at 21:11
8

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 '14 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 '14 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 '14 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 '14 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 '14 at 12:06

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.