I’ve now demonstrated how to build the SFML 2.0 binaries in an IDE and also with a build utility (better). However, all my tutorials have undoubtedly been Windows centric – I discussed Microsoft Visual C++ and MinGW, after all. Well now it’s time to make that right – in this article I’m going to explain how to build the latest versions of the SFML 2.0 binaries for Ubuntu, using GCC.
Other Unix Operating Systems
With the addition of the post, I’ve covered Windows – both MinGW and MSVC – and also GCC on Ubuntu, Linux Mint, Debian or an Ubuntu variant such as Xubuntu. But what about the rest of you? What if you’re on another Unix operating system? Well, the fact is that you should still have access to GCC. This means you should be able to invoke the actual build operation with the same commands. The other software we need – CMake – should also be available for most platforms. Thus the core elements of what I demonstrate here for GCC with Ubuntu should be applicable to GCC with other Unix platforms.
The thing that you will have to bear in mind, however, is that the other terminal commands I use (such as apt-get to install software) may not be available on your system. You may have a different terminal, and different package manager which is invoked via a different command and syntax. If you want to follow this tutorial, you’ll have to translate those commands into ones appropriate for your OS. Just remember that the invocation of cmake and make should be the same in most circumstances.
Read on the for textual tutorial. I suggest that even those of you who prefer videos read this one, as we’ll be working primarily with the terminal: something which is undoubtedly easier to talk about in writing. Read more…
I just uploaded a video to YouTube – in fact, the first video I’ve featured in visually (I used a webcam) – which is also embedded in a post on here. Anyway, for whatever reason it uncontrollably ate up my internet bandwidth, resulting in the following horrifying output from ping. I found it funny, and I hope you do too. Don’t feel obliged to read it all…
alex@alex-PC:~$ ping www.google.com PING www.l.google.com (188.8.131.52) 56(84) bytes of data. 64 bytes from 184.108.40.206: icmp_req=1 ttl=52 time=849 ms 64 bytes from 220.127.116.11: icmp_req=2 ttl=52 time=1633 ms 64 bytes from 18.104.22.168: icmp_req=3 ttl=52 time=1704 ms 64 bytes from 22.214.171.124: icmp_req=4 ttl=52 time=1398 ms 64 bytes from 126.96.36.199: icmp_req=5 ttl=52 time=1508 ms 64 bytes from 188.8.131.52: icmp_req=6 ttl=52 time=1144 ms 64 bytes from 184.108.40.206: icmp_req=7 ttl=52 time=871 ms 64 bytes from 220.127.116.11: icmp_req=8 ttl=52 time=1425 ms 64 bytes from 18.104.22.168: icmp_req=9 ttl=52 time=1399 ms 64 bytes from wy-in-f99.1e100.net (22.214.171.124): icmp_req=10 ttl=52 time=1379 ms 64 bytes from 126.96.36.199: icmp_req=11 ttl=52 time=1045 ms 64 bytes from 188.8.131.52: icmp_req=12 ttl=52 time=1413 ms 64 bytes from wy-in-f99.1e100.net (184.108.40.206): icmp_req=13 ttl=52 time=1291 ms 64 bytes from 220.127.116.11: icmp_req=14 ttl=52 time=1566 ms 64 bytes from 18.104.22.168: icmp_req=15 ttl=52 time=1622 ms 64 bytes from 22.214.171.124: icmp_req=16 ttl=52 time=1543 ms 64 bytes from 126.96.36.199: icmp_req=17 ttl=52 time=1495 ms 64 bytes from 188.8.131.52: icmp_req=18 ttl=52 time=1525 ms 64 bytes from wy-in-f99.1e100.net (184.108.40.206): icmp_req=20 ttl=52 time=1040 ms 64 bytes from 220.127.116.11: icmp_req=21 ttl=52 time=1115 ms 64 bytes from 18.104.22.168: icmp_req=22 ttl=52 time=1230 ms 64 bytes from 22.214.171.124: icmp_req=23 ttl=52 time=1301 ms 64 bytes from 126.96.36.199: icmp_req=24 ttl=52 time=1318 ms 64 bytes from 188.8.131.52: icmp_req=25 ttl=52 time=1331 ms 64 bytes from 184.108.40.206: icmp_req=26 ttl=52 time=1524 ms 64 bytes from wy-in-f99.1e100.net (220.127.116.11): icmp_req=27 ttl=52 time=1675 ms 64 bytes from wy-in-f99.1e100.net (18.104.22.168): icmp_req=28 ttl=52 time=1623 ms 64 bytes from 22.214.171.124: icmp_req=30 ttl=52 time=1221 ms 64 bytes from 126.96.36.199: icmp_req=31 ttl=52 time=1239 ms 64 bytes from 188.8.131.52: icmp_req=32 ttl=52 time=1534 ms 64 bytes from 184.108.40.206: icmp_req=33 ttl=52 time=1245 ms 64 bytes from 220.127.116.11: icmp_req=34 ttl=52 time=1524 ms 64 bytes from 18.104.22.168: icmp_req=35 ttl=52 time=1587 ms 64 bytes from 22.214.171.124: icmp_req=36 ttl=52 time=1359 ms 64 bytes from 126.96.36.199: icmp_req=37 ttl=52 time=1561 ms 64 bytes from 188.8.131.52: icmp_req=38 ttl=52 time=1360 ms 64 bytes from 184.108.40.206: icmp_req=39 ttl=52 time=1334 ms 64 bytes from 220.127.116.11: icmp_req=40 ttl=52 time=1250 ms 64 bytes from wy-in-f99.1e100.net (18.104.22.168): icmp_req=41 ttl=52 time=1291 ms 64 bytes from 22.214.171.124: icmp_req=42 ttl=52 time=1225 ms 64 bytes from 126.96.36.199: icmp_req=43 ttl=52 time=1237 ms 64 bytes from 188.8.131.52: icmp_req=44 ttl=52 time=1663 ms 64 bytes from 184.108.40.206: icmp_req=46 ttl=52 time=1702 ms 64 bytes from 220.127.116.11: icmp_req=48 ttl=52 time=1766 ms 64 bytes from 18.104.22.168: icmp_req=51 ttl=52 time=1689 ms 64 bytes from 22.214.171.124: icmp_req=52 ttl=52 time=1663 ms 64 bytes from wy-in-f99.1e100.net (126.96.36.199): icmp_req=53 ttl=52 time=1470 ms 64 bytes from 188.8.131.52: icmp_req=54 ttl=52 time=1178 ms --- www.l.google.com ping statistics --- 54 packets transmitted, 48 received, 11% packet loss, time 657488ms rtt min/avg/max/mdev = 849.764/1397.715/1766.702/216.293 ms, pipe 2
Yes. You read that right. At times my ping was as high as 1.75 seconds. Yes. That’s ONE POINT SEVEN FIVE SECONDS. Not to mention 11% package loss…
In case you’ve already tried to watch my video in the previous post, sorry. For some reason it broke during the upload so the picture was lost. I’m about to reupload it now, hopefully with better results. As soon as it’s on, I’ll update the previous post with the new video.
Do you remember ages ago when I mentioned a project I was working on which would provide support for quantities with units in C++? Probably not. It really was ages ago. Nonetheless, I did post about it, saying it would take me about a week. Needless to say, other things got in the way and it didn’t happen. Well I’m back on it now. It’s going to take longer than a week as I’m going for something more generic this time.
I was going to ask you to help me choose a name. Even though I’ve now chosen one, I’ll still get some opinions, I think. So tell me, which of the following names is best in your opinion for a library which handles units, quantities and dimensions?
In a week or so I’ll have hopefully made some progress. I’ll add some details to the project page and also link you all to the SourceForge page. Once there’s a fair number of vote’s I’ll also reveal the name I’ve actually chosen – and whether I intend to stick with it or yield to your suggestions.
I’ve just recorded a short video introducing you to C++0x. Unless you’ve been living under a rock for the past few years, or don’t have an internet connection (and somehow still frequent my blog) then chances are you know about it anyway. You may well have been reading Dr. Stroustrup’s FAQ, my own C++0x articles, or some of the many other sources available on the new standard.
Anyway, this video is going to be the first in a series that will cover C++0x features in video form, rather than textual. Enjoy!
Thought you might like to ssee C++0x support for various compilers. Here is a list for GCC, or you can check out this comparison, which features many of the major compilers: Digital Mars’, Intel’s, Microsoft’s, IBM’s and, of course, GCC.
You’ll see that GCC has better support than many, which is in fact why I’ve recently switched from Microsoft Visual Studio to Code::Blocks and/or Qt Creator. I might post a little more about my experiences thereof at a later date. In particular, notice that both MSVC and GCC support long long and nullptr (about which I posted late yesterday). Indeed, long long has unanimous support across all the compilers mentioned in the chart.
And what about the last part of the title? Well I’ve been continuing to say C++0x (and probably will still do so), but as we can expect it’s release sometime this year, I guess I should start saying C++11. Ah well, I probably won’t. That is all.
I’m going to mention two little C++0x features today. I don’t have much time, but I thought I may as well share them briefly. They’re both fairly small and quick to explain, so let’s get to it. I’ve put the one that’s faster to discuss first. As always, check out Dr. Stroustrup’s FAQ for more information.
I. long long Integers
The C++0x standard has a new type – the long long integer – which is guaranteed to be at least 64bit. No more annoyances because too many compilers make int and long int the same size – use long long int and you can be sure that you’ll get 8 whole bytes of integral goodness!
Apparently this feature was already supported by a number of compilers, but it’s standard now so you don’t have to worry about non portable code (well you do, but you can blame compiler vendors for being slow to comply with the new standard… ). There’s really not much to say here, merely that you have two 64bit types: long long (i.e. long long int) and unsigned long long (i.e. unsigned long long int). Also note the new literal suffixes: LL for long long and ULL for unsigned long long.
This one’s exactly as the name suggests: that is, the nullptr keyword represents a null pointer. Previously one might have done something like this:
char* name = 0;
In C++0x, however, one can do the following instead:
char* name2 = nullptr;
These two examples have the same result, that is name == name2 would evaluate to true. On the other hand, while we can also assign the value o to an integral type, we can assign nullptr only to a pointer variable. So the following would yield a compiler error:
int age = nullptr; // compiler error: age is not a pointer
This is all well and good, but it’s quicker to type 0 than nullptr. Why, therefore, should we use the latter over the former? Well the fact is that the double meaning of 0 as the integer 0 and as the null pointer 0×00000000 has the potential to cause problems. Allow me to demonstrate using Dr. Stroustrup’s example. Consider a function f with two overloads:
- void f(int)
- void f(char*)
We call f(0). What happens? Well in fact, f(int) is called, but what if we wanted to pass a null pointer to f(char*). Previously we should have had to resort to something like f((char*)0), which is rather undesirable, in my opinion at least (and, presumably in the opinion of committee members!). So, do the right thing and use nullptr to represent your null pointers.
As you know, I’ve now started to provide prebuilt SFML 2.0 binaries, downloadable from Google docs. Previously you had to subscribe to the blog by email to get them. However, one or two of you weren’t too keen on this, so I’ve decided to place a link here.
If you’ve already subscribed by email to get them, don’t feel short changed. You’ll still come out on top. I intend to regularly update the binaries, and I’ll send email subscribers an email notification with the new link as soon as the files are online. This page will be updated as well, but I shan’t be able to do it as frequently. Also, of course, you won’t be reminded to download a new version if you’re not subscribed by email.
In fact, I’ll take this opportunity to remind you: to get prompt notification of updated SFML 2.0 binaries, including builds for different platforms, then subscribe to the blog by email if you haven’t already. Just enter your email address on the right and click ‘Sign me up’; if you’re logged in to WordPress, you probably won’t need to enter the email address.
However, if you really don’t want email notifications and prefer to subscribe via WordPress or using the RSS feed then fear not. You can download the binaries on my new downloads page – you just might get updates a little less frequently.
Disclaimer: All the files provided in these downloads are AS-IS. I cannot guarantee that they are suitable for purpose, and nor can I be held accountable or responsible for any damages caused by them, even if I was advised of such. Note also that SFML is developed by Laurent Gomila. I do not intend to imply by this service that I am in any way affiliated with him. I compile the binaries from his source and provide them to you merely as a convenience.
I have finally recorded and released the videos to go alongside the Video Modes and Windowing tutorial. They are now embedded in that post, and also in this one, so you can find them easily. Enjoy!