Download

Assimp Importer linker error when building from scratch

Recently I’ve been trying to load external meshes at runtime. To do so, I used the RuntimeMeshLoader repo, which came with assimp pre-built. Now I’m trying to replace this plugin with my own assimp build, so I downloaded assimp from the github repo and compiled it from source. However, after removing the old plugin, pasting in my own assimp build, and adding the assimp include and lib directories to my build.cs file, I’m running into a linker error when I try to instantiate the Assimp Importer. This is the same code as before, so I suspect something went wrong with the build process, but I’m really stuck as to what it is. Any advice would be greatly appreciated! Relevant section of console below:
CompilerResultsLog:Error: Error BlockTypes.cpp.obj : error LNK2019: unresolved external symbol “public: __cdecl Assimp::Importer::Importer(void)” (??0Importer@Assimp@@QEAA@XZ) referenced in function “private: void __cdecl ABlockTypes::loadModel(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)” (?loadModel@ABlockTypes@@
AEAAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

CompilerResultsLog:Error: Error BlockTypes.cpp.obj : error LNK2019: unresolved external symbol “public: __cdecl Assimp::Importer::~Importer(void)” (??1Importer@Assimp@@QEAA@XZ) referenced in function “private: void __cdecl ABlockTypes::loadModel(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)” (?loadModel@ABlockTypes@
@AEAAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

CompilerResultsLog:Error: Error BlockTypes.cpp.obj : error LNK2019: unresolved external symbol “public: struct aiScene const * __cdecl Assimp::Importer::ReadFile(char const *,unsigned int)” (?ReadFile@Importer@Assimp@@QEAAPEBUaiScene@@PEBDI@Z) referenced in function “private: void __cdecl ABlockTypes::loadModel(class std::basic_string<char,struct std::char_t
raits<char>,class std::allocator<char> >)” (?loadModel@ABlockTypes @AEAAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

CompilerResultsLog: Info C:\Users…\TestThirdPerson\Plugins\assimp-master\lib\Debug\assimp-vc140-mt.lib : warning LNK4272: library machine type ‘X86’ conflicts with target machine type ‘x64’

CompilerResultsLog:Error: Error C:\Users…\TestThirdPerson\Binaries\Win64\UE4Editor-TestThirdPerson-2004.dll : fatal error LNK1120: 3 unresolved externals

Here is the code that is triggering this compile error:
*void ABlockTypes::loadModel(std::string path) {
Assimp::Importer importer;

const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_GenNormals);

if (!scene)
	return;

_meshCurrentlyProcessed = 0;
processNode(scene-&gt;mRootNode, scene);

}*

Just wanted to update that I have solved this issue. I’m not sure exactly what the cause was, but I recompiled assimp from source for Win64, double checked the include and lib directories for assimp in my Build.cs, and refreshed the Visual Studio Project, and it now compiles successfully!

EDIT: The previous error is gone, however after I edit the files that utilize assimp and try to recompile I encounter the error, “The program can’t start because assimp-vc140-mt.dll is missing from your computer. Try reinstalling the program to fix this problem.” After this, the compile button in Unreal disappears entirely, and the only way to get it back is to delete the contents of the “Binaries” folder. The dll in question is located in the “bin\Debug” folder within assimp, as is the main assimp executable, so I’m not sure why Unreal cannot locate it.

Solved it for real this time. The dll error was resolved by placing a copy of “assimp-vc140-mt.dll” in my “Binaries/Win64” folder.

I know its a few years late, but could you kindly share your Build.cs file or at least point to some link where it clearly explains how to compile external libraries in ue4? Many thanks in advance.

Sure thing. The contents of my Build.cs file have been pasted below. As this project is a few years old I don’t remember too much about it, but it seems like at the time I downloaded the latest version of assimp and placed it directly in my project under a new folder titled “Plugins”.



using UnrealBuildTool;

public class TestThirdPerson : ModuleRules {

    public string ProjectRoot {
        get {
            return System.IO.Path.GetFullPath(System.IO.Path.Combine(ModuleDirectory, "../../"));
        }
    }

    public TestThirdPerson(TargetInfo Target) {
        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });

        //include JSON file handling
        PublicDependencyModuleNames.AddRange(new string] { "Json", "JsonUtilities" });

        //include procedural generation components
        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "ProceduralMeshComponent" });

        //include assimp
        PublicIncludePaths.Add(ProjectRoot + "Plugins\\assimp-master\\include");
        PublicAdditionalLibraries.Add(ProjectRoot + "Plugins\\assimp-master\\lib\\Debug\\assimp-vc140-mt.lib");
   }
}


Thank you so much. I was finally able to compile it for Win64 Platform. I had to modify the code slightly since the Library is in assimp/Libraries folder and the includes are in the assimp/Includes folder. Also, the syntax has been updated slightly as I’m using UE4.25.3. I’ve compiled it against Assimp 5.0.1. I’ll paste the code below in case if helps aybody in future.



using System;
using System.IO;
using UnrealBuildTool;


public class Assimp_TestProject : ModuleRules { public string ProjectRoot {
  [INDENT=2]get {
return System.IO.Path.GetFullPath(System.IO.Path.Combine(ModuleDirectory, "../../"));
}[/INDENT]
  }

public Assimp_TestProject(ReadOnlyTargetRules Target) : base(Target)
{
  [INDENT=2]PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });

//include JSON file handling
PublicDependencyModuleNames.AddRange(new string] { "Json", "JsonUtilities" });

//include procedural generation components
PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "ProceduralMeshComponent" });

//include assimp
PublicIncludePaths.Add(ProjectRoot + "ThirdParty\\assimp\\Includes");
PublicAdditionalLibraries.Add(ProjectRoot + "ThirdParty\\assimp\\Libraries\\assimp-vc142-mt.x64.lib");[/INDENT]
  }
 }


BTW, I need to compile it for Android platform. Any help will be appreciated. Thanks again. TC