Hi i'm trying to build a basic app using ultralight https://github.com/ultralight-ux/Ultralight . However the build is failing at the linking stage. I have gone through through a lot of other answers and not getting any progress.
The Cmake error:
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'
The 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})
main.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;
}
Any help will do great good to me :) Thank you
You incorrectly use NAMES
parameter for find_library
: this parameter contains list of alternatives , and find_library
will result only with a single library , which has one of those names.
If you want several libraries to be found, you need to issue several find_library
commands, each with its own name (and its own variable):
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}
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.