Using Render Workbench with Cycles

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
catman
Posts: 412
Joined: Fri Jan 11, 2019 10:42 pm

Using Render Workbench with Cycles

Post by catman »

I saw that the new Render WB got a new cycles project button. I thought that was exciting and I wanted to test it out. Now it seems I am stuck already before the first step :oops:

Surprisingly on the forum or the wiki I have not found a lot of information about it. Most is from Yorik in the github readme (see link) and also there are a frew posts on the developer section, so people seem to have done this. The first step is to compile Cycles. The Readme says
To use the Cycles renderer, Cycles must be compiled as standalone. The Blender wiki has a section on how to compile Cycles as standalone
The Blender wiki might have contained detailed info once, but 2020 it only says the following on the topic
No precompiled binaries are available at the moment. Instead you can get the source code (see below) and compile your own
I thought I put together a small script to download and compile Cycles on a Ubuntu 18.04, so I could pull updates in the future easily. However, it turned out to be a lot more difficut than expected ;). Maybe the problem is that I wanted to install the dependencies as libraries from the repository instread of downloading all the code and their recursive dependencies. Right now I am not sure any more if that works at all. Below is the script so far. I have been though quite a few iterations yet and it still does not compile. Currently I am stuck at resolving "could not find OSL" and "could not find LLVM". OSL is the OpenShadingLanguare and needs to be compiles from source - but according to the wiki it is only optional when WITH_CYCLES_OSL option is set which it is not. So its not clear why it still asks for this.
The "could not find LLVM" is more tricky: I tried the following without success: "libllvm-10-ocaml-dev", "libllvm-9-ocaml-dev","libllvm6.0","libllvm9.0". None solved the error.

Is there somone who has gone through this already and can give me a hint on how to compile Cycles on a Ubuntu box? Did I miss something? For my feeling this is already a lot more fuss than it should be.

Code: Select all

#/!bin/bash
# This script will download and compily cycles from source
# Usage
#  ./compile_cycles.sh
# it will ask for the sudo password for installation.

# download current master from the web
cd ~/temp
sudo rm -r ~/temp/cycles
mkdir -p ~/temp/cycles
git clone https://git.blender.org/cycles.git

# install dependencies
sudo apt install -y libopengl0 
sudo apt install -y libglew-dev 
sudo apt install -y libboost-all-dev
sudo apt install -y libopenimageio-dev   
sudo apt install -y libpugixml-dev   
sudo apt install -y libglu1-mesa-dev 
sudo apt install -y libilmbase-dev
sudo apt install -y libopenexr-dev
sudo apt install -y libopencolorio

# compile
# added no Cycles option. If add with -D WITH_CYCLES_XXX the '...'
# The other options found on a post for compiler blender...
# Note: this fails with missing stuff:
#  OSL (not clear which. libosl is sth different)
#  LLVM (there are no libllvmX-dev, but libllvm4.0..libllvm19 and libllvm-X-ocaml-dev ?). Installing "libllvm-10-ocaml-dev" did not solve the error 
make BUILD_CMAKE_ARGS="-DBOOST_ROOT=/usr/lib/boost -DBoost_NO_BOOST_CMAKE=ON -DBoost_NO_SYSTEM_PATHS=ON" CMAKE_EXE_LINKER_FLAGS='-lGLU' release
The CLI output

Code: Select all

-- GLUT_FOUND=TRUE
-- Could NOT find OSL (missing: _osl_LIBRARIES OSL_INCLUDE_DIR OSL_COMPILER) 
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find LLVM (missing: LLVM_LIBRARIES)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  src/cmake/Modules/FindLLVM.cmake:96 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  src/cmake/external_libs.cmake:101 (find_package)
  src/CMakeLists.txt:18 (include)
-- Configuring incomplete, errors occurred!

Edit: minor script correction
Last edited by catman on Mon Jul 13, 2020 8:28 pm, edited 1 time in total.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Using Render Workbench with Cycles

Post by vocx »

catman wrote: Mon Jul 13, 2020 5:29 pm ...
The "could not find LLVM" is more tricky: I tried the following without success: "libllvm-10-ocaml-dev", "libllvm-9-ocaml-dev","libllvm6.0","libllvm9.0". None solved the error.
This problem is about compiling Cycles, therefore I strongly suggest you ask in the Blender forums first. The FreeCAD side of things is independent of Cycles.

And yes, compiling something is not trivial, you should be a bit experienced hunting down the dependencies, using build systems like Cmake, and many things, before attempting to compile a big program like Blender or FreeCAD.

I saw in your script about changing ownership. Remember that to compile you don't need to use sudo at all. That will only cause you problems. To install the dependencies you do need sudo, sudo apt install, but afterwards, the compilation itself should not require sudo. Make sure the source code and build directory are owned and writeable by your regular user and you should be fine.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
catman
Posts: 412
Joined: Fri Jan 11, 2019 10:42 pm

Re: Using Render Workbench with Cycles

Post by catman »

vocx wrote: Mon Jul 13, 2020 6:24 pm I saw in your script about changing ownership. Remember that to compile you don't need to use sudo at all. That will only cause you problems. To install the dependencies you do need sudo, sudo apt install, but afterwards, the compilation itself should not require sudo. Make sure the source code and build directory are owned and writeable by your regular user and you should be fine.
You are right. The ownership was a leftover from an earlier version when I called the whole thing with sudo.
vocx wrote: Mon Jul 13, 2020 6:24 pm This problem is about compiling Cycles, therefore I strongly suggest you ask in the Blender forums first. The FreeCAD side of things is independent of Cycles.
In principle I agree. But in this case it seems that on the standard doc path for using the Render WB there is no link to how to compile Cycles. Also not in the Blender Wiki. So I think it would be very useful for other users who want to try this feature to find that information here in the forum.
Post Reply