Including Assimp (V3.1.1) in a VS2017 project

0

I am under Windows and developing an c++ application using VS2017 (created with Cmake). I am including a library (in the following: plib) which itself depends on Assimp (v3.1.1). As long as I don't include any method from Assimp the whole program works. As soon as I include a single Assimp-Header and create an object the program crashes on startup with return code 0xc000007b. Example:

#include <assimp\Importer.hpp>
int main() {
    Assimp::Importer importer;
    return 0;
}

Even when I comment the line Assimp::Importer importer; the application crashes until I tell VS2017 to not only build but re-build the project files. Can anyone tell me why this problem occurs and how to solve it?

Excerpt from my CMakeLists:

set(plib_DIR "C:/[...]/plib")
find_package(plib REQUIRED)

list(APPEND project_INCLUDES ${SCREEN_INCLUDE_DIRS})
list(APPEND project_LIBRARIES ${SCREEN_LIBRARIES})

Excerpt from plib's CMakeLists:

set(ASSIMP_DIR ${assimp_DIR})
find_package(assimp REQUIRED)

list(APPEND project_INCLUDES ${ASSIMP_INCLUDE_DIRS})
list(APPEND project_LIBRARIES "${ASSIMP_LIBRARY_DIRS}/${ASSIMP_LIBRARIES}.lib")

assimp_DIR is set as an environment variable pointing to the directory where I downloaded the Assimp 3.1.1 release and compiled it. I moved the "lib32/assimp.lib" file to "lib/assimp-vc100-mt.lib" for Cmake to find it. I also changed the beginning of assimp-config.cmake.in for the ASSIMP_ROOT_DIR to be found correctly (I used an in-source-build):

get_filename_component(_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
#get_filename_component(_PREFIX "${_PREFIX}" PATH)
#get_filename_component(_PREFIX "${_PREFIX}" PATH)
get_filename_component(ASSIMP_ROOT_DIR "${_PREFIX}" PATH)
c++
linker
visual-studio-2017
assimp
asked on Stack Overflow Jan 19, 2018 by René Martin

1 Answer

0

You have not specified that you want to use a static lib from assimp. So my guess is you want to use the dll-version of Assimp:

Your application is not able to find the assimp.dll .You need to add the folder containing the assimp-dlls to your PATH-variable. Another option is to copy the dll'S into the starting folder of your application.

What happens: When your application is up and running and you want to call one function / class method from the assimp-lib it needs to load the dll, cannot find it and your application will crash.

answered on Stack Overflow Jan 22, 2018 by KimKulling

User contributions licensed under CC BY-SA 3.0