I have been reading about the minGW project and I am a bit confused about a specific part of it. If you look at http://www.mingw.org/wiki/MinGW, the "Packages included with minGW" section mentions a w32api package. What is that?
Since the project was able to produce a Windows port of gcc, wouldn't you just have to link the Windows c library instead of glibc and have it work?
In the same document it explains:
Header files and import libraries for the Microsoft Windows operating system
But doesn't Windows ALREADY provide header files and libraries for itself? Is the libc that minGW uses different from msvrct?
But doesn't Windows ALREADY provide header files and libraries for itself?
No.
Microsoft provides a Windows SDK, which includes C header files, and import libraries for use in Visual Studio only. Other compiler vendors ship those headers (making any tweaks they may require to compile) and import libraries that are appropriate for use in their own compilers.
That is what the w32api package is for minGW. The files needed to compile Windows code in minGW's environment.
Related
total noob here.
There are a few a few C libraries I would like to use, like unistd.h and sys/time.h, in a Windows machine. I have found many threads discussing is it simply not possible without using alternative packages. But I wonder does the Windows Subsystem for Linux come with those libraries? If so, how do I configure Visual Studio Code work with WSL?
But I wonder does the Windows Subsystem for Linux come with those
libraries?
Yes compiler in WSL will contain these headers.
If so, how do I configure Visual Studio Code work with WSL?
You need to enable WSL in Windows features, install linux distro you like via Microsoft Store, install "Remote - WSL" extension in VS Code.
More information can be found here: https://code.visualstudio.com/docs/remote/wsl
Keep in mind though, that applications that you will compile in this setup will be linux applications. They will only be able to operate under linux or WSL.
There is no way you can compile applications using these libs for Windows. These libs are platform depended.
I recently downloaded Visual Studio Code to begin learning the C programming language. I installed the program as well as the C extension. However, when I tried to create the "Hello, World!" program, it would not run, and in the Problems menu it did not recognize the stdio.h header file, saying that I need to update my includePath. I have not been able to find any stdio.h file on my computer to link to. Do I need to download the C library files (even though I have read they should be included with the compiler), and if so, where can I find them? Or is there another solution? Thanks, and sorry if this is a stupid question, I am new to this.
I think you might be confusing VS Code with the VS IDE.
VS Code is a source editor only; that is to say that it's basically just a glorified text editor. It has the ability to load extensions and open a shell to compile the code, and there are a few extensions that let you debug the code itself, but they can be tricky to get setup and installed to work well with C/C++ code. VS Code does not have a compiler/assembler/linker nor the requisite headers or SDK's as that is up to you (the user) to install and then point to those in your settings file.
The Visual Studio IDE, on the other hand, is a complete integrated development environment that also includes the system headers and SDK's for Windows, as well as the binaries to properly compile, link and assemble your code into a binary for a Windows system (cross platform is possible as well). The Visual Studio IDE comes in many different flavors with the latest being VS 2017.
If you wish to stick with VS Code, you'll need to grab a compiler and the appropriate header files for the system you're targeting. If you wish to just stick with Windows for now, you can grab the Windows 7 SDK here or the Windows 10 SDK here .. you could even grab both and just reference the one you wish when you want. Note that the Windows 7 SDK includes the Microsoft C/C++ compiler, alternatively you can download the MSVC compiler from their Build Tools site.
There's also Cygwin in which you can use the GNU compiler, and of course Clang, which can be referenced in both VS Code and the VS IDE.
I hope that can help.
I have a Linux-specific source file that includes a few Linux-specific headers, such as dirent.h. I added this source file to my cross-platform (Linux) project in VS2017, but IntelliSense is throwing flags at me that it cannot find these headers.
Is there a specific directory I should be adding to my include list to find them?
If not, how do I handle platform specific headers in a cross-platform project?
Edit for clarification: I'm specifically trying to assume that it is a Linux header, but I am editing on a Windows machine using the cross-platform VS feature.
I found the answer in the MS blogs. The short answer is that the includes are never present, and need to be copied over from the Linux machine into a local folder to add.
https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/#includes
So the latest version of TCC supposedly has some of the features of C99 implemented, however, I have found that it does not include C99's Math library.
Is there a way I can get it to use more of C99's libraries on windows? I googled around and found some advice mostly pertaining to Linux, but for this project I need to get it to work on windows.
EDIT: This is not a question about getting 'any' compiler on the windows platform. I realize that there are many compilers. I specifically need to get TCC to do this.
EDIT: The project needs to do some on the fly C compilation, and we would like to see if we can use TCC for this feature.
The documentation for Windows indicates that the TCC installation on Windows deploys a minimal set of MinGW headers. Copy the headers you need from MinGW into the tcc/include/winapi (i.e. place them under tcc-build-root/win32/include/winapi) and then build tcc with build-tcc.bat.
Try Visual Studio Express Edition for 'C'.It's free and IDE is more developed than TCC
What is the most commonly used (simplest) C / C++ compiler used on Windows when using the NetBeans IDE (6.7)?
I want to write (mostly) simple C programs. I have Cygwin installed but for some reason NetBeans doesn't like it. I'm getting a error from it and before I try to figure this out, I thought I should find and (if needed) configure a more popular one.
makeinfo: --fill-column arg must be numeric, not
nbproject/Makefile-Debug.mk'.
Trymakeinfo --help' for more information.
I believe I'm getting this error because I don't have make installed.
I've also found this stackoverflow post (C/C++ Compiler for windows) but and that suggests to use MinGW compiler tools.
What is the difference between MinGW and Cygwin? Which is better or preferred? and are there any other options?
The difference between Cygwin and MinGW is the the Cygwin tools (and the executables generated) rely on the cygwin DLL that provides a POSIX-like layer for the application.
MinGW are native Win32 tools (in that they do not require the presence of the Cygwin DLL) that produce native Win32 executables that do not need the Cygwin DLL.
My personal preference is for MinGW, but if you're going to be building programs that have a Unix heritage, the Cygwin toolset will likely help you build the program to run on Windows more than the MinGW toolset will.
I'm not sure what the licensing implications of linking to the Cygwin DLL are (I forget if it's GPL or LGPL).
Here is a good post I just found for getting cygwin and Netbeans working together.
Configuring cygwin with netbeans in Windows
And just so you know, cygwin and MinGW are by far the two most popular open source solutions for C/C++ on windows. Other popular compilers exist, but are not free (Borland C++, Microsoft Visual C++, etc)