0

命令:

g++ -o "webserver" ./webserver.o -lwtdbopostgres -lwtdbo -lwthttp -lwt -lboost_signals

可怕的,可怕的输出:

./webserver.o: In function `Wt::Dbo::Impl::QueryBase<Wt::Dbo::ptr<pool::db::Settings> >::statements(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int) const':
webserver.cpp (.text._ZNK2Wt3Dbo4Impl9QueryBaseINS0_3ptrIN4pool2db8SettingsEEEE10statementsERKSsSA_SA_ii[Wt::Dbo::Impl::QueryBase<Wt::Dbo::ptr<pool::db::Settings> >::statements(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int) const]+0x1b3): undefined reference to `Wt::Dbo::Impl::completeQuerySelectSql(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, std::vector<Wt::Dbo::FieldInfo, std::allocator<Wt::Dbo::FieldInfo> > const&, bool)'
webserver.cpp:(.text._ZNK2Wt3Dbo4Impl9QueryBaseINS0_3ptrIN4pool2db8SettingsEEEE10statementsERKSsSA_SA_ii[Wt::Dbo::Impl::QueryBase<Wt::Dbo::ptr<pool::db::Settings> >::statements(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int) const]+0x25c): undefined reference to `Wt::Dbo::Impl::createQueryCountSql(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, bool)'
Many, many more lines...

稍微提取错误消息:

undefined reference to `Wt::Dbo::Impl::completeQuerySelectSql
undefined reference to `Wt::Dbo::Impl::createQueryCountSql
undefined reference to `Wt::Dbo::Impl::createWrappedQueryCountSql
...

为什么找不到这些?它与-lwtdbo和链接-lwtdbopostgres,这是项目设置附带的。这是在我手动下载、编译和安装最新的 wt 版本之后。以前我已经使用它们apt-get并且我遇到了一组不同的错误,尽管仍然与未定义的引用相关。

4

1 回答 1

0

libwtdbopostgres.so 和 libwtdbo.so 可能不在您的库路径中。检查您的 $LD_LIBRARY_PATH 以查看这些库所在的路径是否出现。

或者尝试使用 -L 来指定两个库的路径

IE:

g++ -o "webserver" -L/home/libs ./webserver.o -lwtdbopostgres -lwtdbo... etc..
于 2014-06-06T14:57:33.767 回答