EEVblog Electronics Community Forum

Products => Computers => Programming => Topic started by: Picuino on October 31, 2021, 09:56:19 am

Title: Actual C compiler for Windows for free
Post by: Picuino on October 31, 2021, 09:56:19 am
I don't use the c language much to program on the PC (Windows). Now I have considered updating my old compilers and I don't know what open or free software options exist.

Any advice?
Title: Re: Actual C compiler for Windows for free
Post by: Dubbie on October 31, 2021, 10:07:47 am
GCC?
Title: Re: Actual C compiler for Windows for free
Post by: DC1MC on October 31, 2021, 10:15:26 am
Visual Studio Community Edition if you want it for windows -> https://visualstudio.microsoft.com/vs/community/
Title: Re: Actual C compiler for Windows for free
Post by: FlyingDutch on October 31, 2021, 10:17:24 am
hello,

"Visual Studio Comunity" is free software. As one of it's compilers you can install C++ compiler.

Best regards
Title: Re: Actual C compiler for Windows for free
Post by: Picuino on October 31, 2021, 10:24:57 am
GCC?
Good for command line. I have an old version of GCC 3.45 from MinGW. What is the newest one? Cygwin perhaps?

Visual Studio Community Edition if you want it for windows -> https://visualstudio.microsoft.com/vs/community/
Good for Windows GUI. Downloading. Thanks
Title: Re: Actual C compiler for Windows for free
Post by: daqq on October 31, 2021, 10:48:01 am
I use CodeBlocks as a whole package - straighforward, no nonsense single download.
Title: Re: Actual C compiler for Windows for free
Post by: Karel on October 31, 2021, 11:03:41 am
https://www.mingw-w64.org/ (https://www.mingw-w64.org/)
Title: Re: Actual C compiler for Windows for free
Post by: Picuino on October 31, 2021, 11:21:15 am
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download
Title: Re: Actual C compiler for Windows for free
Post by: newbrain on October 31, 2021, 03:45:58 pm
Visual Studio Community is a very powerful, complete and free as in beer IDE - I happen to like it a lot - make sure to comply to the license requirements, if you intend to use it at work: at home, or < 5 employees you should be fine (IANAL, TINLA).
The quality and standard conformance of the Microsoft C/C++ compiler has improved a lot in recent years, though, for the latter, there are no standard C89 or C99 conforming modes (only C11 or C17).

Another fine alternative is LLVM/clang, free as in Apache licensed and with an MS C compiler mode (at least, same options). I used VS to compile it  ;).

Title: Re: Actual C compiler for Windows for free
Post by: TheCalligrapher on October 31, 2021, 04:01:22 pm
C compiler that comes with Microsoft Visual Studio.

It has always been an excellent C89/90 compiler (aside from some ridiculous preprocessor problems). By VS2017 they fixed their preprocessor issues and added almost full C99 support as a "langauge extension". In VS2019 we finally get focused and dedicated support for modern C standards.

Still no VLA though :)
Title: Re: Actual C compiler for Windows for free
Post by: paf on October 31, 2021, 04:31:35 pm
Are you sure you want VLA in C?
https://blog.joren.ga/vla-bad (https://blog.joren.ga/vla-bad)
Title: Re: Actual C compiler for Windows for free
Post by: TheCalligrapher on October 31, 2021, 04:51:36 pm
Are you sure you want VLA in C?

Yes, I am. VLA is an extremely valuable feature.

https://blog.joren.ga/vla-bad (https://blog.joren.ga/vla-bad)

The person who wrote that completely missed the point of what VLA is and what they are for. As many people who don't understand the purpose of VLA, the author focused on the matter of stack-allocated VLA and problems associated with stack-allocated VLA. These concerns are perfectly valid, but in reality, this is a completely secondary and insignificant matter, which does not really have much to do with the proper usage of VLA.

VLA does need to be stack-allocated. And (more importantly!) an array does not have to be a VLA for you to work with it through VLA interface. These two points immediately slam-dunk invalidate all reasoning presented at that link. The author apparently knew that, since later in that post they kinda "touch" the usage patterns that reveal the true value of VLA, but seeing that it basically derails their previous arguments, the author attempts to weasel out of the situation by referring to such bogus problems as "breaking conventions" :)

Here's my take on the matter: https://stackoverflow.com/a/54163435/187690
Title: Re: Actual C compiler for Windows for free
Post by: SiliconWizard on October 31, 2021, 05:06:07 pm
GCC?
Good for command line. I have an old version of GCC 3.45 from MinGW. What is the newest one? Cygwin perhaps?

All C compilers I know of are actually "command line". Even MSVC. Visual Studio just adds an IDE on top of the MS comand line tools, which, BTW, you can also install without Visual Studio IDE.
Likewise, you can use a number of other free IDEs along with GCC. If you like the Visual Studio interface, you can use Visual Studio Code for instance.

The latest GCC is 11.2. There's a number of ways to get it for Windows. If you were used to MinGW, you can just install MSYS2 and get it from there: https://www.msys2.org/ (https://www.msys2.org/)
You also have standalone installs here: https://www.winlibs.com/ (https://www.winlibs.com/)
Title: Re: Actual C compiler for Windows for free
Post by: newbrain on October 31, 2021, 06:17:08 pm
Are you sure you want VLA in C?
https://blog.joren.ga/vla-bad (https://blog.joren.ga/vla-bad)
Sorry, but the undefined behaviour in the very first example* immediately segfaulted my interest and I did not go further.

That said, I'm also not a big friend of VLAs, though they might come handy in some cases I must say I never felt the need to use them.
The official reason for MS not to implement them in their compiler is that they are seen as a vulnerable and easily abusable feature, akin to "gets()".

* Use of an object with automatic storage duration whose value is as yet indeterminate.
Title: Re: Actual C compiler for Windows for free
Post by: newbrain on October 31, 2021, 06:24:11 pm
the MS comand line tools, which, BTW, you can also install without Visual Studio IDE.
Technically correct (the best kind of correct :-+).
But since VS 2017 (IIRC) one cannot install them if they don't have a valid Visual Studio license.
This means they have exactly the same license restrictions, and the only way to get a VS license is (AFAIK, and apart buying one of the professional packages) downloading VS Community.

Not a change I like, but it is what it is (e.g: I cannot use them at work, as I don't have a VS license there).
Title: Re: Actual C compiler for Windows for free
Post by: SiliconWizard on October 31, 2021, 06:31:45 pm
the MS comand line tools, which, BTW, you can also install without Visual Studio IDE.
Technically correct (the best kind of correct :-+).
But since VS 2017 (IIRC) one cannot install them if they don't have a valid Visual Studio license.
This means they have exactly the same license restrictions, and the only way to get a VS license is (AFAIK, and apart buying one of the professional packages) downloading VS Community.

I don't know much about licensing. Just that you can install the command line tools for free, from the VS installer (Visual Studio Build Tools 2019). Downloaded the installer itself for VS Community - but I'm not aware of those tools being at all different from the licensed VS build tools. Possibly you can only use them as per the VC Community license, but they are otherwise just the same.

Do you mean that the build tools once could be used for free without licensing restrictions before 2017? Then that's what would have changed. But if, as seems to be the case for the OP, only uses this as hobby tools (they can correct me if I'm wrong here), it won't make a difference.

That said, in that case, I would certainly use GCC and ditch VS tools.
Title: Re: Actual C compiler for Windows for free
Post by: newbrain on October 31, 2021, 06:38:45 pm
Do you mean that the build tools once could be used for free without licensing restrictions before 2017?
As mentioned, I'm not so sure about the VS revision that brought the change, but, yes, their license was much more liberal before (as much that I had no qualms installing them at work, and I am very careful about these issues).
Title: Re: Actual C compiler for Windows for free
Post by: Jeroen3 on October 31, 2021, 07:06:03 pm
You can install mingw, it's an option when installing Qt community edition as well.

If you install Qt with mingw, you can also do plain C programs without any of the gpl problems Qt brings to the table. Using the IDE is free.
It uses cmake as build system.
Title: Re: Actual C compiler for Windows for free
Post by: emece67 on October 31, 2021, 07:40:36 pm
.
Title: Re: Actual C compiler for Windows for free
Post by: udok on October 31, 2021, 09:11:23 pm

That said, in that case, I would certainly use GCC and ditch VS tools.

Bad choice under Windows.  GCC ist not 100% compatible to the MS DLLs (exceptions handling!).
Much better choice is clang-cl, but the MS cl compiler produces very good code.
Title: Re: Actual C compiler for Windows for free
Post by: TheCalligrapher on October 31, 2021, 10:46:17 pm
That said, in that case, I would certainly use GCC and ditch VS tools.

GCC is a definitive loser at this point. Microsoft and Clang are leading the way with a gap that some might refer to as exponential. Come to think of it, GCC has always been intended as a mere "legacy code" compiler, but previosuly they at least managed to find some time and resources to keep up with the language. But not anymore apparently.

It might also be important to keep in mind, that regardless of what the target platform is, today 90-95% of the actual everyday application develoment is done in Visual Studio under Windows. Everything else is used as a final-stage integration and QA tools. Nobody develops with GCC, if we ignore statistical noise.
Title: Re: Actual C compiler for Windows for free
Post by: nigelwright7557 on October 31, 2021, 10:58:40 pm
Visual Studio Community is a very powerful, complete and free as in beer IDE - I happen to like it a lot - make sure to comply to the license requirements, if you intend to use it at work: at home, or < 5 employees you should be fine (IANAL, TINLA).
The quality and standard conformance of the Microsoft C/C++ compiler has improved a lot in recent years, though, for the latter, there are no standard C89 or C99 conforming modes (only C11 or C17).

Another fine alternative is LLVM/clang, free as in Apache licensed and with an MS C compiler mode (at least, same options). I used VS to compile it  ;).

I have used Visual Studio for about 20 years.
Generally works very well.

Microsoft do sometimes drop a clanger with it.
The buggers removed C++ winforms and left me high and dry.
There was an uproar and they eventually put it back in.

I do a bit of web development with it.
Some of my websites are quite big so being allowed to just update one or two files is great.
Went to do it one day and the option had been removed ! so 10 minutes to upload whole website ! instead of 10 seconds for 2 files.
I complained about it and they put it back in.
Since then it has been removed 3 times and 3 times put back in ! communication inside Microsoft isnt good at times if it keeps getting removed.

Title: Re: Actual C compiler for Windows for free
Post by: Nominal Animal on October 31, 2021, 11:57:51 pm
It might also be important to keep in mind, that regardless of what the target platform is, today 90-95% of the actual everyday application develoment is done in Visual Studio under Windows. Everything else is used as a final-stage integration and QA tools. Nobody develops with GCC, if we ignore statistical noise.
Really?  What ass did you pull that assumption from?

I'll grant you Windows application development and phone apps (Android and iOS) is done in Visual Studio under Windows, but that's it.
Title: Re: Actual C compiler for Windows for free
Post by: SiliconWizard on November 01, 2021, 12:35:54 am
It might also be important to keep in mind, that regardless of what the target platform is, today 90-95% of the actual everyday application develoment is done in Visual Studio under Windows. Everything else is used as a final-stage integration and QA tools. Nobody develops with GCC, if we ignore statistical noise.
Really?  What ass did you pull that assumption from?

I'll grant you Windows application development and phone apps (Android and iOS) is done in Visual Studio under Windows, but that's it.

Same remarks.
Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 01, 2021, 08:29:41 am
... without any of the gpl problems Qt brings to the table.

What are you talking about? Since when Qt brings gpl problems to the table?

The opensource edition of Qt is LGPL licensed which means you can freely use it in all kind of programs including
closed source and commercial programs without the need for an additional license or to pay a fee.
The only exceptions are: when linking static with the Qt libs and/or when you modify the Qt libs.
In the latter case, it suffice to opensource only the modifications of the Qt libs.
Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 01, 2021, 11:47:11 am
... without any of the gpl problems Qt brings to the table.

What are you talking about? Since when Qt brings gpl problems to the table?

The opensource edition of Qt is LGPL licensed which means you can freely use it in all kind of programs including
closed source and commercial programs without the need for an additional license or to pay a fee.
The only exceptions are: when linking static with the Qt libs and/or when you modify the Qt libs.
In the latter case, it suffice to opensource only the modifications of the Qt libs.

You need a commerical QT License for each Developer, if you want to make a living from your work.

You are wrong.

Again, the opensource edition of Qt is LGPL licensed.
All software that is LGPL licensed can be used to make a living from your work. Period.
Title: Re: Actual C compiler for Windows for free
Post by: udok on November 01, 2021, 11:49:54 am
... without any of the gpl problems Qt brings to the table.

What are you talking about? Since when Qt brings gpl problems to the table?

The opensource edition of Qt is LGPL licensed which means you can freely use it in all kind of programs including
closed source and commercial programs without the need for an additional license or to pay a fee.
The only exceptions are: when linking static with the Qt libs and/or when you modify the Qt libs.
In the latter case, it suffice to opensource only the modifications of the Qt libs.

If you want to make a living from your work, you need a commerical license.
You can only distribute your App, if you have a valid license subscription.

Over 4500$ for each developer and a one year subscription!

https://www.qt.io/pricing (https://www.qt.io/pricing)
Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 01, 2021, 11:59:03 am
You are NOT obliged to buy a commercial license. The Qt Company just wants to give you that impression.
You can use Qt in commercial closed source applications without the need for a commercial license, as long as you don't link static.
The Qt company is free to ask money for a commercial license.
You are free not to buy the commercial license and to use the opensource edition of Qt in commercial closed source software.
Don't believe their b*llsh*t.

edit:

https://softwareengineering.stackexchange.com/questions/47323/can-i-use-an-lgpl-licenced-library-in-my-commercial-app (https://softwareengineering.stackexchange.com/questions/47323/can-i-use-an-lgpl-licenced-library-in-my-commercial-app)

https://www.gnu.org/licenses/why-not-lgpl.html (https://www.gnu.org/licenses/why-not-lgpl.html)
Title: Re: Actual C compiler for Windows for free
Post by: paf on November 01, 2021, 12:32:08 pm
About VLAs (and other stuff) a good reference is:
https://gustedt.gitlabpages.inria.fr/modern-c/ (https://gustedt.gitlabpages.inria.fr/modern-c/)

And please remember that VLAs are an optional feature in C11. Yu should test if your compiler has it before using it.

Title: Re: Actual C compiler for Windows for free
Post by: newbrain on November 01, 2021, 12:37:44 pm
Don't believe their b*llsh*t.
To be honest, there is very little bullshit on the Qt site.

They repeatedly state (in various forms, this is taken from the FAQ, emphasis mine):
Quote
The Qt open source licensing is ideal for use cases such as open-source projects with open source distribution, student/academic purposes, hobby projects, internal research projects without external distribution, or other projects where all (L)GPL obligations can be met.

The only point they get (probably unintentionally) slightly wrong is:
Quote
Accept Digital Rights Management terms - Accept Digital Rights Management terms, please see the GPL FAQ
On this page (https://www.qt.io/download-open-source).
Specifically LGPLv3 gives an explicit exemption of section 3 of GPL, the one about DRM.

Moreover, there's a nice page which (correctly AFAICS) details the obligations of the various FOSS license (LGPLv3 GPLv2, GPLv3) used:
https://www.qt.io/licensing/open-source-lgpl-obligations (https://www.qt.io/licensing/open-source-lgpl-obligations)

Disclaimer: IANAL, TINLA - consult a specialized lawyer.
But I've worked for many years as an internal FOSS product owner, and as a go-to person (before legal, which is always needed) for FOSS licensing.
BTW, the product was LGPL, and we were both heavily contributing and making money by using it.

EtA: GPL, in its various incarnations especially the v3 ones, is a very complicated license. For this reasons it's widely misunderstood (even by many FOSS supporters). Sometimes the "peace of mind" of getting a commercial license can seem attractive, one gets some features more (as for Qt) and the cost might be reasonable or completely inconsequential depending of the volume of affairs.
Title: Re: Actual C compiler for Windows for free
Post by: newbrain on November 01, 2021, 12:58:09 pm
And please remember that VLAs are an optional feature in C11. Yu should test if your compiler has it before using it.
That's one of the reasons MS compiler does not declare C99 compliance, but does (better, and with explicit command line support) with C11/C17.
Title: Re: Actual C compiler for Windows for free
Post by: SiliconWizard on November 01, 2021, 05:17:48 pm
Are you sure you want VLA in C?
https://blog.joren.ga/vla-bad (https://blog.joren.ga/vla-bad)
Sorry, but the undefined behaviour in the very first example* immediately segfaulted my interest and I did not go further.

Yeah, most of this blog's rant is just very silly.
Sure stack space is limited - default is usually 2 MBytes on both Windows and Linux (Edit: on Linux, it depends - on my machines, it's 8 Mbytes). Just allocate a very big object on the stack, and it will just spectacularly crash in the same way. No need for VLAs here.
Code: [Select]
int main(void)
{
    double ThisWontEndWell[500000];
    ...
    return 0;
}

Of course when using VLAs, you should always check that the size will be under some predefined bound before declaring the array. That's common sense.

Now I admit I never use VLAs, but I can see in which situations they could come in handy, and even save stack space - it just allows to allocate the minimum amount you need in a given function call instead of allocating a fixed size (which would be the largest you need). And no, dynamic allocation is not the answer to everything here: it's usually a lot less efficient, and for small objects which only live within a given function, it often doesn't make sense.

Like most other C features, it can have its own risks. Use it accordingly. Yes VLAs can be risky in the hands of beginners. Experienced programmers should have no problem using them properly.

As to MS not supporting them, frankly MS compilers have been notorious not to be fully compliant to the C standard, in particular starting with C99. VLAs are not the only thing missing. Shipping a compiler that is not fully compliant to the standard for alleged security reasons is stupid. If that is even the rationale, which I'm not even sure here.
Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 01, 2021, 08:05:43 pm
Don't believe their b*llsh*t.
To be honest, there is very little bullshit on the Qt site.

You are right, I exaggerated there. But I still stand with my other points about LGPL'ed libraries & closed source software.
Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 01, 2021, 08:22:19 pm
“Open Source Qt” shall mean the non-commercial Qt computer software products, licensed under the terms of the GNU Lesser
General Public License, version 2.1 or later (“LGPL”) or the GNU General Public License, version 2.0 or later (“GPL”). For clarity,
Open Source Qt shall not be provided nor governed under this Agreement.


https://www.qt.io/terms-conditions/ (https://www.qt.io/terms-conditions/)

What The Qt company calls "non-commercial", can be used perfectly fine in closed source commercial software as long
as it (the Qt libraries) is licenced under the LGPL license and not statically linked.

Think about this: if LGPL'ed libraries couldn't be used by closed source (commercial) programs, then they couldn't
use, for example, printf() provided by glibc on Linux.
Title: Re: Actual C compiler for Windows for free
Post by: newbrain on November 01, 2021, 11:47:56 pm
Think about this: if LGPL'ed libraries couldn't be used by closed source (commercial) programs, then they couldn't
use, for example, printf() provided by glibc on Linux.
You don't need to convince me: my point was only that the site has quite clear indications of the various license regimens, and does not try to hide the FOSS ones.

I'm 100% aware and convinced that LGPL can be dynamically (or in equivalent ways) integrated in proprietary software, see my own words below:
I've worked for many years as an internal FOSS product owner, and as a go-to person (before legal, which is always needed) for FOSS licensing.
BTW, the product was LGPL, and we were both heavily contributing and making money by using it.
Maybe I should have added "...using it in our proprietary SW".
Title: Re: Actual C compiler for Windows for free
Post by: Nominal Animal on November 01, 2021, 11:51:52 pm
If you want to make a living from your work, you need a commerical license.
You can only distribute your App, if you have a valid license subscription.

Over 4500$ for each developer and a one year subscription!

https://www.qt.io/pricing (https://www.qt.io/pricing)
No. This has been discussed before, but heck, why not, let's repeat.

If you use the LGPL-licensed (License mode: LGPL v3) Qt (https://www.qt.io/product/features#js-6-3), and dynamically link your project against those unmodified libraries, you do not require a commercial license, and you do not need to pay a cent to anybody, and your own code is yours, free to sell or distribute as you wish.

Here is how you, as a proprietary software vendor, can trivially fulfill the LGPL requirements.  There are other options, but this set is basically bulletproof and exactly what the Qt developers want, so if you ever find yourself targeted, you can simply ask the copyright owners (Qt developers) a statement you're not breaking their copyrights; and complying in the following way is likely to make the copyright owners happy to help.

To obtain the sources to the Qt libraries, go to the Qt site, and scroll to the bottom of the page.  Near the bottom right corner, under "Community", pick the "Downloads" link. On that page, in the "Downloads for Open Source users" block, click the "Go open source" link.  For the sources, on the following pages that continue to scare you away from open source to the commercial licenses, you'll finally end up at https://code.qt.io/ (https://code.qt.io/), with build/compile instructions at [url=https://wiki.qt.io/Building_Qt_5_from_Git]https://wiki.qt.io/Building_Qt_5_from_Git (https://wiki.qt.io/Building_Qt_5_from_Git[/URL)[/URL].  These two pages are the ones you need to bookmark, as you'll often return there, and going through the Qt site is a pain.

Or, you can just grab e.g. the entire Qt 5.15 long-term release (latest as of 2021-11-01) via git command-line utilities:
    git clone https://code.qt.io/qt/qt5.git (https://code.qt.io/qt/qt5.git)
    cd qt5
    git checkout 5.15
You'll need Perl, Python, and a C++ compiler; see Building_Qt_5_from_Git (https://wiki.qt.io/Building_Qt_5_from_Git) for details.

The Qt 5.12.11 long-term release binaries (application development Qt libraries and the Qt Creator tool) are available as offline installers (https://www.qt.io/offline-installers) (also grab the sources for them on the same page!), if you don't want or cannot compile the binaries you want/need with your own application.

That's it.

Now, although the Qt libraries needed for application development, Qt Creator (including Qt Designer for UI design), and even PySide2 (if you want Python bindings too) are all LGPL-licensed, you do want to verify the license for the modules you need.  In particular, for Qt 5, you can consult doc.qt.io/qt-5/licensing.html (https://doc.qt.io/qt-5/licensing.html) and doc.qt.io/qt-5/qtmodules.html (https://doc.qt.io/qt-5/qtmodules.html): Qt Essentials (QtCore, QtGui, QtWidgets, QtMultimedia, QtMultimediaWidgets, QtNetwork, QtSql, etc.) are all LGPL-licensed, and so are most add-on modules (Qt3D, QtConcurrent, QtBluetooth, QtGamepad, QtHelp, QtImageFormats, QtLocation, QtOpengl, QtPrintSupport, QtRemoteObjects, QtSerialPort, QtSerialBus (CAN, Modbus), QtSpeech, QtSVG, QtUiTools, QtWebChannel, QtWebEngine, QtWebSockets, QtWebView).  Modules listed under "Add-ons available under Commercial Licenses, or GNU General Public License v3", like QtCharts and so on, are NOT LGPL-licensed, so those you cannot include in your proprietary projects.  Similarly, "Value-add modules" like "Qt for Device Creation" and "Qt for MCUs" require a commercial license, and are NOT LGPL-licensed.

Because Python is licensed under the zero-clause BSD license (https://docs.python.org/3/license.html), it is perfectly legal and allowed, even encouraged by the developers, to create a proprietary application that uses the Python interpreter for a permissively licensed UI (granting users permission to modify the UI and pass those changes on to other users), Qt libraries (dynamically linked, used under the LGPL license), and proprietary C and/or C++ libraries (containing the secret application magick).  While it sounds like a mess, in some cases this has the best of all worlds: keeps the nitty-gritty details that users cannot and should not really mess with and makes the application stand apart from competitors completely proprietary, leverages known existing LGPL libraries for the UI functionality, but lets the end users fix any niggling issues with the UI itself with permission (but obviously no guarantees after modifications have been done!) from the vendor.  This kind of complete control over the UI is extremely powerful, and may open up completely new, customized uses, for institutional/company clients, while still keeping all licensing issues clear.
It's not difficult to achieve, neither legally nor technically, if properly designed from the get go, instead of just aggregating something together first and then checking how to make it legally/safely distributable.
Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 02, 2021, 07:20:36 am
You don't need to convince me: my point was only that the site has quite clear indications of the various license regimens, and does not try to hide the FOSS ones.

I'm 100% aware and convinced that LGPL can be dynamically (or in equivalent ways) integrated in proprietary software, ...

It was a reaction to udok who is under the impression that you are obliged to buy a commercial Qt license if you want
to commercially use Qt in closed source programs.
The reason that I want to rectify this, is because this discussion pops up every now and then. I believe this is partly caused
by the way the Qt Company communicates about this matter.
In the past, the open source edition of Qt was GPL licensed, not LGPL. That was a different situation and perhaps
this is contributing to the confusion as well after they changed it to the LGPL.
Title: Re: Actual C compiler for Windows for free
Post by: udok on November 02, 2021, 11:04:28 am
You don't need to convince me: my point was only that the site has quite clear indications of the various license regimens, and does not try to hide the FOSS ones.

I'm 100% aware and convinced that LGPL can be dynamically (or in equivalent ways) integrated in proprietary software, ...

It was a reaction to udok who is under the impression that you are obliged to buy a commercial Qt license if you want
to commercially use Qt in closed source programs.
The reason that I want to rectify this, is because this discussion pops up every now and then. I believe this is partly caused
by the way the Qt Company communicates about this matter.
In the past, the open source edition of Qt was GPL licensed, not LGPL. That was a different situation and perhaps
this is contributing to the confusion as well after they changed it to the LGPL.

OK, i had this impression from the Qt Website.

But why do they then provide commercial licenses, and not cheap ones for 4500$ / Year / Developer.

Maybe it is because any larger project will have a need to modify the Qt sources?

Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 02, 2021, 12:10:55 pm
But why do they then provide commercial licenses, and not cheap ones for 4500$ / Year / Developer.

Maybe it is because any larger project will have a need to modify the Qt sources?

The commercial edition of Qt adds the following (in respect to the opensource edition):

- extra goodies/modules not avalaible under an opensource license.

- precompiled libs (at least for windows) so no need to recompile everything after an update

- updates for LTS releases, the opensource edition of a certain major version e.g 5.15.x stopped receiving updates when 6.0.0 was released
  People with a commercial license will still receive updates for 5.15.x

- support: your bugreport will be handled faster if you are a paying customer


Title: Re: Actual C compiler for Windows for free
Post by: Jeroen3 on November 02, 2021, 02:48:06 pm
... without any of the gpl problems Qt brings to the table.

What are you talking about? Since when Qt brings gpl problems to the table?
See the comments above.
Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 02, 2021, 04:27:51 pm
... without any of the gpl problems Qt brings to the table.

What are you talking about? Since when Qt brings gpl problems to the table?
See the comments above.

Do you really consider them problems?

Either you pay for a commercial license or you compile the libraries yourself.
Regarding the missing updates, you can find them in newer major release version.
But even with these "problems", I find Qt, with all her defects, still the best cross-platform graphical  toolkit and C++ framework available.
Title: Re: Actual C compiler for Windows for free
Post by: Nominal Animal on November 02, 2021, 08:16:02 pm
If one wants to develop GUI applications in C as opposed to C++, Gtk+ 3 (https://docs.gtk.org/gtk3/) is also LGPL-licensed.  (So are its dependencies GObject (https://gitlab.gnome.org/GNOME/glib/-/blob/main/COPYING) (and glib (https://gitlab.gnome.org/GNOME/glib/)), Cairo (https://www.cairographics.org/), Pango (https://gitlab.gnome.org/GNOME/pango), GDK (https://docs.gtk.org/gdk3/), and Atk (https://docs.gtk.org/atk/).  The https://docs.gtk.org/ (https://docs.gtk.org/gtk3/) pages lists many of their licenses as GPL, but that is not exactly accurate: many are dual-licensed, and some use the older "GNU Library General Public License" form, which is still LGPL, not GPL.)

A minimal example (with compile instructions for Linux and Mac OS; I don't have Windows, so I don't know the exact ones to use there):
Code: [Select]
// SPDX-License-Identifier: CC0-1.0

/* Compile using for example
 *    gcc -Wall -O2 `pkg-config --cflags gtk+-3.0` example.c `pkg-config --libs gtk+-3.0` -o example
*/

#include <gtk/gtk.h>

static void  main_activate(GtkApplication *app, gpointer data)
{
    GtkWidget *win;

    win = gtk_application_window_new(app);
    gtk_window_set_title(GTK_WINDOW(win), "Example");

    gtk_widget_show_all(win);
}

int main(int argc, char *argv[])
{
    GtkApplication *app = gtk_application_new("com.eevblog.Example", G_APPLICATION_FLAGS_NONE);
    g_signal_connect(G_OBJECT(app), "activate", G_CALLBACK(main_activate), NULL);

    int status = g_application_run(G_APPLICATION(app), argc, argv);
    g_object_unref(G_OBJECT(app));

    return status;
}
User interfaces are inherently event-based, so it is natural to write even C code to conform to the event model, rather than requiring an imperative model (as is common for C programs).  So there is a big paradigm difference in the entire approach, and that can feel jarring.  Don't let yourself be put off by it; in this kind of use, the event-based model –– even if it looks odd/funny/funky for a C programmer! –– actually works really, really well.

Note how uppercase macros (GTK_WINDOW(), G_OBJECT(), G_CALLBACK(), G_APPLICATION()) are used to access the variables in specific "roles".  This is how GObject provides (https://docs.gtk.org/gobject/concepts.html#conventions) classes and inheritance in C, while still providing type checks.  Don't consider them "casts", as that can lead to seeing them as unnecessary irritant in the coding style; consider them the way GObject provides multiple roles for each type (especially GtkWidget and its "derivatives"), according to the type hierarchy.

One can use Glade to design the UI, saving it as a .glade file (XML format description of the widgets).  These .glade files can then be realized easily using e.g. gtk_builder_new_from_file() (or gtk_builder_new_from_string()), associating callback names with functions using gtk_builder_add_callback_symbol(), and connecting events with the named callbacks with gtk_builder_connect_signals().  One can even access individual objects described in the .glade, using gtk_builder_get_object().  All of this is themeable using CSS, too.
Title: Re: Actual C compiler for Windows for free
Post by: SiliconWizard on November 02, 2021, 08:42:03 pm
Note that GTK4 has been out for a while.

GTK is not bad at all. (On Windows, the same compile line will work under MSYS2.)
The UI looks a lot less like "native" UI on MacOS and Windows, which is one of the reasons it's frowned upon a bit on those platforms, but it does work reasonably well.

One of the things that often ticks people off are the non-native common dialogs (such as File Open). But there's a way to have them using GTK.
For instance, you have the 'GtkFileChooserNative'.

Title: Re: Actual C compiler for Windows for free
Post by: PlainName on November 04, 2021, 12:42:01 pm
Quote
One of the things that often ticks people off are the non-native common dialogs

Hate that. Prevents stuff like Listary and similar from working, so a massive productivity killer. In fact, sometimes I think about running such an app and then think forward to opening some file well down the directory tree and think, "Sod that, can't be arsed".
Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 04, 2021, 01:27:58 pm
QFileDialog Class:

By default, a platform-native file dialog will be used if the platform has one.

https://doc.qt.io/qt-5/qfiledialog.html (https://doc.qt.io/qt-5/qfiledialog.html)

Apart from the native file chooser dialog, Qt has the best native look and feel when compared with
other cross platform gui toolkits and frameworks.
Title: Re: Actual C compiler for Windows for free
Post by: Nominal Animal on November 05, 2021, 06:28:17 am
Qt has the best native look and feel when compared with other cross platform gui toolkits and frameworks.
No, that would be wxWidgets (https://www.wxwidgets.org/), because it uses native widgets if one exists, and only implements its own when there is no close-enough native one.  See e.g. screenshots for 3.1.5 (https://docs.wxwidgets.org/3.1.5/page_screenshots.html) (latest as of 2021-11-05) for the differences.

It too has a native file selection dialog; so do Qt, GTK+, and FLTK, too, so nothing surprising.  If an application uses a non-native File (Open/Save) dialog, it's the developers fault, and is easily fixable, in basically all applications, by using the proper dialog widget instead.
Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 05, 2021, 07:29:51 am
Let's agree we don't agree  ;D

https://doc.qt.io/qt-5/gallery.html (https://doc.qt.io/qt-5/gallery.html)

(https://doc.qt.io/qt-5/images/windows-style.png)

(https://doc.qt.io/qt-5/images/windows-style2.png)
Title: Re: Actual C compiler for Windows for free
Post by: PlainName on November 05, 2021, 09:56:45 am
Quote
Let's agree we don't agree 

It's nice to have dialogs that follow the native style (except, perhaps, the W10/11 white-on-white borderless annoyance), but looks is just skin deep. The importance of using the actual native dialogs is that the user can replace them with more appropriate ones, or even just inject hints, and every app on the system will use those instead without the programmer needing to modify his product especially. Kind of like the reason for LGPL.

Sorry if you're already aware of that, but you do seem to be banging on about looks. Function matters a lot more.
Title: Re: Actual C compiler for Windows for free
Post by: Karel on November 05, 2021, 11:19:58 am
Sorry if you're already aware of that, but you do seem to be banging on about looks. Function matters a lot more.

Actually, I agree with you. But it seems that a lot of people do care about it (they prefer to use software that have native look & feel).
In other words, you can make (from a functionally point of view) the perfect software, but if users don't like the esthetics, they run away...
Title: Re: Actual C compiler for Windows for free
Post by: Nominal Animal on November 05, 2021, 02:05:19 pm
Let's agree we don't agree  ;D
Or let's agree that you're just wrong, because Qt is not native, it just implements its own widgets in a style that looks like the default theme on each OS (possibly with limited OS theme emulation, I'm not sure), whereas wxWidgets are the native widgets.

What you showed is that by default, Qt provides a preferred look-and-feel on different OSes.  That I could agree with, I guess.

Native widgets start to matter a lot when we start using stuff like screen readers and Braille displays and such.  If the widgets are native, and the OS supports those devices, then everything Just Works.  If the widgets are self-implemented, and only emulate a "native look and feel", it means those devices won't work unless the widget toolkit has special support for the devices.  Usually they don't.

wxWidgets uses the native widgets for all widgets that do have native implementation, so although the default wxWidgets "looks" may be plainer/uglier than typical, the widgets are genuine, and therefore all those screen readers and special displays just work.

This can seem like nitpicking or semantics, but "native" is an important concept here.

We could argue whether "native look and feel" implies native implementation (as I believe it does), or whether it allows emulation (which I do not believe it does, because if it did, then the word "native" would be just a synonym of 'expected' or 'typical').
Title: Re: Actual C compiler for Windows for free
Post by: SiliconWizard on November 05, 2021, 06:29:32 pm
wxWidgets is IMO the closest to looking "native" than most other cross-platform libraries, and the licensing is nicer (again IMO) than Qt's. And as Nominal pointed out, it's not just looking native but actually uses the native common dialogs and widgets when available.

Although looking close to native, Qt is different as Nominal said, and Qt apps are IME very recognizable. I can spot that an app uses Qt in a couple seconds.
Title: Re: Actual C compiler for Windows for free
Post by: 77algernon on November 16, 2021, 10:02:27 am
To OP: You may try Pelles C Compiler, a complete C compiler/IDE/toolkit, in under 15 MBytes =)

http://www.smorgasbordet.com/pellesc/ (http://www.smorgasbordet.com/pellesc/)

Title: Re: Actual C compiler for Windows for free
Post by: rstofer on December 01, 2021, 07:24:41 pm
All C compilers I know of are actually "command line". Even MSVC. Visual Studio just adds an IDE on top of the MS comand line tools, which, BTW, you can also install without Visual Studio IDE.
Likewise, you can use a number of other free IDEs along with GCC. If you like the Visual Studio interface, you can use Visual Studio Code for instance.


Visual Studio can print your source files, Visual Studio Code can not.  I like VS Code, I use it all the time but I really hate having to open the file with another editor just to get a listing.
Title: Re: Actual C compiler for Windows for free
Post by: SiliconWizard on December 01, 2021, 07:42:47 pm
All C compilers I know of are actually "command line". Even MSVC. Visual Studio just adds an IDE on top of the MS comand line tools, which, BTW, you can also install without Visual Studio IDE.
Likewise, you can use a number of other free IDEs along with GCC. If you like the Visual Studio interface, you can use Visual Studio Code for instance.


Visual Studio can print your source files, Visual Studio Code can not.  I like VS Code, I use it all the time but I really hate having to open the file with another editor just to get a listing.

Ah, that's funny. I have VS Codium - mainly installed it to evaluate it, and occasionally to get a GUI frontend for GDB - it has an extension for that - but otherwise, I don't use it. Just checked and you're right, it doesn't support printing. Must be one of the few IDEs I've seen that did not!
Title: Re: Actual C compiler for Windows for free
Post by: cfbsoftware on December 01, 2021, 10:22:15 pm
I like VS Code, I use it all the time but I really hate having to open the file with another editor just to get a listing.
If it's any consolation you are not alone:
https://github.com/Microsoft/vscode/issues/5953

Title: Re: Actual C compiler for Windows for free
Post by: SiliconWizard on December 01, 2021, 11:15:12 pm
I like VS Code, I use it all the time but I really hate having to open the file with another editor just to get a listing.
If it's any consolation you are not alone:
https://github.com/Microsoft/vscode/issues/5953

Wow, it's over 5 years old. And still nothing. Guess MS does not care one bit. Or maybe they want to keep this feature strictly as a differentiator for Visual Studio.

Note that VS Codium does not have printing either. But as far as I've understood, VS Codium is not really a fork, so it doesn't add any feature to VS Code. It's mainly a *build* that just strips off the nasty stuff (telemetry...) but otherwise uses the same code base.
Title: Re: Actual C compiler for Windows for free
Post by: PlainName on December 01, 2021, 11:23:49 pm
Quote
It's mainly a *build* that just strips off the nasty stuff (telemetry...)

Thought that would be worth a look, but on Windows it uses Chocolaty or Scoop for install, both of which make Microsoft look sensible.
Title: Re: Actual C compiler for Windows for free
Post by: SiliconWizard on December 01, 2021, 11:42:51 pm
Quote
It's mainly a *build* that just strips off the nasty stuff (telemetry...)

Thought that would be worth a look, but on Windows it uses Chocolaty or Scoop for install, both of which make Microsoft look sensible.

It doesn't need any install. You can download the binaries directly and run it without installation. That's what I do.

Just pick the .zip file of your choice here:  https://github.com/VSCodium/vscodium/releases (latest is VSCodium-win32-x64-1.62.3.zip for Windows/x64)

Title: Re: Actual C compiler for Windows for free
Post by: PlainName on December 02, 2021, 12:27:06 am
Quote
It doesn't need any install.

Blinding, thanks  :-+

Dunno how I missed that. Probably too dazzled by the  pretty web page  :palm:
Title: Re: Actual C compiler for Windows for free
Post by: SiliconWizard on December 02, 2021, 01:15:23 am
Quote
It doesn't need any install.

Blinding, thanks  :-+

Dunno how I missed that. Probably too dazzled by the  pretty web page  :palm:

Yes, the web site is not the best. But it explains the difference with VS Code, including license differences...

Note that (probably also for licensing reasons), some VS Code extensions are not accessible in VS Codium. But you should find equivalent extensions that will work with it. Was the case for the extension supporting GDB debugging.
Title: Re: Actual C compiler for Windows for free
Post by: rpiloverbd on December 13, 2021, 01:26:57 pm
I use visual studio
Title: Re: Actual C compiler for Windows for free
Post by: PlainName on December 13, 2021, 03:17:49 pm
The thing Visual Studio (even the proper full fat one) doesn't have, which I find so useful it's the other primary feature all my code editors since Brief have had, is the preview window. This isn't the VS preview window that merely shows a file preview but a preview of whatever your cursor happens to be on. If it's a function call it will show the function definition. A variable, the declaration. A struct member, the structure declaration. Etc. Even if you're not using it to actually preview, it is so quick that you get used to it signalling that the thing you just typed actually exists. IOW, if you type a name and the preview window doesn't show the declaration, you've made a typo.

The attached screeny gives a flavour. It's part of ESP32 example code, so the highlighted #define is actually defined somewhere within the 1GB of ESP-IDF source. Nevertheless, as soon as I click on it the preview window shows the definition - it is very rare that it doesn't update within a second. (Of course, this is in addition to the usual code hints and stuff.
Title: Re: Actual C compiler for Windows for free
Post by: Bassman59 on December 13, 2021, 09:00:10 pm
All C compilers I know of are actually "command line". Even MSVC. Visual Studio just adds an IDE on top of the MS comand line tools, which, BTW, you can also install without Visual Studio IDE.
Likewise, you can use a number of other free IDEs along with GCC. If you like the Visual Studio interface, you can use Visual Studio Code for instance.


Visual Studio can print your source files, Visual Studio Code can not.  I like VS Code, I use it all the time but I really hate having to open the file with another editor just to get a listing.

Ah, that's funny. I have VS Codium - mainly installed it to evaluate it, and occasionally to get a GUI frontend for GDB - it has an extension for that - but otherwise, I don't use it. Just checked and you're right, it doesn't support printing. Must be one of the few IDEs I've seen that did not!

The Atom developers also don't think that printing is important. See here (https://github.com/atom/atom/discussions/22303), for example.
Title: Re: Actual C compiler for Windows for free
Post by: newbrain on December 14, 2021, 10:36:30 am
I was trying to remember the very last time I felt the need to print code.
It finally came to me it was 1993, with some Fortran running on a MicroVAX!

I did not even notice VS Code was missing a print function, and I'm not able to tell whether e.g. Eclipse or Visual Studio do include one...