错误:重复符号,当包含本身包含库的类时

问题描述 投票:0回答:1

我正在尝试解决以下问题: 我导入了一个仅标头库,该库本身包含另一个仅标头库。 tiny_gtlf.h 包含 stb_image.h。我有一个名为 GLTFLoader .cpp/.h 的类,头文件包含tiny_gltf.h 文件。现在,当我将我的类包含在 main.cpp 中时,我收到重复符号错误,并且我不确定如何准确修复这个特定错误。 预先感谢

ld: error: duplicate symbol: stbi_failure_reason
>>> defined at stb_image.h:976 (C:/Users/<user>/AndroidStudioProjects/WallpaperEngine/app/src/main/cpp/headers/../engine/../engine/loaders/../../tinygltf-2.8.16/stb_image.h:976)
>>>            CMakeFiles/wallpaperengine.dir/main.cpp.o:(stbi_failure_reason)
>>> defined at stb_image.h:976 (C:/Users/<user>/AndroidStudioProjects/WallpaperEngine/app/src/main/cpp/engine/loaders/../../tinygltf-2.8.16/stb_image.h:976)
>>>            CMakeFiles/wallpaperengine.dir/engine/loaders/GLTFLoader.cpp.o:(.text.stbi_failure_reason+0x0)
c++ android-ndk
1个回答
0
投票

在 GLTFLoader.cpp 和 main.cpp 中包含任何内容之前,您似乎错过了

#define STB_IMAGE_STATIC
,或者在编译器设置中错过了
-DSTB_IMAGE_STATIC

© www.soinside.com 2019 - 2024. All rights reserved.