1

I'm trying to compile a program in CLion that uses the Assimp library using the MinGW compiler. When building the project it gets up to 77% and gives the following error on the file "SMDLoader.cpp.obj":

C:\Dev\AssimpTest\cmake-build-debug\_deps\assimp-src\code\SMDLoader.cpp: In member function 'void Assimp::SMDImporter::GetAnimationFileList(const string&, Assimp::IOSystem*, std::vector<std::tuple<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)':
C:\Dev\AssimpTest\cmake-build-debug\_deps\assimp-src\code\SMDLoader.cpp:579:47: error: 'strtok_s' was not declared in this scope
 tok1 = strtok_s(&buf[0], "\r\n", &context1);
                                           ^
_deps\assimp-build\code\CMakeFiles\assimp.dir\build.make:2246: recipe for target '_deps/assimp-build/code/CMakeFiles/assimp.dir/SMDLoader.cpp.obj' failed

This is the CMakeLists.txt file i'm using:

cmake_minimum_required(VERSION 3.13)
project(AssimpTest)

set(CMAKE_CXX_STANDARD 11)

find_package(assimp 4.1.0 QUIET)

if (NOT assimp_FOUND)
include(FetchContent)

FetchContent_Declare(
        assimp
        URL https://github.com/assimp/assimp/archive/master.tar.gz
)

FetchContent_GetProperties(raylib)
if (NOT assimp_POPULATED)
    set(FETCHCONTENT_QUIET NO)
    FetchContent_Populate(assimp)

    set(CMAKE_BUILD_TYPE release CACHE STRING "" FORCE)
    set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE)

    add_subdirectory(${assimp_SOURCE_DIR} ${assimp_BINARY_DIR})

endif()

endif()

add_executable(AssimpTest main.cpp)
target_link_libraries(${PROJECT_NAME} assimp)

Here's the main file i'm trying to compile, just in case:

#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

int main() {
    Assimp::Importer importer;

    const char* pFile = R"(C:\Dev\raycast\models\teapot.fbx)";

    const aiScene* scene = importer.ReadFile( pFile,
                                          aiProcess_CalcTangentSpace       |
                                          aiProcess_Triangulate            |
                                          aiProcess_JoinIdenticalVertices  |
                                          aiProcess_SortByPType);
    if( !scene)
    {
        printf(importer.GetErrorString());
        return -1;
    }
    printf("Num meshes: %i", scene->mNumMeshes);

    return 0;
}

The main reason i'm trying to use Assimp is to import .fbx models into my program, so if there is any way to optimize all of this setup just for that, that would be really helpful! The information i found about the usage of this library with MinGW on the internet was really scarce.

Anyway thanks for help in advance.

  • Possible duplicate of [Why didn't gcc implement \_s functions?](https://stackoverflow.com/questions/50724726/why-didnt-gcc-implement-s-functions) – Mike Kinghan Jan 30 '19 at 11:26

3 Answers3

1

If you don't need the SMD loader, you can simply disable it. Go to File -> Settings -> Build, Execution, Deployment -> CMake and insert "-DASSIMP_BUILD_SMD_LOADER=NO" (without " ") into CMake options

1

GCC does not implement the _s functions. The solution is to change the #indef condition at the top of the SMDloader.cpp to check agains _MSC_VER instead of _WIN32:

#ifndef _MSC_VER
#define strtok_s strtok_r
#endif
matepal297
  • 961
  • 1
  • 11
  • 19
0

Which mingw- and assimp-version do you use? Mingw is part of the CI-buildchain we are using to test the assimp-code and this issue shall not occur anymore. So if this issue is on our current master we need to fix it.

And which kind of information do you miss when using mingw? I will try to optimize this.

Thanks!

KimKulling
  • 2,654
  • 1
  • 15
  • 26