gpt4 book ai didi

c++ - CMake 无法正确地将 ultralight ui 库链接到 Clion 2019.1.2 中的可执行文件

转载 作者:行者123 更新时间:2023-11-28 04:17:38 25 4
gpt4 key购买 nike

您好,我正在尝试使用 ultralight 构建一个基本应用程序 https://github.com/ultralight-ux/Ultralight .但是,构建在链接阶段失败。我已经完成了很多其他答案,但没有取得任何进展。

Cmake 错误:

C:/Users/AMWAJ-PC/Desktop/untitled1/main.cpp:10: undefined reference to `__imp__ZN10ultralight3App6CreateEv'

C:/Users/AMWAJ-PC/Desktop/untitled1/main.cpp:11: undefined reference to `__imp__ZN10ultralight6Window6CreateEPNS_7MonitorEjjbj'
C:/Users/AMWAJ-PC/Desktop/untitled1/main.cpp:14: undefined reference to `__imp__ZN10ultralight7Overlay6CreateENS_3RefINS_6WindowEEEjjii'
C:/Users/AMWAJ-PC/Desktop/untitled1/main.cpp:15: undefined reference to `__imp__ZN10ultralight6StringC1EPKc'
C:/Users/AMWAJ-PC/Desktop/untitled1/main.cpp:15: undefined reference to `__imp__ZN10ultralight6StringD1Ev'
C:/Users/AMWAJ-PC/Desktop/untitled1/main.cpp:15: undefined reference to `__imp__ZN10ultralight6StringD1Ev'

Cmakelist.txt

cmake_minimum_required(VERSION 3.14)
project(untitled1)
set(CMAKE_CXX_STANDARD 17)

set(INCLUDE_DIRS "C:/C++/ultralight_ui/include/")
set(LINK_DIRS "C:/C++/ultralight_ui/lib/")
include_directories("${INCLUDE_DIRS}")
find_library(
ULTRA_LIB
NAMES UltralightCore AppCore Ultralight WebCore
HINTS "${LINK_DIRS}")

add_executable(untitled1 main.cpp)
target_link_libraries(untitled1 ${ULTRA_LIB})

主要.cpp

#include <AppCore/App.h>
#include <AppCore/Window.h>
#include <AppCore/Overlay.h>

using namespace ultralight;

int main()
{

auto app = App::Create();
auto window = Window::Create(app->main_monitor(), 300, 300, false, kWindowFlags_Titled);
window->SetTitle("Tutorial 2 - Basic App");
app->set_window(window);
auto overlay = Overlay::Create(window, window->width(), window->height(), 0, 0);
overlay->view()->LoadHTML("<center>Hello World!</center>");
app->Run();

return 0;
}

任何帮助都会对我有很大帮助 :) 谢谢

最佳答案

您为 find_library 错误地使用了 NAMES 参数:此参数包含 alternatives 列表,find_library 将导致只有一个单个库,它具有这些名称之一。

如果您想要找到多个库,则需要发出多个 find_library 命令,每个命令都有自己的名称(和自己的变量):

find_library(
ULTRA_LIB_CORE
NAMES UltralightCore
HINTS ${LINK_DIRS})

find_library(
ULTRA_LIB_APP_CORE
NAMES AppCore
HINTS ${LINK_DIRS})

find_library(
ULTRA_LIB
NAMES Ultralight
HINTS ${LINK_DIRS})

find_library(
ULTRA_LIB_WEB_CORE
NAMES WebCore
HINTS ${LINK_DIRS})

...

target_link_libraries(untitled1
${ULTRA_LIB_CORE} ${ULTRA_LIB_APP_CORE} ${ULTRA_LIB} ${ULTRA_LIB_WEB_CORE}
)

关于c++ - CMake 无法正确地将 ultralight ui 库链接到 Clion 2019.1.2 中的可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56258674/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com