These are chat archives for learnclang/general

5th
Jan 2015
Cesar Saez
@csaez
Jan 05 2015 03:07

Hi guys,

I've been playing around with Qt trying to replicate the "hello world" window by @mottosso and I think I got a good example of why Makefiles are needed/useful.

Here's the source code of my window:

#include <QApplication>
#include <QMessageBox>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QMessageBox msgBox;
    msgBox.setWindowTitle("My New Window");
    msgBox.setText("Hello world!");
    msgBox.show();

    return app.exec();
}

And here the compiler call (with the linking and stuff):

g++ -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I. -isystem /usr/include/qt -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtCore -I. -o main.o main.cpp
g++ -Wl,-O1,--sort-common,--as-needed,-z,relro -Wl,-O1 -o helloQt main.o   -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread

As you can see, things get messy as we add libs to the mix, I would rather call make instead of typing this on each build or rely on non-standarized scripts (fortunatelly qtcreator ships with qmake, a command line utility to generate Makefiles from .pro files).

Hope some of this makes sense,
Cheers!

Alex Widener
@alexwidener
Jan 05 2015 04:11
Isn't QTCreator a frowned-upon method of working anyway?
And absolutely in regards to using a make file, it's the equivalent of using the build.bat file. I am not trying to type that stuff in over and over.
Cesar Saez
@csaez
Jan 05 2015 05:34

We have already had this conversation.

Gist: Follow standards is a good thing if you're planning to share source code imho. Also, if you are able to write a shell/batch script, you will have no problem to write a Makefile.
And qtcreator is fine afaik (I'm using Vim though :smile: )

Alex Widener
@alexwidener
Jan 05 2015 06:41
Sorry, there’s too much to read through in this stuff right now. I’ve only skimmed it.
Marcus Ottosson
@mottosso
Jan 05 2015 09:06

Hi @csaez I think that's C++ and from what I understand they are quite different, maybe even in it's build procedure, and it's quite possible that build systems are more relevant there than with C.

But! You're right. I wouldn't want to type all of that either, but what the Handmade Hero guy (Casey) was doing was not insist on having to do a lot of typing, but instead on not optimising builds by only building what has changed.

For example, if we are working on 10 source files, only one of which has changed since last time - from what I understand - a build systems role is to understand that only this one file did change and to compile only this and reuse all else during linking into an executable.

So, what he suggest, and what I really liked, and what @alexwidener mentiones above, is to roll that command into a batch script - .bat on Windows or .sh on Linux for example - and then call that.

mymake.bat

g++ -c -pipe ... and so on

Calling

$ mymake
...

What you end up with is exactly what you are looking for - a single command to execute a build with all those flags.

Isn't QTCreator a frowned-upon method of working anyway?

This sounds a little like Casey talking, where else did you hear this? :) As far as I know, QtCreator is a pretty darn good debugger on Linux, amongst the few there are, and one of the few that is entirely cross-platform. If anything, I think it must be one of the better choices if you're looking for a single environment during cross-platform work.

Sebastian Thiel
@Byron
Jan 05 2015 09:24
It's great and nice to start rolling your own build system by writing some shell scripts or makefiles, just to learn what actually happens, to understand what's underneath.
Once that is done though, and if cross-platform or team-work is a concern, it's a good idea to use one of the established build systems just because they are so much better than a blunt script someone would produce.
Marcus Ottosson
@mottosso
Jan 05 2015 09:27

Once that is done though, and if cross-platform or team-work is a concern, it's a good idea to use one of the established build systems just because they are so much better than a blunt script someone would produce.

That's just what Casey argues against. :) I'll hold out until I see some actual compilation of large code this way, but so far it's been one less thing to worry about.

Sebastian Thiel
@Byron
Jan 05 2015 09:46
Even though I didn't see him, I believe he says that in small projects, setting up some third party build system isn't worth the effort. Certainly he is right if you just set the bar for the anticipated ROI high enough. On the other hand, if you start with an IDE like visual studio or QT Creator, the build system comes for free and is nicely integrated. This would make you do extra work to not use it, which probably isn't intended either. Anyway, all the info is out there for everyone to make his/her own educated decisions.
Marcus Ottosson
@mottosso
Jan 05 2015 09:51
I hear ya, but this is just what he compares his .bat files with. He claims to compile very large programs this way and he's from Rad which has got some serious performance-driven tools in their portfolio.
For a frame of reference, this is what he says to use for a build-script until the final version of the game he's making.
mkdir ..\..\build
pushd ..\..\build
cl -Zi ..\handmade\code\win32_handmade.cpp -o win32_handmade user32.lib gdi32.lib
popd
Marcus Ottosson
@mottosso
Jan 05 2015 10:43
@Byron Could you set up a Twitch channel so we can start bookmarking and linking folks to it, and maybe put a note about when it will start?
Cesar Saez
@csaez
Jan 05 2015 11:02

It's ok, I don't want to force anything on anyone... all I ask is that you take a look at how to do a Makefile before arguing against its complexity (learn C the hard way does a good job introducing it).

Almost every piece of open source software I've downloaded and installed on Linux comes with a Makefile, ./configure && make && make install is on every README file out there.

Marcus Ottosson
@mottosso
Jan 05 2015 11:18
You're talking about distribution, @csaez, I'm not sure that applies here which is about development.. in any case, I'll reserve my opinion until a future time when I know more about it. :)
Marcus Ottosson
@mottosso
Jan 05 2015 12:10

I created a learnclang channel on Twitch, should we try to do all screencasts in the same channel?

http://www.twitch.tv/learnclang

Sending you the login pass privately, @Byron

Marcus Ottosson
@mottosso
Jan 05 2015 12:19

Asked on the python_inside_maya mailing list, I think it applies to us all so hope you don't mind me duplicating it here, @fredrikaverpil

In the event of that I can't make it, will this screencast become available for download/viewing later?

I don’t know, to be honest. I think we’ll let this first one go as it goes and if it’s recorded somehow I can try and put it up somewhere.

Spontaneously though, I think it might make for a better show if it’s always live and interactive. I know some folks won’t be able to join if they’re on the other side of the planet, but on the other hand that does leave room for both a “east coast” broadcast and a “west coast” broadcast.

Also, while I’m here:

Screencasters

If anyone would be interested in making their own screencast, that would be cool. We could try and arrange it so that there is at least one broadcast a week or so. I know some of you are experienced in C/C++ already, I’m sure many of us would appreciate a peek into your brain. Maya plug-in development will become relevant in a bit, for example, once we’re all familiar with the basics.

And welcome to the group @sonictk!
Sebastian Thiel
@Byron
Jan 05 2015 13:35
And I just realised that this Thursday evening I am already on a java script meetup in Munich's google offices, totally forgot about that. Therefore, we are back to either doing it Wednesday if my microphone arrives in time, or Friday. Sorry for not noticing earlier
Marcus Ottosson
@mottosso
Jan 05 2015 13:52
Any microphone is fine, shall we say Wednesday then?

Screencast at Wednesday 7th of January @ 8 PM GMT+0

Sebastian Thiel
@Byron
Jan 05 2015 13:55
Ok, lets say that and hope that mic will arrive. Otherwise sound quality will be less than everyone is used to I suppose. If a macbook gets hot, these fans will be quite audible, as well as the typing (independent of heat though ;))
Marcus Ottosson
@mottosso
Jan 05 2015 14:01

Broadcast will happen @ http://www.twitch.tv/learnclang

Marcus Ottosson
@mottosso
Jan 05 2015 15:22
@/all Hopefully this should notify everyone, that the screencast date has changed! See above.
Cesar Saez
@csaez
Jan 05 2015 20:05
Hi @mottosso, Is there a place to upload an image to be used on a wiki page? I would like to add an animated gif to the page about vim (similar to the one in the sublime text) but don't know where I should upload the image.
Marcus Ottosson
@mottosso
Jan 05 2015 20:08
I typically drop an image into an empty issue, and copy the link.
You can even copy an image, e.g. Ctrl-c or screenshot it, and paste it into an issue, and it will be uploaded.
Marcus Ottosson
@mottosso
Jan 05 2015 21:06
The Vim page looks great, @csaez. Good work!
Cesar Saez
@csaez
Jan 05 2015 21:12
Thanks :)
macgio
@macgio
Jan 05 2015 21:27
hi @mottosso, thanks a lot for this initiative and for sharing all this resources
Marcus Ottosson
@mottosso
Jan 05 2015 21:28
You are very welcome @macgio :) Will you be joining us on Wednesday for the screencast?
macgio
@macgio
Jan 05 2015 21:29
I hope to :) passed he message to some friends as well
Marcus Ottosson
@mottosso
Jan 05 2015 21:29
That's great, the more the merrier :)