Google 地球在 Ubuntu 上C++ API 库错误
Google Earth C ++ API Library Errors on Ubuntu
我是这个论坛的新手,但我在尝试寻找这个问题的解决方案时已经看过几次了。我正在尝试使用我为 Ubuntu 找到的 C++ API 库(libkml-dev_1.2.0-1ubuntu6_amd64)生成要在 Google 地球中使用的 KML 文件。我使用命令sudo apt-get install libkml-dev安装了软件包,回来成功了。之后,我使用命令行终端导航到 examples 文件夹,尝试使用命令 g++ helloworld.cc -o helloworld 执行程序"helloworld.cc",但随后出现了一系列错误(主要声称 kmldom 是一个未定义的引用)。抱歉,我想附加文本文件,但不知道如何附加,所以我在下面包含一个错误示例。我整个星期都在搜索高低,确保头文件确实包含在下载中,甚至就此问题联系了Google地球开发人员(他们回答说他们与此无关,并将有关此问题的所有问题重定向到StackOverflow)。
有谁知道导致此问题的原因以及我可以做些什么来解决这个问题,以便我可以继续前进?
<小时 />/tmp/cc5u2JyV.o: In function 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: In function 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: In function 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: In function 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*)'收集2:LD 返回 1 个退出状态
编译使用库的应用程序时,需要在应用程序编译时链接它。因此,请尝试使用以下参数:
要指定用于搜索库的目录,请使用 -L:
-L/data[...]/lib
要指定实际的库名称,请使用 -l:
-labc
(链接 abc.a 或 abc.so)
指定要搜索包含文件的目录,请使用 -I:
-I/data[...]/lib
我已经找到了解决方案。问题是你正在直接链接 libkml。您应该找到头文件和库文件 (*.so) 的路径。我在这里找到了它们:
/usr/include/kml/
(包括带有标题的 dit),
/usr/lib/x86_64-linux-gnu/
(图书馆目录)。
和 CMakeLists.txt 用于一个项目。使用 libkml 可能如下所示:
`cmake_minimum_required (VERSION 3.2)
# Set language standard
set(CMAKE_CXX_STANDARD "11")
project (test_proj)
add_definitions(-std=c++11)
# Set default build type to RelWithDebInfo if not specified
if (NOT CMAKE_BUILD_TYPE)
message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info")
set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE
STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel"
FORCE)
endif()
# linking boost library
find_package(Boost COMPONENTS system filesystem thread REQUIRED)
if(NOT Boost_FOUND)
message(SEND_ERROR "Failed to find boost.")
return()
else()
include_directories(${Boost_INCLUDE_DIRS})
endif()
add_executable(test_proj main.cpp)
set (LibKML_INCLUDE_DIRS /usr/include/kml/)
set (LibKML_LIBRARIES /usr/lib/x86_64-linux-gnu/libkmlbase.so /usr/lib/x86_64-linux-gnu/libkmlconvenience.so /usr/lib/x86_64-linux-gnu/libkmldom.so /usr/lib/x86_64-linux-gnu/libkmlengine.so /usr/lib/x86_64-linux-gnu/libkmlregionator.so /usr/lib/x86_64-linux-gnu/libkmlxsd.so)
message("LibKML is at: ${LibKML_INCLUDE_DIRS} and ${LibKML_LIBRARIES}")
message("Boost is at: ${Boost_INCLUDE_DIRS} and ${Boost_LIBRARIES}")
target_include_directories(test_proj
PUBLIC
${LibKML_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} )
target_link_libraries(test_proj
PUBLIC
${LibKML_LIBRARIES} ${Boost_LIBRARIES})
install(TARGETS test_proj EXPORT test_proj_export)
export(EXPORT test_proj_export FILE cmake/test_proj-targets.cmake)`
- 第三方 API 中的编译错误 - Visual Studio
- 分段错误(核心转储) - 使用 SavedModel 的 Tensorflow C++ API 进行推断
- 如何修复无效的API密钥,IP或操作权限错误?
- 使用 lua 协程 API 和lua_close时出现分段错误
- 两个线程一个使用流 Api,另一个线程创建文件失败并出现错误ERROR_SHARING_VIOLATION
- Win32 API - HWND "{unused = ???} Unable to read memory"错误
- 设置我的应用程序 API 感知并防止系统使其模糊和错误定位
- 从谷歌日历API获取错误请求
- 创建进程 API 失败,在窗口 122 上出现错误代码 10
- Windows上的Flite API错误
- QScreen geometry()api为分辨率2736 x 1824和2560 x 1600提供了错误的值
- cuda-gdb 给出错误"warning: Cuda API error detected: cudaLaunchKernel returned (0x7)"
- 使用N-API时如何避免分段错误
- 来自API的错误代码..处理什么是好的做法
- 内部编译器错误Visual Studio Community 2017与SFML API
- 节点 API 抛出自己的错误消息,而不是自己的错误消息
- azure-iot-sdk-c API IoTHubClient_LL_DoWork()失败并显示大量错误
- 如何在使用CreateRemoteThread API时修复"LPVOID: unknown size"错误?
- 任务调度程序API错误80041318
- 如何找到检测到 Cuda API 错误时程序崩溃的位置:cudaMemcpy 返回 (0xb)