Ошибка компиляции openvpn3 в windows под mingw64 — переменная не была объявлена ​​в области видимости

Я получаю эту ошибку, пытаясь скомпилировать openvpn3 (https://github.com/OpenVPN/openvpn3в окнах под mingw64

$ ./build.sh
g++ -fwhole-program -O3 -Wall -Wno-sign-compare -Wno-unused-parameter -std=c++14 -flto=4 -Wl,--no-as-needed -Wno-unused-local-typedefs -Wno-unused-variable -Wno-shift-count-overflow -pthread -mms-bitfields -pthread -mms-bitfields -IC:/msys64/mingw64/include/gtk-3.0 -IC:/msys64/mingw64/include/cairo -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/pango-1.0 -IC:/msys64/mingw64/include/atk-1.0 -IC:/msys64/mingw64/include/cairo -IC:/msys64/mingw64/include/pixman-1 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/freetype2 -IC:/msys64/mingw64/include/libpng16 -IC:/msys64/mingw64/include/harfbuzz -IC:/msys64/mingw64/include/glib-2.0 -IC:/msys64/mingw64/lib/glib-2.0/include -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/freetype2 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/harfbuzz -IC:/msys64/mingw64/include/libpng16 -IC:/msys64/mingw64/include/gdk-pixbuf-2.0 -IC:/msys64/mingw64/include/libpng16 -IC:/msys64/mingw64/include/glib-2.0 -IC:/msys64/mingw64/lib/glib-2.0/include -IC:/msys64/mingw64/include -I/usr/include/jsoncpp -DUSE_OPENSSL -DUSE_ASIO -DASIO_STANDALONE -DASIO_NO_DEPRECATED -I/home/Nicholas/Work/asio/asio/include -DHAVE_LZ4 -I/home/Nicholas/Work/ovpn3/core ovpncli.cpp -o ovpncli -LC:/msys64/mingw64/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lz -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -lcurlpp -lcurl -ljsoncpp -lssl -lcrypto -ldl -llz4
In file included from C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/tun/win/client/tuncli.hpp:41:0,
from C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/client/cliopt.hpp:86,
from C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/client/cliconnect.hpp:59,
from C:/msys64/home/Nicholas/Work/ovpn3/core/client/ovpncli.cpp:96,
from ovpncli.cpp:35:
C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/tun/win/client/tunsetup.hpp: In member function 'void openvpn::TunWin::Setup::adapter_config_l2(HANDLE, const wstring&, const openvpn::TunWin::Util::TapNameGuidPair&, const openvpn::TunBuilderCapture&, openvpn::ActionList&, openvpn::ActionList&, std::ostream&)':
C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/tun/win/client/tunsetup.hpp:777:74: error: 'tap' was not declared in this scope
l2_thread.reset(new std::thread([this, logwrap=Log::Context::Wrapper(), tap]() {
^~~
C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/tun/win/client/tunsetup.hpp: In lambda function:
C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/tun/win/client/tunsetup.hpp:783:26: error: 'tap' is not captured
Util::dhcp_release(ii, tap.index, os);
^~~
C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/tun/win/client/tunsetup.hpp:777:77: note: the lambda has no capture-default
l2_thread.reset(new std::thread([this, logwrap=Log::Context::Wrapper(), tap]() {
^
C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/tun/win/client/tunsetup.hpp:777:74: note: '<typeprefixerror>tap' declared here
l2_thread.reset(new std::thread([this, logwrap=Log::Context::Wrapper(), tap]() {
^~~
C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/tun/win/client/tunsetup.hpp:789:24: error: 'tap' is not captured
Util::dhcp_renew(ii, tap.index, os);
^~~
C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/tun/win/client/tunsetup.hpp:777:77: note: the lambda has no capture-default
l2_thread.reset(new std::thread([this, logwrap=Log::Context::Wrapper(), tap]() {
^
C:/msys64/home/Nicholas/Work/ovpn3/core/openvpn/tun/win/client/tunsetup.hpp:777:74: note: '<typeprefixerror>tap' declared here
l2_thread.reset(new std::thread([this, logwrap=Log::Context::Wrapper(), tap]() {
^~~

Я посмотрел на заголовочный файл, который вызывает ошибку, и tap определяется в параметрах функции

void adapter_config_l2(HANDLE th,
const std::wstring& openvpn_app_path,
const Util::TapNameGuidPair& tap,
const TunBuilderCapture& pull,
ActionList& create,
ActionList& destroy,
std::ostream& os)
{
// Make sure the TAP adapter is set for DHCP
{
const Util::IPAdaptersInfo ai;
if (!ai.is_dhcp_enabled(tap.index))
{
os << "TAP: DHCP is disabled, attempting to enable" << std::endl;
ActionList::Ptr cmds(new ActionList());
cmds->add(new Util::ActionEnableDHCP(tap));
cmds->execute(os);
}
}

// set TAP media status to CONNECTED
Util::tap_set_media_status(th, true);

// ARP
Util::flush_arp(tap.index, os);

// We must do DHCP release/renew in a background thread
// so the foreground can forward the DHCP negotiation packets
// over the tunnel.
l2_thread.reset(new std::thread([this, logwrap=Log::Context::Wrapper(), tap]() {
Log::Context logctx(logwrap);
::Sleep(250);
const Util::InterfaceInfoList ii;
{
std::ostringstream os;
Util::dhcp_release(ii, tap.index, os);
OPENVPN_LOG_STRING(os.str());
}
::Sleep(250);
{
std::ostringstream os;
Util::dhcp_renew(ii, tap.index, os);
OPENVPN_LOG_STRING(os.str());
}
}));
}

Что может быть причиной этой ошибки?

Вот некоторая информация о моей среде сборки:
Windows 10, GCC 7.1.0, msys2 mingw64. я на последнем коммите. мой скрипт сборки выглядит так

#!/bin/bash
export O3=~/Work/ovpn3
ECHO=1 PROF=win ASIO_DIR=~/Work/asio OPENSSL_SYS=1 LZ4_SYS=1 $O3/core/scripts/build ovpncli

-1

Решение

Я исправил это, изменив порядок захвата потока из

l2_thread.reset(new std::thread([this, logwrap=Log::Context::Wrapper(), tap](){

в

l2_thread.reset(new std::thread([this, tap, logwrap=Log::Context::Wrapper()](){

Я не очень понимаю, почему это исправляет

0

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]