[英]STB Image Implementation with tinygltf and sfml
我在我的项目中同时包含了 tinygltf 和 sfml。 当我在这些选项中包含 tinygltf 时:
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <tiny_gltf.h>
我收到多个定义错误:
/usr/bin/ld.gold: error: sfml/lib/libsfml-graphics-s.a(ImageLoader.cpp.o): multiple definition of 'stbi_write_jpg'
/usr/bin/ld.gold: _objs/client_lib/loader.pic.o: previous definition here
这只是错误的一小部分,但对于大多数 stb 函数,存在类似的错误。 所以我试图通过像这样包含 tinygltf 来解决这个问题:
#define TINYGLTF_IMPLEMENTATION
#include <tiny_gltf.h>
但是,现在只有一个单一的错误:
_objs/client_lib/loader.pic.o:loader.cpp:function tinygltf::LoadImageData(tinygltf::Image*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, int, int, unsigned char const*, int, void*): error: undefined reference to 'stbi_is_16_bit_from_memory'
似乎这两个库依赖于略有不同的 stb 版本。 有没有什么办法解决这一问题?
我使用的是 tinygltf 2.2.0 版和 sfml 2.5.1 版。
由于您静态链接 SFML,因此您将 SFML 的所有符号集成到您的应用程序中,包括 STB 符号。
我在这里看到两种不同的解决方案,也许还有更多:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.