提问人:Opor 提问时间:11/15/2023 最后编辑:Abderrahmene Rayene MihoubOpor 更新时间:11/15/2023 访问量:72
如何从 openvpn3 库生成 lib 文件
How to generate a lib file from the openvpn3 library
问:
我正在尝试在我的qt项目中使用openvpn3库。现在,我让它变得非常简单,以便测试库,但我不知道我做错了什么。我按照步骤使用 visual studios (https://github.com/OpenVPN/openvpn3#id16) 下载库。
从我所看到的,没有生成 lib 文件,如果我没有 lib 文件,我怎么能链接到库?
CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project(TestAuthentication VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(ASIO_INCLUDE_DIR "C:/Users/dev/Documents/asio/asio/include")
include_directories(C:/Users/dev/Documents/core)
find_package(Qt6 6.4 REQUIRED COMPONENTS Quick)
qt_standard_project_setup()
qt_add_executable(appTestAuthentication
main.cpp
)
target_include_directories(appTestAuthentication PRIVATE ${ASIO_INCLUDE_DIR})
qt_add_qml_module(appTestAuthentication
URI TestAuthentication
VERSION 1.0
QML_FILES Main.qml
SOURCES vaultauthenticator.h vaultauthenticator.cpp
SOURCES ovpnclient.h ovpnclient.cpp
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(appTestAuthentication PROPERTIES
# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appTestAuthentication
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
target_link_libraries(appTestAuthentication
PRIVATE Qt6::Quick
)
include(GNUInstallDirs)
install(TARGETS appTestAuthentication
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
main.cpp:
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "qdebug.h"
#define USE_ASIO 1
#define OPENVPN_CORE_API_VISIBILITY_HIDDEN
#include <client/ovpncli.hpp>
using namespace openvpn;
class OVPNClient: public ClientAPI::OpenVPNClient {
public:
explicit OVPNClient(){
qDebug() \<\< "Constructor";
}
virtual void event(const ClientAPI::Event&) override {
qDebug() << "event";
}
virtual void log(const ClientAPI::LogInfo&) override {
qDebug() << "log";
}
virtual bool pause_on_connection_timeout() override {
qDebug() << "pause_on_connection_timeout";
return false;
}
virtual void external_pki_cert_request(ClientAPI::ExternalPKICertRequest& request) override {
qDebug() << "external_pki_cert_request";
}
virtual void external_pki_sign_request(ClientAPI::ExternalPKISignRequest& request) override {
qDebug() << "external_pki_sign_request";
}
};
int main(int argc, char \*argv\[\])
{
QGuiApplication app(argc, argv);
OVPNClient client;
return app.exec();
}
我在输出中收到多个链接错误:
11:51:40: Running steps for project TestAuthentication...
11:51:40: Starting: "C:\Qt\Tools\CMake_64\bin\cmake.exe" --build C:/build-TestAuthentication-Desktop_Qt_6_6_0_MSVC2019_64bit-Release --target all
[1/10 2.8/sec] Automatic MOC and UIC for target appTestAuthentication
[2/9 4.7/sec] Running AUTOMOC file extraction for target appTestAuthentication
[3/9 6.2/sec] Running moc --collect-json for target appTestAuthentication
[4/5 0.7/sec] Building CXX object CMakeFiles\appTestAuthentication.dir\main.cpp.obj
Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:
- add -D_WIN32_WINNT=0x0601 to the compiler command line; or
- add _WIN32_WINNT=0x0601 to your project's Preprocessor Definitions.
Assuming _WIN32_WINNT=0x0601 (i.e. Windows 7 target).
[5/5 0.8/sec] Linking CXX executable appTestAuthentication.exe
FAILED: appTestAuthentication.exe
cmd.exe /C "cd . && C:\Qt\Tools\CMake_64\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\appTestAuthentication.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo CMakeFiles\appTestAuthentication.dir\appTestAuthentication_autogen\mocs_compilation.cpp.obj CMakeFiles\appTestAuthentication.dir\main.cpp.obj CMakeFiles\appTestAuthentication.dir\apptestauthentication_qmltyperegistrations.cpp.obj CMakeFiles\appTestAuthentication.dir\.rcc\qrc_qmake_TestAuthentication.cpp.obj CMakeFiles\appTestAuthentication.dir\vaultauthenticator.cpp.obj CMakeFiles\appTestAuthentication.dir\ovpnclient.cpp.obj CMakeFiles\appTestAuthentication.dir\.rcc\qmlcache\appTestAuthentication_qmlcache_loader.cpp.obj CMakeFiles\appTestAuthentication.dir\.rcc\qmlcache\appTestAuthentication_Main_qml.cpp.obj CMakeFiles\appTestAuthentication.dir\.rcc\qrc_appTestAuthentication_raw_qml_0.cpp.obj /out:appTestAuthentication.exe /implib:appTestAuthentication.lib /pdb:appTestAuthentication.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:windows C:\Qt\6.6.0\msvc2019_64\lib\Qt6Quick.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6QmlModels.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6Qml.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6Network.lib ws2_32.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6OpenGL.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6Gui.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6Core.lib mpr.lib userenv.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6EntryPoint.lib shell32.lib d3d11.lib dxgi.lib dxguid.lib d3d12.lib user32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK: command "C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo CMakeFiles\appTestAuthentication.dir\appTestAuthentication_autogen\mocs_compilation.cpp.obj CMakeFiles\appTestAuthentication.dir\main.cpp.obj CMakeFiles\appTestAuthentication.dir\apptestauthentication_qmltyperegistrations.cpp.obj CMakeFiles\appTestAuthentication.dir\.rcc\qrc_qmake_TestAuthentication.cpp.obj CMakeFiles\appTestAuthentication.dir\vaultauthenticator.cpp.obj CMakeFiles\appTestAuthentication.dir\ovpnclient.cpp.obj CMakeFiles\appTestAuthentication.dir\.rcc\qmlcache\appTestAuthentication_qmlcache_loader.cpp.obj CMakeFiles\appTestAuthentication.dir\.rcc\qmlcache\appTestAuthentication_Main_qml.cpp.obj CMakeFiles\appTestAuthentication.dir\.rcc\qrc_appTestAuthentication_raw_qml_0.cpp.obj /out:appTestAuthentication.exe /implib:appTestAuthentication.lib /pdb:appTestAuthentication.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:windows C:\Qt\6.6.0\msvc2019_64\lib\Qt6Quick.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6QmlModels.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6Qml.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6Network.lib ws2_32.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6OpenGL.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6Gui.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6Core.lib mpr.lib userenv.lib C:\Qt\6.6.0\msvc2019_64\lib\Qt6EntryPoint.lib shell32.lib d3d11.lib dxgi.lib dxguid.lib d3d12.lib user32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:appTestAuthentication.exe.manifest" failed (exit code 1120) with the following output:
Creating library appTestAuthentication.lib and object appTestAuthentication.exp
main.cpp.obj : error LNK2019: unresolved external symbol "public: __cdecl openvpn::ClientAPI::OpenVPNClient::OpenVPNClient(void)" (??0OpenVPNClient@ClientAPI@openvpn@@QEAA@XZ) referenced in function "public: __cdecl OVPNClient::OVPNClient(void)" (??0OVPNClient@@QEAA@XZ)
main.cpp.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl openvpn::ClientAPI::OpenVPNClient::~OpenVPNClient(void)" (??1OpenVPNClient@ClientAPI@openvpn@@UEAA@XZ) referenced in function "int `public: __cdecl OVPNClient::OVPNClient(void)'::`1'::dtor$0" (?dtor$0@?0???0OVPNClient@@QEAA@XZ@4HA)
main.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl openvpn::ClientAPI::OpenVPNClient::socket_protect(unsigned __int64,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,bool)" (?socket_protect@OpenVPNClient@ClientAPI@openvpn@@UEAA_N_KV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z)
main.cpp.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl openvpn::ClientAPI::OpenVPNClient::remote_override_enabled(void)" (?remote_override_enabled@OpenVPNClient@ClientAPI@openvpn@@UEAA_NXZ)
main.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl openvpn::ClientAPI::OpenVPNClient::remote_override(struct openvpn::ClientAPI::RemoteOverride &)" (?remote_override@OpenVPNClient@ClientAPI@openvpn@@UEAAXAEAURemoteOverride@23@@Z)
main.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl openvpn::ClientAPI::OpenVPNClient::clock_tick(void)" (?clock_tick@OpenVPNClient@ClientAPI@openvpn@@UEAAXXZ)
main.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl openvpn::ClientAPI::OpenVPNClient::connect_attach(void)" (?connect_attach@OpenVPNClient@ClientAPI@openvpn@@MEAAXXZ)
main.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl openvpn::ClientAPI::OpenVPNClient::connect_pre_run(void)" (?connect_pre_run@OpenVPNClient@ClientAPI@openvpn@@MEAAXXZ)
main.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl openvpn::ClientAPI::OpenVPNClient::connect_run(void)" (?connect_run@OpenVPNClient@ClientAPI@openvpn@@MEAAXXZ)
main.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl openvpn::ClientAPI::OpenVPNClient::connect_session_stop(void)" (?connect_session_stop@OpenVPNClient@ClientAPI@openvpn@@MEAAXXZ)
main.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual class openvpn::Stop * __cdecl openvpn::ClientAPI::OpenVPNClient::get_async_stop(void)" (?get_async_stop@OpenVPNClient@ClientAPI@openvpn@@MEAAPEAVStop@3@XZ)
main.cpp.obj : error LNK2001: unresolved external symbol "private: virtual bool __cdecl openvpn::ClientAPI::OpenVPNClient::sign(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?sign@OpenVPNClient@ClientAPI@openvpn@@EEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAV45@000@Z)
appTestAuthentication.exe : fatal error LNK1120: 12 unresolved externals
ninja: build stopped: subcommand failed.
11:51:47: The process "C:\Qt\Tools\CMake_64\bin\cmake.exe" exited with code 1.
Error while building/deploying project TestAuthentication (kit: Desktop Qt 6.6.0 MSVC2019 64bit)
When executing step "Build"
11:51:47: Elapsed time: 00:06.
答: 暂无答案
评论
ovpnclilib.lib