I have the following test program (test.gltf is a file containing just "{}"):
#include "assimp/Importer.hpp"
#include "assimp/postprocess.h"
#include "assimp/scene.h"
#include "rapidjson/document.h"
#include <iostream>
int main()
{
std::cout << "reading test" << std::endl;
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile("test.gltf", {});
std::cout << "SUCCESS" << std::endl;
std::cout << "testing document" << std::endl;
rapidjson::Document document;
std::cout << document.HasMember("product") << std::endl;
return 0;
}
When I run this I get an error on the ReadFile call:
main: /home/sanderv/dev/twikbot-core/external/assimp/code/../contrib/rapidjson/include/rapidjson/document.h:1336: rapidjson::GenericValue::MemberIterator rapidjson::GenericValue<rapidjson::UTF8<>>::FindMember(const GenericValue<Encoding, SourceAllocator> &) [Encoding = rapidjson::UTF8<>, Allocator = rapidjson::MemoryPoolAllocator<>, SourceAllocator = rapidjson::MemoryPoolAllocator<>]: Assertion `IsObject()' failed.
This is odd because ReadFile should work, and just return nullptr. When I remove the call to document.HasMember in the above program this does work. Stepping through the code shows that something very odd is going on, on stepping into the actual FindMember function the *this object looks corrupt.
The cause was in the way the program is built, I'm using static libraries. Assimp is built using
If I compile the above test program with these flags (looks like specifically the last one is needed) then the odd behavior goes away. It had to be something like this of course, my knowledge of compilers and linkers is too limited to know exactly what's wrong, besides that statically linking against basically two slightly different versions of rapidjson is a no-go.