c++ - Ubuntu 上的 Google Earth C++ API 库错误

标签 c++ linux api terminal google-earth

我是这个论坛的新手,但我在尝试寻找此问题的解决方案时已经看过几次。我正在尝试使用我为 Ubuntu (libkml-dev_1.2.0-1ubuntu6_amd64) 找到的 C++ API 库生成要在 Google 地球中使用的 KML 文件。我使用命令 sudo apt-get install libkml-dev 安装了软件包,成功返回。之后,我使用命令行终端导航到示例文件夹,尝试使用命令 g++ helloworld.cc -o helloworld 执行程序“helloworld.cc”,但随后出现了一系列错误(主要是声称 kmldom 是一个 undefined reference )。抱歉,我想附上文本文件,但不知道怎么做,所以我在下面包含了一个错误示例。我整个星期都在上下搜索,确保头文件确实包含在下载中,甚至就这个问题联系了 Google Earth 开发人员(他们回应说他们与此无关,并重定向了所有关于这个问题发给 StackOverflow)。

有谁知道是什么导致了这个问题,我可以做些什么来解决这个问题以便我继续前进?


/tmp/cc5u2JyV.o:在函数中HelloKml(bool)': helloworld.cc:(.text+0x17): undefined reference to kmldom::KmlFactory::GetFactory()' helloworld.cc:(.text+0x27): 未定义对 kmldom::KmlFactory::CreateCoordinates() const' helloworld.cc:(.text+0x328): undefined reference to 的引用kmldom::AsPoint(boost::intrusive_ptrkmldom::Element)' /tmp/cc5u2JyV.o: 在函数中 boost::intrusive_ptr<kmldom::Coordinates>::intrusive_ptr(kmldom::Coordinates*, bool)': helloworld.cc:(.text._ZN5boost13intrusive_ptrIN6kmldom11CoordinatesEEC2EPS2_b[_ZN5boost13intrusive_ptrIN6kmldom11CoordinatesEEC5EPS2_b]+0x3d): undefined reference to kmlbase::intrusive_ptr_add_ref(kmlbase::Referent*)' /tmp/cc5u2JyV.o: 在函数中 boost::intrusive_ptr<kmldom::Coordinates>::~intrusive_ptr()': helloworld.cc:(.text._ZN5boost13intrusive_ptrIN6kmldom11CoordinatesEED2Ev[_ZN5boost13intrusive_ptrIN6kmldom11CoordinatesEED5Ev]+0x23): undefined reference to kmlbase::intrusive_ptr_release(kmlbase::Referent*)' /tmp/cc5u2JyV.o: 在函数中 boost::intrusive_ptr<kmldom::Geometry>::intrusive_ptr(boost::intrusive_ptr<kmldom::Geometry> const&)': helloworld.cc:(.text._ZN5boost13intrusive_ptrIN6kmldom8GeometryEEC2ERKS3_[_ZN5boost13intrusive_ptrIN6kmldom8GeometryEEC5ERKS3_]+0x35): undefined reference to kmlbase::intrusive_ptr_add_ref(kmlbase::Referent*)' collect2: ld 返回 1 个退出状态

最佳答案

当您编译使用库的应用程序时,您需要在应用程序编译时链接它。所以,尝试使用这个参数:

要指定搜索库的目录,请使用 -L:

-L/data[...]/lib

要指定实际的库名称,请使用 -l:

-labc(链接 abc.a 或 abc.so)

要指定搜索包含文件的目录,请使用 -I:

-I/data[...]/lib

关于c++ - Ubuntu 上的 Google Earth C++ API 库错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11054448/

相关文章:

c++ - 是否可以在重定向前读取 STDOUT?

linux - 等待子进程但出现错误 : 'pid is not a child of this shell'

javascript - 将 Outlook 与 JS Web 应用程序集成

c++ - 创建线程时有多少开销?

c++ - 类元组类型(元组、对)的模板重载

c++ - 转发引用和正常引用的部分排序与推导指南

php - 500 内部服务器 - Apache

json - 使用 SwiftUI 解码 API 调用中的嵌套 JSON 响应时遇到问题

api - 在 Firebase 的 POST 请求中丢弃空数组

c++ - 海合会 LTO : Limit scope of optimization