7 Replies - 334 Views - Last Post: 24 October 2017 - 07:46 AM

#1 Atharron  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 154
  • Joined: 23-April 14

What is a build system?

Posted 23 October 2017 - 01:04 PM

I'm currently checking out Qt and going through the manual, but it often refers to a build system without defining it. I've looked it up, but I'm still unsure of what it does, or why there are different ones.

I always thought that if you write code, it will produce the same result every time, so what do these different things do, and why does it matter?
Is This A Good Question/Topic? 0
  • +

Replies To: What is a build system?

#2 Atharron  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 154
  • Joined: 23-April 14

Re: What is a build system?

Posted 23 October 2017 - 01:10 PM

It gets worse:

Quote

Qbs is an all-in-one build tool that generates a build graph from a high-level project description (like qmake or CMake do) and executes the commands in the low-level build graph (like make does).


'Build Graph'? 'Project description'? 'High-level'? 'Low-level'?

What does any of this mean?
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13493
  • View blog
  • Posts: 53,901
  • Joined: 12-June 08

Re: What is a build system?

Posted 23 October 2017 - 01:12 PM

Different target systems have different needs and interpretation of code. Example - differences between compiling Windows or iOS or Ubuntu. You can make things more 'cross compatible' so that helps, but those are different systems and options to interact with those systems.

https://en.wikipedia...NU_Build_System

Quote

Qbs is a tool that helps simplify the build process for developing projects across multiple platforms.

http://doc.qt.io/qbs/
Was This Post Helpful? 0
  • +
  • -

#4 Atharron  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 154
  • Joined: 23-April 14

Re: What is a build system?

Posted 23 October 2017 - 01:40 PM

So different operating systems understand code differently, and these build systems are there to turn the human readable code into computer readable code for certain operating systems? Like a translator?

Unfortunately, your first link goes on about a lot of stuff, but includes so many other words I don't understand that it makes no sense without me going down the Wiki rabbit hole.

The second one goes on about writing a bunch of code, but I'm not certain if I need to know all that, because the Qt IDE seems like it does that for me? Either way, from what I've read, it still doesn't seem to make the quote from the manual any more understandable.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • the case is sol-ved
  • member icon

Reputation: 6382
  • View blog
  • Posts: 25,781
  • Joined: 12-December 12

Re: What is a build system?

Posted 23 October 2017 - 01:59 PM

What is a Build System?

If you are creating small or personal applications then a build system is not likely to be a high priority, and is also why the tech-talk might not mean much. It is of significance with collaborative, substantial, and/or cross-platform applications.
Was This Post Helpful? 0
  • +
  • -

#6 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2512
  • View blog
  • Posts: 3,991
  • Joined: 21-June 11

Re: What is a build system?

Posted 23 October 2017 - 02:05 PM

View PostAtharron, on 23 October 2017 - 10:40 PM, said:

So different operating systems understand code differently, and these build systems are there to turn the human readable code into computer readable code for certain operating systems? Like a translator?


No, that's what the compiler does. Build systems exist to automate how you invoke the compiler (and other tools that may be part of your build process).

I wouldn't even say that cross-platform support is the primary feature of build systems (certainly not for basic ones like make). It's just that a lot of modern ones emphasize cross-platform support as a feature because that's one thing that sets them apart from older ones.

Anyway, let's start at the beginning (and let's ignore the cross-platform stuff for now):

You use a compiler to turn code into an executable (or binary). For example if all your code is in "bla.c", you can use gcc bla.c -o bla.exe to compile your code, right? Now if you have two C files, you can do the same thing like this: gcc bla1.c bla2.c -o bla.exe. But the more files you have, the less handy this becomes to type. So the next step would be to write it in a shell script (or .bat file on Windows) and call it "build.sh" or something. That way you don't need to re-type the whole command all the time.

However, if you have a lot of files, compilation can take a long time. One way to speed up compilation is to only re-compile the files that have actually changed. But to do that, you need to compile the files individually. Then a full compilation would look like this:

gcc -c bla1.c
gcc -c bla2.c
# Repeat for all other c files
gcc bla1.o bla2.o ... -o bla.exe



Now if you only want to recompile some of these files, you can just leave out the gcc -c commands for the files that you don't want to recompile. The first problem with that is that your shell script is now useless unless you want to do a full compilation. And the other problem is that you have to keep track of which files you've changed, so you know which ones to recompile. That's pretty annoying and error prone.

So that's what make was invented for. With make you can execute a makefile, which is basically like a shell script except that you can tell it which of the commands are used to generate which files and which files are needed to generated which other files. Then make will check which of the files have changed and only run the commands that are need to regenerate those files.

This isn't just useful to keep compile times low, but also to keep the build process simple. In larger projects, building the project often involves more than just invoking the compiler: You might want to generate code using tools such as yacc/bison or, in case of Qt projects, moc. So the build system can also take care of running those tools for you.

There are many things that make doesn't do (or doesn't do very well), so many more build systems with additional features were invented. Some work in combination with make, some alone. These additional features include things like automatically figuring out dependencies between files (that is, figuring out which files need to be recompiled when a certain file has changed, without you having to manually write down the dependencies); or automatically figuring out which options need to be passed to the compiler to use certain libraries etc.

View PostAtharron, on 23 October 2017 - 10:40 PM, said:

The second one goes on about writing a bunch of code, but I'm not certain if I need to know all that, because the Qt IDE seems like it does that for me?


Yes, qtcreator automatically creates a qmake project file and maintains it for you. Unless you want to set certain compiler flags or link against external libraries, you won't need to touch it yourself. When you hit the "compile" or "run" buttons in the IDE, it will run qmake and make automatically, so it all happens automatically for you. You don't need to understand it to use it (though it doesn't hurt either).
Was This Post Helpful? 1
  • +
  • -

#7 Atharron  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 154
  • Joined: 23-April 14

Re: What is a build system?

Posted 23 October 2017 - 02:10 PM

View Postandrewsw, on 23 October 2017 - 01:59 PM, said:

What is a Build System?

If you are creating small or personal applications then a build system is not likely to be a high priority, and is also why the tech-talk might not mean much. It is of significance with collaborative, substantial, and/or cross-platform applications.


I found that page when doing my research, but like most things I find, it's geared more towards people who already know what they're doing.

sepp2k explained it very well. Thanks.
Was This Post Helpful? 0
  • +
  • -

#8 ndc85430  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 594
  • View blog
  • Posts: 2,492
  • Joined: 13-June 14

Re: What is a build system?

Posted 24 October 2017 - 07:46 AM

Some build systems like Maven or Gradle (often used for JVM projects in Java/Scala/Kotlin) also do dependency management - that is, they let you put the libraries you depend on in the build script and it will go fetch them for you. Obviously that is useful for your own projects (as you'll likely need to use third party libraries) and probably not a thing that's easy to do for languages like C/C++ because you'd have to compile the libraries for whatever platform you were running on.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1