gpt4 book ai didi

c++ - 与 Wt 示例组合时的链接错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:29:49 25 4
gpt4 key购买 nike

我正在为我的项目使用 C++ webframework。我正在尝试向 gitmodel 示例添加身份验证。

我收到以下错误:

../hangman/CMakeFiles/hangman.wt.dir/Session.o: In function `Session::Session()':     /home/s/Downloads/wt-3.2.3/examples/hangman/Session.C:101: undefined reference to `void Wt::Dbo::Session::mapClass<User>(char const*)'
../hangman/CMakeFiles/hangman.wt.dir/Session.o: In function `Wt::Auth::Dbo::AuthInfo<User>::user() const': /home/s/Downloads/wt-3.2.3/src/Wt/Auth/Dbo/AuthInfo:94: undefined reference to `Wt::Dbo::ptr<User>::ptr(Wt::Dbo::ptr<User> const&)'
../hangman/CMakeFiles/hangman.wt.dir/Session.o: In function `Session::user() const': /home/s/Downloads/wt-3.2.3/examples/hangman/Session.C:138: undefined reference to `Wt::Dbo::ptr<User>::operator bool() const'
/home/s/Downloads/wt-3.2.3/examples/hangman/Session.C:139: undefined reference to `User::User()'
/home/s/Downloads/wt-3.2.3/examples/hangman/Session.C:139: undefined reference to `Wt::Dbo::ptr<User> Wt::Dbo::Session::add<User>(User*)'
/home/s/Downloads/wt-3.2.3/examples/hangman/Session.C:139: undefined reference to `Wt::Dbo::ptr<User>::operator=(Wt::Dbo::ptr<User> const&)'

完整错误列表:http://pastie.org/5469803

我尝试使用 cmake 生成的 makefile。追查下来,发现这个链接器错误是在运行CMakeFiles目录下的link.txt后出现的。我尝试将 gitmodel 示例和 hangman 示例的 link.txt 结合起来,因为 hangman 也进行身份验证。这是我的 link.txt:

/usr/bin/c++   -O2 -g ../hangman/CMakeFiles/hangman.wt.dir/Session.o CMakeFiles/gitview.wt.dir/Git.o CMakeFiles/gitview.wt.dir/GitModel.o CMakeFiles/gitview.wt.dir/__/wt-homepage/SourceView.o CMakeFiles/gitview.wt.dir/GitView.o  -o gitview.wt -rdynamic -L/home/s/Downloads/wt-3.2.3/build/src/http -L/home/s/Downloads/wt-3.2.3/build/src -L/home/s/Downloads/wt-3.2.3/build/src/Wt/Dbo -L/home/s/Downloads/wt-3.2.3/build/src/Wt/Dbo/backend -lcrypt -L/usr/local/lib ../../src/http/libwthttp.so.3.2.3 ../../src/libwt.so.3.2.3 ../../src/Wt/Dbo/libwtdbo.so.3.2.3 ../../src/Wt/Dbo/backend/libwtdbosqlite3.so.3.2.3  /usr/local/lib/libboost_filesystem.so /usr/local/lib/libboost_random.so /usr/local/lib/libboost_regex.so /usr/local/lib/libboost_signals.so /usr/local/lib/libboost_system.so /usr/local/lib/libboost_filesystem.so -lz -lssl -lcrypto ../../src/Wt/Dbo/libwtdbo.so.3.2.3 /usr/local/lib/libboost_thread.so /usr/local/lib/libboost_program_options.so /usr/local/lib/libboost_date_time.so -lpthread -ldl -Wl,-rpath,/home/s/Downloads/wt-3.2.3/build/src/http:/home/s/Downloads/wt-3.2.3/build/src:/home/s/Downloads/wt-3.2.3/build/src/Wt/Dbo:/home/s/Downloads/wt-3.2.3/build/src/Wt/Dbo/backend:/usr/local/lib

馅饼链接:http://pastie.org/5469815

谁能告诉我我的链接命令有什么问题?

在运行 cmake 时,我明白了

/home/s/Downloads/wt-3.2.3/examples/gitmodel on master ✗ at  1:24PM 
➜ BOOST_FS_LIB=/usr/local/lib/libboost_filesystem.so cmake .
-- ** Not building gitmodel example: requires boost_filesystem library.
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 2.8)

should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/s/Downloads/wt-3.2.3/examples/gitmodel

最佳答案

看起来链接器没有找到 Dbo 符号。

如果您使用 cmake 进行编译,请提供您的 CMakelist.txt 好吗?

查看 gitmodel Cmakelist 和 auth Cmakelist 示例,将 wtdbowtdbosqlite3 添加到 TARGET_LINK_LIBRARIES 应该就足够了。

user@debiam:~$ cat /usr/lib/Wt/examples/gitmodel/CMakeLists.txt
IF(NOT WIN32)

IF(BOOST_FS_LIB)
WT_ADD_EXAMPLE(gitview.wt
Git.C
GitModel.C
../wt-homepage/SourceView.C
GitView.C
)
TARGET_LINK_LIBRARIES(gitview.wt ${BOOST_FS_LIB} ${BOOST_SIGNALS_LIB} ${BOOST_SYSTEM_LIB})

INCLUDE_DIRECTORIES(
${WT_SOURCE_DIR}/src
)

ADD_DEPENDENCIES(gitview.wt wt ${EXAMPLES_CONNECTOR})

ELSE(BOOST_FS_LIB)

MESSAGE(STATUS "** Not building gitmodel example: requires boost_filesystem library.")

ENDIF(BOOST_FS_LIB)

ELSE(NOT WIN32)

MESSAGE(STATUS "** Not building gitmodel example: uses POSIX calls not available on win32")

ENDIF(NOT WIN32)

.

user@debiam:~$ cat /usr/lib/Wt/examples/feature/auth1/CMakeLists.txt
WT_ADD_EXAMPLE(auth1.wt
Auth1.C
model/Session.C
model/User.C
)

TARGET_LINK_LIBRARIES(auth1.wt wtdbo wtdbosqlite3 ${BOOST_SIGNALS_LIB} ${BOOST_SYSTEM_LIB})

INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src)

关于c++ - 与 Wt 示例组合时的链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13676990/

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