assimp-go
Developing assimp-go
We link against static assimp libraries that are built for each platform and added to the aig/libs package.
Depending on the platform we select one of them and link against it when doing go build.
The general steps are:
- Copy assimp includes into
aig/assimp - Copy
zlib.h,zconf.handirrXML.hintoaig/zlibandaig/irrxmlrespectively. - Copy static libraries into
aig/libs - Generate the wrappers using
swig -go -c++ -intgosize 64 aig/aig.i - Add
#cgo LDFLAGS: -L ./staticLibs -l zlibstatic -l IrrXML -l assimpat the top of the 'C' import inaig.go
Note: When dealing with static libraries the compiler will probably (e.g. MinGW does this) ignore
libsuffixes and.a/.libsuffixes. So if your lib name islibassimp.ayou need to pass it to CGO as-l assimp, otherwise you will get an error about library not found.
For platform specific steps:
Windows:
Note: You must compile with the same C/C++ compiler you use with Go (e.g. if you use MinGW with Go, then compile assimp with MinGW by sepcifying the correct
-Goption)
Note: If you get compilation errors with things like
File too bigorcan't write 166 bytes to sectionthen cmake isn't detecting you are using MinGW, so add this flag-D CMAKE_COMPILER_IS_MINGW=TRUE
Now assuming you are using MinGW on windows:
- Clone wanted release of assimp and run
cmake CMakeLists.txt -D BUILD_SHARED_LIBS=OFF -D ASSIMP_BUILD_ZLIB=ON -D ASSIMP_BUILD_ASSIMP_TOOLS=OFF -D ASSIMP_BUILD_TESTS=OFF -G "MinGW Makefiles"in the root folder - Run
cmake --build . --parallel 6 - Copy the generated
*.libfile intoaig/lib