# How do I build Assimp with MinGW?

How can I build Assimp with cMake and MinGW?

I tried, but I don't get a functioning library...

Details of my attempt:

I am trying to build the Open Asset Import Library (Assimp) but I have been running into problems. The assimp documentation is really poor and expects you to know exactly what you are doing. The developers haven't been particularly helpful either. I hope someone here has successfully built assimp and can let me know where I am going wrong. I suspect that I have several problems that are contributing to my failure. I am using 64 bit Windows 8.1 pro and using MinGW version 4.8.1.

The first thing I tried was downloading assimp 3.1.1 and boost 1.57. I extracted both folders and tried to use cMake to generate the makefile for MinGW. I haven't used cMake before and the assimp instructions are use cMake as you normally would, so I have no idea if I configured it right. I pointed BOOST_ROOT to the boost folder I extracted from the download, set it to build static libraries and generated the makefile.

I then tried running the makefile and got a number of errors. The first was

IFCReaderGen.cpp.obj: too many sections and was too big.


After some googling, I found a workaround was to set CMAKE_BUILD_TYPE to release. That seemed to work and it finished the build but I only got the files assimp32.dll and libassimp.dll.a, which I thought was odd because I was expecting lib/relese/libassimp.a to be generated as per the details on the assimp website. Though the website might also be wrong or out of date.

I linked with -lassimp.dll and that allowed me to build my program. However it crashed upon start-up - the error that appeared immediately at start-up was

Program has stopped working

(There was no additional info.) I guessed that this was a dll problem—which was odd because I had (tried) to build the static libraries through cMake. I copied assimp32.dll into my executable folder. This time, the program wouldn't crash but the screen would be blank. I'm guessing that there was something wrong with the library I build that was causing it to link incorrectly.

At this point, I deleted everything to try a fresh start. I tried to follow this article:

2. I opened cmd, changed to the boost root directory and ran

bootstrap.bat mingw

3. I then ran

b2 --build-dir="C:/Libraries/boost/" variant=release link=static address-model=32 toolset=gcc


The result of this was

598 targets updates, 3 targets skipped, 2 targets failed.


I now have a folder C:\Libraries\boost\boost\bin.v2 with two folders libs and standalone, but I'm not certain what my BOOST_ROOT directory is anymore.

4. I opened cMake, selected the assimp folder I had extracted, and configured the following:

BOOST_ROOT = "C:/Libraries/boost/boost/"
ASSIMP_BUILD_STATIC_LIB = TRUE
ASSIMP_BUILD_TESTS = FALSE
ASSIMP_ENABLE_BOOST_WORKAROUND = FALSE
BUILD_SHARED_LIBS = FALSE

5. I then pressed configure and got the error that the boost libraries were not found.

I'm only guessing what these cMake settings do, as I can't find any documentation for assimp. I'd like to build some version of assimp that I can then link to and use in a simple test program. At some point I will go back and build the shared libraries, but first I just want to get something working and understand how to do it again.

Can someone see what has gone wrong?

• You're running into multiple issues and not giving enough details for others to diagnose. I suggest you break things up and address issues one by one, giving relevant information for each. For example, what parameters exactly did you use with CMake? What kind of test program were you using? What were the details of the crash - any outputs, stack traces? Did you check errors in your function calls? What are your test files? – congusbongus Dec 31 '14 at 1:39
• I have edited the question, hopefully that clarifies it. What I want to know is how to build Assimp, I can't find any instructions for building with MinGW. The information isn't several problems I need solved, just what I've already tried trying to build Assimp. I've included all the error information allready - unfortunately they weren't very descriptive which is why so far I've been guessing what the cause is. I know the function calls are right - I'm fairly certain the crash was caused by a link error due to the library I built being bad - which is why my question is how to build Assimp? – Francis Dec 31 '14 at 6:22
• Why have you concluded that the library you built is bad? Do you have identical test code that works on a "known-good" build of the library? – Anko Dec 31 '14 at 8:25
• The program I was running didn't get as far as the first line before it crashed. I also got the program down to a single creation of an Assimp::Importer object. Linking with the dll (even though I was supposed to be static linking) was cause the crash. In any case I don't have the library that was built anymore - I deleted everything when I tried to do a fresh build. I can't work out how to build Assimp, and I'd like someone to provide instructions. – Francis Dec 31 '14 at 8:54
• Alright, it was a code problem, the shader I was loading was wrong and made it look like nothing was being drawn. I have managed to build a working version of libassimp.dll.a and assimp.dll but I still don't know how I did it - I just pulled levers in cMake and crossed my fingers until it spat out something that worked. If someone knows how to build assimp I'd appreciate if they could write up the procedure. – Francis Dec 31 '14 at 19:15

I don't know how to exactly configure Assimp to build it with MinGW, but I have successfully build this library (as static lib) from source code of the OpenGL Tutorial's examples. You can use it as well. Just download the source code (I was using exactly this version) and do standard CMake build:

mkdir build
cd build
cmake -G "MinGW Makefiles" ../
# or
# cmake -G "MSYS Makefiles" ../
make


If compilation will succeed you will have generated:

build/external/assimp-3.0.1270/code/libassimp.a

You could also inspect CMake files of the Assimp libarary to see how it is configured.

• Thanks for the suggestion. I've just tried this, but the recipe in the makefile produced failed due to a number of thing being undeclared. I any case while I might be able to get a working library using this method, I'd still like to know how to build it myself in case I have to do it from the actual source at some point (for example there are newer versions of assimp than the one included in the tutorial). – Francis Dec 31 '14 at 9:08

Try turning off Boost: http://assimp.sourceforge.net/FAQ.html

ENABLE_BOOST_WORKAROUND = ON

As explained there its not really required, and its big. When we build Boost for Qt3D 1.0 we didn't use Boost because of compile issues.