Project

General

Profile

Wt cmake build

Added by Jahn Mueller 2 months ago

I am new to Wt and I am trying to build the HelloApplication project (https://www.webtoolkit.eu/wt/doc/tutorial/wt.html) using cmake. For this purpose I have clone the official repository of Wt and install it on a Debian system.

Furthermore I have created the following CMakeLists.txt:
`make_minimum_required(VERSION 3.14 FATAL_ERROR)

project(WtTestProject)

Debug or Release

if (NOT CMAKE_BUILD_TYPE)
## set default to Debug
set(CMAKE_BUILD_TYPE Debug) # override with -DCMAKE_BUILD_TYPE=Debug
message("==> CMAKE_BUILD_TYPE empty. Changing it to Release.")
else()
message("==> CMAKE_BUILD_TYPE == ${CMAKE_BUILD_TYPE}.")
endif()

find_package(Boost REQUIRED)
find_package(Wt REQUIRED)

set(SOURCES
src/main.cpp
src/HelloApplication.cpp
)

ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})

target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)`

However, it did not work and I am getting the following linking error while trying to build the project:
[main] Building folder: WtHelloApp
[build] Starting build
[proc] Executing command: /usr/local/bin/cmake --build /workspaces/WtHelloApp/build --config Debug --target all -- -j 10
[build] Scanning dependencies of target WtDesignerTestProject
[build] [ 66%] Building CXX object CMakeFiles/WtDesignerTestProject.dir/src/main.cpp.o
[build] [ 66%] Building CXX object CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o
[build] [100%] Linking CXX executable WtDesignerTestProject
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/main.cpp.o: in function
main':
[build] /workspaces/WtHelloApp/src/main.cpp:5: undefined reference to Wt::WRun(int, char**, std::function<std::unique_ptr<Wt::WApplication, std::default_delete<Wt::WApplication> > (Wt::WEnvironment const&)>)'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function
HelloApplication::HelloApplication(Wt::WEnvironment const&)::{lambda()#1}::operator()() const':
[build] /workspaces/WtHelloApp/src/HelloApplication.cpp:14: undefined reference to Wt::operator+(char const*, Wt::WString const&)'
[build] /usr/bin/ld: /workspaces/WtHelloApp/src/HelloApplication.cpp:14: undefined reference to
Wt::WText::setText(Wt::WString const&)'
[build] /usr/bin/ld: /workspaces/WtHelloApp/src/HelloApplication.cpp:14: undefined reference to Wt::WString::~WString()'
[build] /usr/bin/ld: /workspaces/WtHelloApp/src/HelloApplication.cpp:14: undefined reference to
Wt::WString::~WString()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function HelloApplication::HelloApplication(Wt::WEnvironment const&)':
[build] /workspaces/WtHelloApp/src/HelloApplication.cpp:4: undefined reference to
Wt::WApplication::WApplication(Wt::WEnvironment const&, Wt::WtLibVersion)'
[build] /usr/bin/ld: /workspaces/WtHelloApp/src/HelloApplication.cpp:6: undefined reference to Wt::WString::WString(char const*, Wt::CharEncoding)'
[build] /usr/bin/ld: /workspaces/WtHelloApp/src/HelloApplication.cpp:6: undefined reference to
Wt::WApplication::setTitle(Wt::WString const&)'
[build] /usr/bin/ld: /workspaces/WtHelloApp/src/HelloApplication.cpp:6: undefined reference to Wt::WString::~WString()'
[build] /usr/bin/ld: /workspaces/WtHelloApp/src/HelloApplication.cpp:16: undefined reference to
Wt::WInteractWidget::clicked()'
[build] /usr/bin/ld: /workspaces/WtHelloApp/src/HelloApplication.cpp:16: undefined reference to Wt::Signals::Impl::Connection::~Connection()'
[build] /usr/bin/ld: /workspaces/WtHelloApp/src/HelloApplication.cpp:6: undefined reference to
Wt::WString::~WString()'
[build] /usr/bin/ld: /workspaces/WtHelloApp/src/HelloApplication.cpp:4: undefined reference to Wt::WApplication::~WApplication()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function
Wt::Signals::Impl::Connection Wt::EventSignalWt::WMouseEvent::connect(HelloApplication::HelloApplication(Wt::WEnvironment const&)::{lambda()#1})':
[build] /usr/local/include/Wt/WSignal.h:804: undefined reference to Wt::EventSignalBase::exposeSignal()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function
std::MakeUniqWt::WText::single_object std::make_unique(char const (&) [20])':
[build] /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to Wt::WString::WString(char const*, Wt::CharEncoding)'
[build] /usr/bin/ld: /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to
Wt::WText::WText(Wt::WString const&)'
[build] /usr/bin/ld: /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to Wt::WString::~WString()'
[build] /usr/bin/ld: /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to
Wt::WString::~WString()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function `std::_MakeUniqWt::WLineEdit::
single_object std::make_uniqueWt::WLineEdit()':
[build] /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to Wt::WLineEdit::WLineEdit()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function
std::_MakeUniqWt::WPushButton::
single_object std::make_unique(char const (&) [10])':
[build] /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to Wt::WString::WString(char const*, Wt::CharEncoding)'
[build] /usr/bin/ld: /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to
Wt::WPushButton::WPushButton(Wt::WString const&)'
[build] /usr/bin/ld: /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to Wt::WString::~WString()'
[build] /usr/bin/ld: /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to
Wt::WString::~WString()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function `std::_MakeUniqWt::WBreak::
single_object std::make_uniqueWt::WBreak()':
[build] /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to Wt::WBreak::WBreak()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function
std::_MakeUniqWt::WText::
single_object std::make_uniqueWt::WText()':
[build] /usr/include/c++/8/bits/unique_ptr.h:831: undefined reference to Wt::WText::WText()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function
Wt::Signals::Impl::ProtoSignalWt::WMouseEvent::SignalLink::add_before(std::function&&, Wt::Core::observable const*)':
[build] /usr/local/include/Wt/Signals/signals.hpp:147: undefined reference to Wt::Signals::Impl::SignalLinkBase::connect(Wt::Core::observable const*)'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function
Wt::Signals::Impl::ProtoSignalWt::WMouseEvent::SignalLink::SignalLink()':
[build] /usr/local/include/Wt/Signals/signals.hpp:100: undefined reference to Wt::Signals::Impl::SignalLinkBase::SignalLinkBase(void (*)(Wt::Signals::Impl::SignalLinkBase*))'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function
Wt::Signals::Impl::ProtoSignalWt::WMouseEvent::SignalLink::~SignalLink()':
[build] /usr/local/include/Wt/Signals/signals.hpp:105: undefined reference to Wt::Signals::Impl::SignalLinkBase::~SignalLinkBase()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x20): undefined reference to
Wt::WObject::idabi:cxx11 const'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x28): undefined reference to `Wt::WObject::setObjectName(std::
cxx11::basic_string, std::allocator > const&)'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x30): undefined reference to Wt::WObject::objectName[abi:cxx11]() const'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x38): undefined reference to
Wt::WObject::signalConnectionsChanged()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x40): undefined reference to Wt::WObject::setFormData(Wt::WObject::FormData const&)'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x48): undefined reference to
Wt::WObject::setRequestTooLarge(long)'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x50): undefined reference to Wt::WObject::getStateless(void (Wt::WObject::*)())'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x58): undefined reference to
Wt::WApplication::refresh()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x60): undefined reference to `Wt::WApplication::makeAbsoluteUrl(std::
cxx11::basic_string, std::allocator > const&) const'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x68): undefined reference to Wt::WApplication::waitForEvent()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x70): undefined reference to
Wt::WApplication::initialize()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x78): undefined reference to Wt::WApplication::finalize()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x80): undefined reference to
Wt::WApplication::notify(Wt::WEvent const&)'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x88): undefined reference to Wt::WApplication::isExposed(Wt::WWidget*) const'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x90): undefined reference to
Wt::WApplication::enableAjax()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0x98): undefined reference to Wt::WApplication::unload()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0xa0): undefined reference to
Wt::WApplication::idleTimeout()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTV16HelloApplication[_ZTV16HelloApplication]+0xa8): undefined reference to `Wt::WApplication::handleJavaScriptError(std::
_cxx11::basic_string, std::allocator > const&)'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o: in function HelloApplication::~HelloApplication()':
[build] /workspaces/WtHelloApp/inc/HelloApplication.h:8: undefined reference to
Wt::WApplication::~WApplication()'
[build] /usr/bin/ld: CMakeFiles/WtDesignerTestProject.dir/src/HelloApplication.cpp.o:(.data.rel.ro._ZTI16HelloApplication[_ZTI16HelloApplication]+0x10): undefined reference to typeinfo for Wt::WApplication'
[build] collect2: error: ld returned 1 exit status
[build] make[2]: *** [CMakeFiles/WtDesignerTestProject.dir/build.make:118: WtDesignerTestProject] Error 1
[build] make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/WtDesignerTestProject.dir/all] Error 2
[build] make: *** [Makefile:103: all] Error 2
[build] Build finished with exit code 2

Can anyone pls help me?


Replies (2)

RE: Wt cmake build - Added by Jahn Mueller 2 months ago

I could fix it :D

RE: Wt cmake build - Added by Mark Travis 2 months ago

I have never had trouble building Wt from the documentation. https://www.webtoolkit.eu/wt/doc/reference/html/InstallationUnix.html

    (1-2/2)