OpenVPN / openvpn3

OpenVPN 3 is a C++ class library that implements the functionality of an OpenVPN client, and is protocol-compatible with the OpenVPN 2.x branch.
https://openvpn.net
Other
977 stars 386 forks source link

Auto type specifier error with Qt build on Linux #75

Closed Locutu5 closed 5 years ago

Locutu5 commented 5 years ago

Hi all, I have started implementing a Qt based client for OpenVPN3 and for lack of clear instructions I am taking it slowly.

With just including the header (actually openvpncli.cpp) and trying a test compile I am getting the error

core/openvpn/common/msfind.hpp:55: error: ‘find’ function uses ‘auto’ type specifier without trailing return type
     inline auto find(MAP_SET& ms, const KEY& k)
                                               ^

The class I am trying to implement this in is

#ifndef OPENVPNCLIENT_H
#define OPENVPNCLIENT_H

#define OPENVPN_CORE_API_VISIBILITY_HIDDEN
#define USE_OPENSSL
#define USE_ASIO

#include <QObject>
//#include <openvpn/common/platform.hpp>

// should be included before other openvpn includes,
// with the exception of openvpn/log includes
#include <client/ovpncli.cpp>

using namespace openvpn;

class OVPNClient : public QObject, ClientAPI::OpenVPNClient
{
    Q_OBJECT
public:
    explicit OVPNClient(QObject *parent = nullptr);

signals:

public slots:
};

#endif // OPENVPNCLIENT_H

As you can see it is pretty much an empty class. What am I missing to be causing this error?

I am using Qt 5.12.3 and have enabled C++11 in the config. The compiler is g++ and the Linux is Arch.

lstipakov commented 5 years ago

Yep, we're aware of that problem (https://travis-ci.org/OpenVPN/openvpn3/jobs/541446445#L147) As a workaround, can you try to switch to C++14?

Locutu5 commented 5 years ago

So I am not going crazy :) I did read something about it being a c++14 and above functionality. I'll see if I can get Qt to support C++14.

Thanks for the quick reply.

Locutu5 commented 5 years ago

Just for those who also come across this problem. Changing in the Qt .pro file CONFIG += c++11 to CONFIG += c++14 will fix this particular issue.

dsommers commented 5 years ago

We still want to ensure OpenVPN 3 is functional with C++11. But pure C++11 compilers (stock RHEL 7 gcc-4.8 tested) with no C++14 support seems only to barf at this issue, not triggering a fatal error. While C++14 capable compilers are far more picky.

Regardless, this should be improved - but we will handle that improvement outside of this ticket.

Locutu5 commented 5 years ago

Understood. Until this improvement has been fixed this information may help someone else hence the reason I posted the solution which worked for me. Others mileage may vary :D