# Building (Blender) with OpenMP



## myname (Mar 19, 2016)

I've been trying to build blender with OpenMP.  Here's what I got so far:

*1.) Modify the makefile to include those features.*

```
# Only works, if everything else is compiled with the same compiler
 OPENMP_CMAKE_ON=        -DWITH_OPENMP:BOOL=ON
 OPENMP_CMAKE_OFF=        -DWITH_OPENMP:BOOL=OFF
 OPENMP_USES=            compiler:openmp
 OPENMP_USES_OFF=        compiler:features
```
(But what does the comment mean, exactly?)

*2.) Update the Compiler to Clang 3.9.0, which claims to support OpenMP*

```
-- The C compiler identification is Clang 3.9.0
-- The CXX compiler identification is Clang 3.9.0
```

I went ahead and edited /etc/make.conf, which appears to work  (cc= and cxx= did not) ​*3.)  make | tee blender-make-output*

This build ends uncerimonously with: 


```
/usr/ports/graphics/blender/work/blender-2.76b/intern/opensubdiv/opensubdiv_capi.cc:43:12: fatal error: 'opensubdiv/osd/ompEvaluator.h' file not found
#  include <opensubdiv/osd/ompEvaluator.h>
```

Now, my next thought is to just diasble open subdivisions, but what the heck, I'll run it with unsafe jobs:
`make clean
make`

And, proudly in it's ancestors footprints, we get the same error.  I now disable opensubdivisions with `make config`, clean it, and indeed see this happens:


```
`__kmpc_fork_call'
../../lib/libbf_intern_itasc.a(Scene.cpp.o): In function `.omp_outlined.':
/usr/ports/graphics/blender/work/blender-2.76b/intern/itasc/Scene.cpp:(.text+0x5e0f): undefined reference to `__kmpc_for_static_init_8'
/usr/ports/graphics/blender/work/blender-2.76b/intern/itasc/Scene.cpp:(.text+0x6008): undefined reference to `__kmpc_for_static_fini'
/usr/ports/graphics/blender/work/blender-2.76b/intern/itasc/Scene.cpp:(.text+0x6019): undefined reference to `__kmpc_barrier'
../../lib/libbf_intern_itasc.a(WDLSSolver.cpp.o): In function `.omp_outlined.':
/usr/ports/graphics/blender/work/blender-2.76b/intern/itasc/WDLSSolver.cpp:(.text+0x261f): undefined reference to `__kmpc_for_static_init_8'
/usr/ports/graphics/blender/work/blender-2.76b/intern/itasc/WDLSSolver.cpp:(.text+0x2818): undefined reference to `__kmpc_for_static_fini'
/usr/ports/graphics/blender/work/blender-2.76b/intern/itasc/WDLSSolver.cpp:(.text+0x2829): undefined reference to `__kmpc_barrier'
../../lib/libbf_intern_itasc.a(WSDLSSolver.cpp.o): In function `.omp_outlined.':
/usr/ports/graphics/blender/work/blender-2.76b/intern/itasc/WSDLSSolver.cpp:(.text+0x297f): undefined reference to `__kmpc_for_static_init_8'
/usr/ports/graphics/blender/work/blender-2.76b/intern/itasc/WSDLSSolver.cpp:(.text+0x2b78): undefined reference to `__kmpc_for_static_fini'
/usr/ports/graphics/blender/work/blender-2.76b/intern/itasc/WSDLSSolver.cpp:(.text+0x2b89): undefined reference to `__kmpc_barrier'
clang-3.7: error: linker command failed with exit code 1 (use -v to see invocation)
--- bin/blender ---
```

So, we get closer, but still, no cigar.  To be honest, I work really soon, and I have not yet tried to build blender WITHOUT OpenMP as a sanity check, but I did that just earlier in the day.

I have an FX-8320, so a thousand thank you's in advance for any help.


----------



## sossego (Mar 19, 2016)

You should try building the port in a jailed environment.
https://www.freebsd.org/cgi/ports.cgi?query=jail&stype=all

The solution for testing is there.


----------



## myname (Mar 20, 2016)

I'm more than willing to try it, but it might help if I understood the theoretical advantages of building ti in a jail, sir :/


----------



## emorras (May 26, 2016)

Check the OpenMP  llvm documentation at http://openmp.llvm.org/README.txt

The 

"# Only works, if everything else is compiled with the same compiler"

means you can't mix in a program, code & dynamic libraries with openmp compiled with different compilers or OpenMP versions. If your openmp 3 app is compiled with clang, you can't dynamic link with zlib-openmp.so if it was compiled with gcc5 or OpenMP 4

For the 

'undefined reference to `__kmpc_for_static_init_8'

error, check that your make file uses -openmp


----------

