What file contains the main function?

I would like to get involved in programming, but the directory structure is really unclear. I can’t find the file with the main-function. Where do I find the file with the main function?

Can this file be moved to the highest directory? It’s really unclear and bad programming to store it in a lower level subdirectory where no one can find it.

Other than that, when I compile Blender as Blender lite, what does it still do and what doesn’t it do?

Blenders main function is located here: blender/source/creator/creator.c:244. I think the location is appropriate.

You can check blender/build_files/cmake/config/blender_lite.cmake to see what the lite build turns off.

Thank you for your reply. Without naming conventions it’s really difficult to find anything. Why not rename it “main?”

The main function is essentially full of boilerplate code to handle arguments and initialization, eventually followed by entering the main loop (WM_main()). There’s rarely ever a reason to touch this, except for core changes.

I know that people new to programming in Blender often think starting from there is a good path to understand the code, but that is not the case. There is a complex interplay of data and systems in Blender, glued together by other abstract systems close to the main loop (like the event system, operators, draw callbacks, etc). It is better to get an idea of the individual systems one by one, and how they interact. All this is very normal for a complex application like Blender. It’s just not your typical program from a computer science course where the main function may be a clear to follow entry point.


There are multiple executables in Blender, hence multiple main() functions. In a way this is the main-main function, but there are others (makesdna, makesrna, datatoc, msgfmt, etc). creator.c may indeed not be the most obvious name, but a) as mentioned above it’s a less relevant place than many people think it is and b) it’s documented here: Source/File Structure - Blender Developer Wiki


That needs to change. If it’s not clear to follow it’s a mess. That leads to bugs. Bugs need to be taken out early on in the development process, not late. This is very very wrong.

How can you have multiple main functions anyway? That goes against the ANSI-standard. You need to separate your source files into “active” and “trial” directories also, if that’s what it’s for.

Like I said there are multiple executables. Most of them are run as part of compiling Blender for additional code generation.

A lot of books and research is written on how to deal with complex software architecture, it’s not a simple issue. There’s continuous efforts to reduce or better manage complexity in Blender too. But again, all of this is normal for a project of Blender’s complexity. Many applications use frameworks/toolkits such as Qt that handle and hide a lot of the complexity, which is another big topic with many pros and cons to consider.


I’ve studied those books and the rule is to make it simple: (1) pull apart nested if-then-clauses for instance, (2) make sure that if you have more than seven lines of code that you try to put it into its own function with a clear name and descriptor to make sure people can see at a glance what it does, etc.

The answer to complexity isn’t to leave it be complex, it’s to make it simple. These are core programming principles that you are trying to wave aside.

With all due respect. We are continuously apply those guidelines when it makes sense. We do not put them on a sidetrack. Note that many books are written with certain cases and it is not wise to apply them directly to a full code base at once. Those guidelines also changes a lot during the time and can differ based on the programming paradigm.

Please join our development community for some time and see for yourself. Feel free to discuss, but in a productive way. What I miss in this communication is actual concrete ideas that will help improving blender source base.

Large applications have multiple executables, this does not mean that it is bad by default. Look into the reasoning, research and find out why stuff is as they are.

Creator.c is a legacy name and mostly kept for that reason. I do think we should turn to efforts in the areas where bugs are known to be, where it makes sense. Changing working code also introduces risks, not saying that is a reason not to do it. But all changes should happen with thought.

Please by critic that would help blender move forward, but be respectful to others as we are to you.


I am respectful in the way I answer and critical.

The guidelines I propose, also the clarity guidelines, were developed to eliminate errors (bugs) beforehand, not afterward.

By the looks of the Mac package, Blender only has one executable of 359 MB big in the MacOS directory. That means when you compile, only one main-function is compiled.

That means when you compile, only one main-function is compiled.

Incorrect, while blender is a single executable, there’s a bunch of other executable artifacts from the build (ie datatoc, datatoc_icon, makesdna, makesrna, msgfmt) that all have their own main function, so while blender indeed only has a single main function, multiple exist in the codebase as a whole as blender is not the only executable being build.

1 Like

I checked the package contents of the Mac version of Blender that you can download from the website and that’s not true. It’s simply incorrect. It is the only executable.

On top of that, I don’t really get why one directory in the Mac package had uncompiled CPP files in it in all honesty.

find * | grep baby

Just because we only ship a single executable doesn’t mean the other are not needed, they are helpers that are required to build blender. while they don’t get shipped, but they do get build / run during blenders build.

The uncompiled CPP files are likely in the cycles folder, cycles support building some GPU kernels on demand and the cycles source ships with blender for that reason.

How? Do you have any idea how convoluted and insane this is, eliminating all transparency of programming? What do these programs do? And why do they get deleted?

Please converse in a more respectful way, or i’ll be forced to close this thread as well, this is NOT how we communicate with each other here.

Nothing is getting deleted, they are merely not included in the blender distribution as they serve no use for the end users, if you look for them in your local build folder you’ll find them

@julianeisel already answered this:

I have a proper high school and engineering degree and in terms of education I outrank you on many levels. If you want my respect, you need to earn it. You don’t. If you can’t handle criticism, you shouldn’t be here. You are displaying you can’t handle criticism and I’m 100% sure I’m not the first to tell you that.

What kind of code? What do they do?