Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » C compilers

This thread is locked; no one can reply to it. rss feed Print
C compilers
KeithS
Member #11,950
May 2010

Hello,

I noticed since when I used to do a bit of coding before, there is a new C standard, C11.

I am using MinGW on Windows 10, which to my understanding is still C99 standard. Just out of interest, I have a couple of questions regarding;

What compilers are you using for coding in C on Windows for C11 standard? Are you using C11 at all?

Just FYI, I would be using it through the Code::Blocks IDE. I am not fond of MSVS.

And...

How is the compatibility / usability of A5 with C11? Is A5 still the latest distribution of Allegro? I read that SDL, for example (not that I use it), is soon to be dropping "support" of MinGW.

Sorry for these questions, I'm only just getting back into the loop, and beg for your patience, please.

Thanks in advance...

* * * * * * * * * * *

My Noobish Blog

Chris Katko
Member #1,881
January 2002
avatar

MinGW uses GCC. So all you should need is to pass the -std=c11 flag.

https://gcc.gnu.org/wiki/C11Status

There "shouldn't" be any problems using C11 with Allegro. Newest version of Allegro is always here:

https://github.com/liballeg/allegro5

5 is the major version. It hasn't and won't change for a very long time as it represents a large break in compatibility / API with A4. For minor version numbers, it's at least:

Allegro 5.2.4

per here.

http://liballeg.org/

And this article says MinGW with the w64 fork, supports all the way up to C11:

https://nullprogram.com/blog/2016/06/13/

Quote:

Of course my first natural choice is MinGW, specifically the Mingw-w64 fork. It’s GCC ported to Windows. You can continue relying on GCC-specific features when you need them. It’s got all the core language features up through C11, plus the common extensions.

http://mingw-w64.org/doku.php

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Neil Roy
Member #2,229
April 2002
avatar

I have always used C and I compile all my programs with -std=gnu11, I compile with MinGW using Code::Blocks as my IDE. I recommend using the gnu11 version of C11 as it also includes certain useful gnu extensions, which I honestly can't remember what they are at this moment, but I do recall needing -std=gnu11 instead of -std=c11 for some reason.

I use the following version of MinGW-W64 available here: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/7.2.0/threads-posix/dwarf/

My Deluxe Pacman 1 and 2 games were both compiled with C11 and Allegro 4 and 5, actually, I compiled Allegro 5 myself using the C11 setting (gnu11) without problems.

---
“I love you too.” - last words of Wanda Roy

Kitty Cat
Member #2,815
October 2002
avatar

I would recommend using -std=c11. The point of a standard is that it's standard and the code is portable to any compiler/system implementing the standard. -std=gnu11 will enable GCC-specific extensions that other compilers will choke on, whereas with -std=c11 any GCC extensions will require the use of double-underscores or explicit marking (e.g. __typeof(foo) instead of typeof(foo), __extension__({ ... }) instead of ({ ... })), which makes it clear when you're using non-conformant constructs that makes your code GCC-exclusive.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

KeithS
Member #11,950
May 2010

OK, thank you for the information!

Regarding the Allegro A5 distribution; at my stage right now I would rather download the Windows binaries. Back in the day when I was on Linux I used to build it, but at the moment I am worried I might mess up the build (until I regain a little more experience).

Which should I obtain here?

Win Binaries

I am assuming the file;

allegro-i686-w64-mingw32-gcc-7.2.0-posix-dwarf-static-5.2.4.1.zip

...would be the right one for me.

* * * * * * * * * * *

My Noobish Blog

Chris Katko
Member #1,881
January 2002
avatar

That definitely looks like the right link for the newest Allegro binaries.

i686 is 32-bit. x86_64 is 64-bit. I'd recommend always using 64-bit unless you have a good reason not to. Otherwise, you're stuck with a 2 GB RAM limit and all function calls go through a 64-bit-to-32-bit compatibility layer called Wow64. *

Static vs dynamic is static vs dynamic compilation. When it's static, Allegro is compiled into your program. Dynamic sits as a DLL.

I'm not sure which is "best" in the case of Allegro 5 (I recall someone saying one of them had more issues when you installed on other systems), but both should work.

(Side sidenote: *They "say" it's not slower, but I'd call B.S. on that because you're still sending every system and library call function through an additional compatibility function.)

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

KeithS
Member #11,950
May 2010

Thanks again, for the clarification.

So the one I need is this one;

allegro-x86_64-w64-mingw32-gcc-7.2.0-posix-seh-static-5.2.4.1.zip

A very small, additional confusion was born from this, though, so my apologies for the insistence.

I was assuming that the "static" in the file name meant that the Allegro library had been built statically for the binary, not that it would build the programs you created with Allegro statically. I thought that the option to build statically or dynamically remained yours using the flag;

-static

This raised yet another question for me. I've been looking around trying to clarify it myself, but I'm only be making this worse if I don't ask (I want to get it right).

Is there any reason I should not use this file?

allegro-5.2.4.0.zip

In other words, why are some of those binaries MinGW specific?

Again, sorry for being a pain!

Thanks in advance.

* * * * * * * * * * *

My Noobish Blog

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

To clarify,

Your binaries need to match your compiler version exactly, or else you will have problems.

Dynamic builds depend on 'Dynamic Link Libraries" (*.dll) on Windows, or "Shared Object" files on Linux (*.so). Static builds depend on linking the library code directly into your executable, so there is no dll or so.

"allegro5.2.4.0.zip" - why shouldn't I download this file? Because it's only the source code and then you would have to build allegro yourself.

As an aside, does anyone else have the persistent problem of typing 'source codd' whenever they mean 'source code'? I feel like I'm having seafood. 8-)

{"name":"383_1129.z.2000.1500.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/9\/e96630f2f9771f9568b5706afd4e0e49.jpg","w":2000,"h":1412,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/9\/e96630f2f9771f9568b5706afd4e0e49"}383_1129.z.2000.1500.jpg

Neil Roy
Member #2,229
April 2002
avatar

Kitty Cat said:

I would recommend using -std=c11.

No. I won't. I use GNU compilers, period. My projects are built for gnu compilers. If you try building it using something else, than I will want to know how in hell you got a hold of my source code? :) There's no shortage of gnu compilers, but hey, knock yourself out dreaming up problems that will never happen.

---
“I love you too.” - last words of Wanda Roy

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

@Neil,
Relax man, nobody's tryin to take your gnu away. ::)

Really though, for applications, portability doesn't matter so much, as long as the compiler you're using has been ported to all the platforms you care about. :/

But from a library builder's perspective (yes, there are other perspectives), you want your library to be as portable as possible. I personally hate MSVC and think it's a steaming pile of poo for an IDE but I digress. I still plan to fully support MSVC for my eagle library when I find the time or someone else with the skill to make it work. For example, many people will refuse to use your code simply because it doesn't come with an msvc project. Some coders are simply illiterate when it comes to using any other IDE or compiler.

EDIT
Funny thought. Wonder why nobody's ported MSVC to linux? Ha aha hahhha aaaahahaa (maniacal laughter ensues)...

bamccaig
Member #7,536
July 2006
avatar

It's not entirely unreasonable for Microsoft to build MSVC for Linux in the near future. They're being forced to support Linux for Web and various other ventures. They're starting to surrender on the OS front and focus more on software. I'll keep holding out though. They won't do it willingly, but they'll submit by force. That said, it'll probably require community involvement to pull it closer to the standard (unless they just replace the compiler with a free option that's already closer). Since my job requires ASP.NET/MVC use the VsVim extension to make the environment Vim-like in ways. It still requires way too much mouse involvement. For example, finding and switching files. There are also benefits to its "intelisense" when it works. There are a handful of features that I use that can be useful, but generally tripping over the IDE overrides them in general. You still don't need it. It doesn't do anything so well that you need it. They might well find that there's less and less of a market for it going forward, and developers are forced to stop being babies and learn to code "for real". Well, we can dream.

KeithS
Member #11,950
May 2010

Dynamic builds depend on 'Dynamic Link Libraries" (*.dll) on Windows, or "Shared Object" files on Linux (*.so). Static builds depend on linking the library code directly into your executable, so there is no dll or so.

Thank you. Well, that's clear, and it isn't in another sense...

I'm having trouble getting my head around something, regarding that there are static and dynamic versions.

So, yes. I would want to build static projects with Allegro.

Therefore, I want the static binary.

I got that much...

I am still not sure if I have to be redundant and specify in the linker

-static

I'm assuming not for the Allegro libraries, but I would need to anyway to statically link the rest of the MinGW dependant code.

Hope that makes sense. I'm still very rusty. I used to be able to do all this before and know why, but not at the moment....

Sorry!

* * * * * * * * * * *

My Noobish Blog

Samuel Henderson
Member #3,757
August 2003
avatar

bamccaig said:

It's not entirely unreasonable for Microsoft to build MSVC for Linux in the near future.

They already have, sort of. We've been using it for 6 months: https://blogs.msdn.microsoft.com/vcblog/2017/04/11/linux-development-with-c-in-visual-studio/

Basically it's an extension to Visual Studio 2015/2017 that replaces cl.exe with gcc on a remote linux system (or gcc in that weird Linux subsystem thing in Windows 10). It also uses gdb/gdb-server as a debugging engine (but still retains the typical Visual Studio debugger UI)

It is definitely not as clean as just straight up developing on Linux using vim + makefile, however 4 out of 5 members of my team had absolutely no experience with gcc / development in linux ... so the VC++ for Linux development was a good way to ease them into it. I'm 100% confident that we would have wound up using either Netbeans or Eclipse to develop our Linux application, both of which (in my opinion at least) suck as C++ IDEs compared to Visual Studio.

=================================================
Paul whoknows: Why is this thread still open?
Onewing: Because it is a pthread: a thread for me to pee on.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

With gcc, you should specify -static, but not on Linux.

If there's a shared name between a static archive and a dynamic one, gcc will favor the dynamic one. Usually library authors are smart enough to name them differently, like so : libpng16.dll.a and libpng16.a . Then there's no way it can get screwed up.

EDIT

They haven't ported anything. All they do is connect to a linux machine and use gcc! They're still running windows!

Samuel Henderson
Member #3,757
August 2003
avatar

They haven't ported anything. All they do is connect to a linux machine and use gcc! They're still running windows!

You are 100% correct. The IDE remains on Windows. The binaries that are produced remain on the Linux system and are indistinguishable from binaries produced with make-files using equivalent gcc flags. However I still find it an interesting combination of the Visual C++ IDE with gcc as a compiler.

Back to bamccaig's original point though, in recent years Microsoft has released a version of Visual Studio for MacOS. Basically it's just for cross platform development of mobile/web applications, however there are two fairly recent announcements from the Microsoft world that I believe could stir up enough interest to warrant a full blown port of MSVS to Linux and OSX.

#1: Microsoft recently announced they will be releasing their own 'Linux' operating system. Reading their press release about it they basically admit that Windows is not really suited (/cough too bloated /cough) for the various lightweight hardware configurations of 'IoT' devices and the Linux kernel was much more suitable for them to build a platform around.

#2: .NET Core 3 will support Desktop Applications (including WinForms). (Albeit I agree that this doesn't really have anything to do with MSVC, however if they release a full blown C# IDE for Linux.

Actually, I don't know. Even if Microsoft does wind up shipping these two products (I'm pretty sure the .NET Core 3 thing will definitely happen) I don't know if there'd be enough of an influx of new developers to the Linux platform clamoring for a full blown Visual Studio port.

=================================================
Paul whoknows: Why is this thread still open?
Onewing: Because it is a pthread: a thread for me to pee on.

bamccaig
Member #7,536
July 2006
avatar

I don't think Linux developers will ever care to have a Visual Studio port. If there is ever a demand for it it'll be from Windows developers that find themselves in Linux by force. If anything, the whole "run VS on Windows to cross-compile for Linux" thing will probably prevent that.

In other news, I think that Microsoft's interest in Linux is dangerous. The Linux kernel team has never really made free software a priority. Though I think they generally support the ideals, they aren't religious about them like RMS. Kind of makes me worry about the future of free operating systems..

Chris Katko
Member #1,881
January 2002
avatar

Linus would never intentionally sabotage his own ecosystem and legacy just for a couple of bucks from Microsoft. Remember when he gave nVidia the finger? :)

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

bamccaig
Member #7,536
July 2006
avatar

I think that Linus is just genuinely interested in software engineering so I agree that I don't think that he'd sabotage it. However, he doesn't actually control it. It's free software. Others can take it and fork it, and the thousands of developers that maintain it could choose sides and eventually fuck us all.

Linus has apparently refused the GPLv3 because it might prevent using Linux for DRM. Many other Linux developers also signed a petition refusing GPLv3. So obviously they don't care entirely about software freedoms. I think that Linus cares mostly about the "puzzles" of engineering. I think that the GPL happens to have been a way to protect Linux from corporate interests and build momentum and collaboration. It was convenient. He didn't choose it because he cared specifically about protecting the freedom aspect for users. I wouldn't put it past him to fuck us in the end if it suits him then. Not that he necessarily is in complete control either. Ultimately, I think that the GPL is forgiving enough that the system could be overtaken if we fall asleep and let a corporation tempt us away from freedom (Canonical is already trying).

Note that the Linux kernel itself is also only a piece of the system. The overall system depends on many, many projects. It could be crippling if some of them fell into the wrong hands and pulled people towards a non-free system with the promise of features. Ultimately, that's the thing we need to fear. A corporation with lots of resources could take free software, develop new features that everybody wants and release them non-free (or use a tricky copyleft mechanism, such as charge an insane amount of money to access the source code for example, which the GPL doesn't prohibit). And if people decide that the convenience of the features is more valuable at the time than their freedom then support and resources could shift to the non-free option. And before long the free option will stagnate and die, leaving only the non-free option. It's something we need to collectively defend against.

Chris Katko
Member #1,881
January 2002
avatar

bamccaig said:

Linus has apparently refused the GPLv3 because it might prevent using Linux for DRM.

Well, he literally gave the finger to nVidia for benefiting from Linux without giving back to the open-source nVidia drivers.

As much as I hate DRM, I'm not actually opposed to allowing binary drivers and DRM. Like, if having DRM lets Netflix run on Linux, so be it. Even though it's likely easy to bypass, it's about appeasing stupid heads. (The same reason many AAA companies have DRM--their publisher FORCES them to use it while 99% of game programmers are gamers and gamers hate when DRM explodes in their face.) And binary drivers, many companies still have a conservative / historical / ancient mindset of "I wrote it, therefor I should be the only one that benefits from it."

There's also the very REAL issue of whoever is the platform leader, has MILLIONS in IP (and even more in hidden, non-public IP), that they don't want people simply copying. As much as nVidia is a big bunch of dicks for not contributing back to open source, they also have a reasonable premise for keeping their fastest drivers a secret. There are dozens of real Chinese companies that would (and do) reverse-engineer nVidia's products and are completely un-sueable because of their government. So while I wouldn't be surprised that their secrets DO get reverse engineered, there's the question of EASE of reverse engineering.

Likewise, Wifi on Linux is DRM protected ... ish. Why? Because of all the government regulations that if they made it completely open, then anyone on Linux could switch their wifi gear's channel region-code. And if they do that, people could very easily start using illegal radio spectrums and the news and idiots in government won't see "300 separate people abuse a tool" they'll see "Linux enables abusers".

Further, keeping that binary mode for wifi has encouraged many more developers to support Linux. I remember 2005 when literally NOBODY had !@$!@$ing Wifi support. You got it installed and... congrats... you could Linux it for almost nothing. Because there were no drivers.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Samuel Henderson
Member #3,757
August 2003
avatar

Further, keeping that binary mode for wifi has encouraged many more developers to support Linux. I remember 2005 when literally NOBODY had !@$!@$ing Wifi support. You got it installed and... congrats... you could Linux it for almost nothing. Because there were no drivers.

Oh man. I remember trying to get Wifi working in Linux back in college. (So that would have been probably 2006-2007ish). I spent countless hours working with the college's resident Linux Guru to try and get it working. The problem was that the generic free/open driver only supported 'WEP' protected networks and the college was using WPA. I think we eventually got it working by using a tool (fwcutter) that extracted the driver and firmware from the card's Windows Driver and wrapped it in a context that Linux could use.

=================================================
Paul whoknows: Why is this thread still open?
Onewing: Because it is a pthread: a thread for me to pee on.

KeithS
Member #11,950
May 2010

Thanks, Edgar Reynaldo.

Yeah, it has all clicked again. In fact, I have a very vague recollection that if you wanted to statically link, you could go ahead and rebuild the whole Allegro library from the source alongside your project with the static link option. I might be wrong, but if I'm not mistaken it was either Elias or Tomasu who helped me with something like that on the IRC chat, back then.

Of course, it was Linux, then. I'm yet to look into how CMake, or its equivalents, work on Windows.

And thinking of that, perhaps I should install a Linux OS on my present rig, too, so I can work on both, again.

Thanks again!

* * * * * * * * * * *

My Noobish Blog

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

They haven't ported anything. All they do is connect to a linux machine and use gcc! They're still running windows!

You are 100% correct. The IDE remains on Windows. The binaries that are produced remain on the Linux system and are indistinguishable from binaries produced with make-files using equivalent gcc flags. However I still find it an interesting combination of the Visual C++ IDE with gcc as a compiler.

Ok, I'll give them credit for that. Being able to choose the compiler your IDE uses is a big plus, but I still hate Visual Studio compared to Code::Blocks. Although, if I wanted to develop for Linux, I would want to be in a Linux environment, not a tunneled Linux session on a Windows host.

KeithS
Member #11,950
May 2010

Upon my return to hobby programming a very short while ago, I thought I might try starting with C#, on MSVS Community. The whole thing was a very, very bad experience in which everything seemed to be along these lines;

"For this, you need to install this MS component, and for that, this other MS component, which needs this and this other MS...." etcetera.

I wish I could figure out how to strip all of it out as if it had never been there without doing a Windows reinstall.

The long and short of it was I was doing absolutely no coding. I was nearly put off, until I remembered Code::Blocks and a gcc version for Windows (which even without Code::Blocks works fine off command line, which I'm comfortable with).

And of course, Allegro...

I do think I will come down on the side of the dynamically linked binary, though, for the moment. Windows is rather "proud"(?) of its dll's for development (don't ask me to expand on that, it is just an impression I get), IIRC, and in any case, I won't be "distributing" any projects (for the time being) that need to be static, really.

* * * * * * * * * * *

My Noobish Blog

Go to: