Thursday, August 30, 2018

Develop Blender On Windows - 1. How to get started (build Blender) and why it seems difficult at the beginning for beginners?

This series of articles is ment to serve beginners as my self. I did a lot of python scripting in the past, but I have no idea how to develop software in C/C++. I do not have any experience with these language but I belive it can't be too hard. Why not to start learning C/C++ with developing Blender.

I wrote this article during my quest to build Blender which is the first step. My longest article so far. I tried to write it as it was happing and to write my first reactions (which could be changed later). After that I started to summarize what I experienced. So I'm going to write more in detail about it in the future. If you are a beginner and you want to avoid confusion about what we do and why we do that way you might want to check later articles (if there is). The information I write is valid now but I guess it will be obsolate after a couple of month or so. If you find something that I should have to update, please let me know!

Fortunatelly we are not alone. There is a page on blender.org which describes how to start:
https://wiki.blender.org/wiki/Developer_Intro/Advice


It says first: build Blender! So I'm going to do what it says step by step (for me it took around an afternoon (4-5 hour) to "finish"). I use Windows so I need to follow that:
https://wiki.blender.org/wiki/Building_Blender/Windows
I refer to this particlular page later when I write Blender Wiki.


I guess I'm not the only person who does not like to install lot of softwares on their computer. That's why I raise that question again and again: why these programs (how do we call them?) are necessary to develop Blender?

1. Visual Studio 2017 Community Edition
So as it says we have to install Visual Studio. More precisely: Visual Studio Community. It raises the first questions:
What is Visual Studio?
Why is it necessary to develop Blender?
Of course I could spend time to find the answares by myself but it would be nice to have couple of words about Visual Studio on Blender Wiki.
What I know at the moment that C/C++ differs from python that the code written in these languages have to compile to get the executable program. I guess that is the main reason.

Okay, just let it happen. There is the link:
https://visualstudio.microsoft.com/free-developer-offers/


It takes around 5 minutes to install.


Note: If you are installing right now please read the end of the article because I had a problem with compiling Blender so I had to install more so called workloads later to correct that.


Just to mention with Pyhton extension:
2 GB disk space

After that we have to restart the computer. The first start is a bit tricky. It says takes a few minutes to start and it really are few minutes. After around 30 minutes I had the feeling I was stuck at the very first step. With Task Manager I shut it down, but after that the program didn't start at all. Surprisingly after that I restarted the computer the Visual Studio started as it should.

2. Subversion for Windows
As far as I remember I heard about Subversion as a version control solution, but that's all what I know about it. Again: the Blender Wiki does not provide any information about what it is? Why it is  necessary to develop Blender? Of course if we have plenty of time to research we can read about Subversion a lot:
https://en.wikipedia.org/wiki/Apache_Subversion
On Blender Wiki we have only that link:
https://sliksvn.com/download/

As a matter of fact it is not Subversion but SlikSVN. So what a hack is that? Ok, I know that SVN is the abbreviation of Subversion. And we can read that on the website:

"We provide a standalone command-line Subversion client for Windows."
I guess for an experienced developer it is clear as the sky, but for me is definatelly not.
Okay, just let it happen.


To install SlikSVN is straithforward. I choosed Typical settings.

But...I guess when they write "command-line Subversion" it explains why I can't find the program in the Windows start menu. So I can't launch that program as usually do with softwares. Let's move on.

Just to mention it is around:
16 MB

3. Git for Windows
So what a hack is git? I'm convinced that in this case git has nothing to do with unpleasant persons (as the dictionary describes the word: git). Wikipedia is the better choice:
https://en.wikipedia.org/wiki/Git
I would really preciate if somebody took the time to explain all this stuff for beginners.

On Blender Wiki we have only that link:
https://gitforwindows.org/

And we have only one hint:
"In the installer, choose to add Git to your PATH to ensure the Git version is in the splash screen."

Installing Git for Windows is definatelly very very not straightforward. Plenty of settings without any guide, and during installation there is no option as mentioned on the Blender Wiki. We can hope that the default settings are fine. If it is the case why can't be there a short descrition on Blender Wiki: "Every time if you are not sure what is the right option to choose during the installation just hit the Next button."








The installer said it would be 230 MB but I checked the folder which was 500 MB.

4. CMake
So what a hack is Cmake? Wikipedia says:

"CMake is a cross-platform free and open-source software application for managing the build process of software using a compiler-independent method."

Definitely not what I can undersand at the moment. Just move on!

The Blender Wiki has a link to:
https://cmake.org/
giving a headache to find out which version to download. I hit Download Latest Release on that page I found this:



It seems there is zip version of Cmake (like Blender), so it is not necessary to install. I prefer that. But Blender Wiki says:
"In the installer, choose to add Git to your PATH to ensure the Git version is in the splash screen."
That means we have to install to get the right settings (I tried the other way and it didn't work :) I guess it could work somehow with setting Environment Variables). So we need to choose:

Windows win64-x64 Installer: Installer tool has changed. Uninstall CMake 3.4 or lower first!



To install CMake is straithforward. I choosed that PATH option and that was all.




The CUDA install is optional so I skip it for now.

SO WE DID IT!

Ready to get Blender source code and the other unknown but necessary stuff. We can follow the instruction. Have to make a folder. I stick to the description: C:\blender-git.
There is a thing: command line. For beginners it can be frightening to type commans but the description on Blender Wiki is pretty clear 😃. We have to lunch cmd which is basically pop up a new window with only text, the so called Command Prompt.



We have to type what Blender Wiki writes about it. Every line of the text is one command. So we have to hit Enter after each line. There are DOS specific commans and others...
There is another interesting thing (which is not very offen communicated) that the font type of a program code is always Courier. Why? I wrote about it here. We can recognize on Blender Wiki that these lines are commands.

5. Precompiled Libraries

This line of command: 
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/win64_vc14 lib/win64_vc14
tells me that the svn is the command and that's why we had to install SlikSVN. Forthermore on Blender Wiki below the Advanced Setup we can read that.
"Subversion is required for accessing precompiled libraries."
It is a little bit of help to understand what is going on, but somebody should tell me what are these precompiled libraries?
I run that svn command and it took around 15 minute to download (?) all the stuff and it required 7 GB discpace.




Now I have this structure below c:\blender-git\lib\win64_vc14\

So we can see libs are stuff in connection with CGI like openSubdiv and openExr.


6. The Blender Source Code

The next step is to "download" the Blender source code with git commnads. Of course only lines started with git are these.

It is much faster than te previous step and intrestingly it is only 746 MB.








7. Compile Blender
The final-final step of the begining of this long-long journey. The command:
make full
Simple as one, two, three. It should be. But I got an error message.

No explicit msvc version requested, autodetecting version.
Compiler Detection failed. Use verbose switch for more information.
Visual Studio not found (try with the 'verbose' switch for more information)


I had hard time to figure out how to use 'verbose' switch. According to my experience command switch or flags usually typed like -v or -verbose. Finally I suceeded with that:

make full verboes

And the verbose message was this:

"svn   : C:\Program Files\SlikSvn\bin\svn.exe
cmake : C:\Program Files\CMake\bin\cmake.exe
git   : C:\Program Files\Git\cmd\git.exe
No explicit msvc version requested, autodetecting version.
Detecting msvc 2017
"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest  -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64`
Visual Studio is detected but the "Desktop development with C++" workload has not been instlled
Detecting msvc 2015
Visual Studio 2015 not found.
Compiler Detection failed. Use verbose switch for more information.
Visual Studio not found (try with the 'verbose' switch for more information)"


I had to have some help because I had no idea what to do. I felt that something with Visual Studio is not correct. As I wrote before there was a wierd stuff at the first launch. I subscribed to bf-committers@blender.org mailing list long time ago so I had the chance to ask about this problem. Fortunatelly I got an answer and it solved to problem.
I had to install another workload to Visual Studio called Desktop development with C++







With pyhton extension and C++ desktop development extension: 5.2 GB

After that it workd fine for me.




 BLENDER IS BUILT!

One little problem that I did not get the massage described on Blender Wiki:
Blender successfully built, run from: 
C:\blender-git\build_windows_Full_x64_vc14_Release\bin\Release
 Right now I don't know why but the complied version of Blender works fine. Yupee! It is the version 2.79 which is stable but 2.8 is comming soon, so I have to investigate how to get the source code of 2.8 and complie it.
To be continued...

1 comment:

  1. Hey dude, can you please compile a version of UPBGE (a fork of blenfer game engine)for me? I will give you the source code, please bro do it for me....

    ReplyDelete