OS X Xcode/clang to build Windows executables? - c

Is it possible to build classic Windows executables (Windows 8 support is not required) from C source code using the latest Xcode/clang compilers on a current Mac (e.g. without using gcc or a VM to run Linux or Windows)?

After thinking why the hell would you want to do this?, I just surprised myself and found what may actually be a solution!
The Cocotron
The Cocotron is an open source project which aims to implement a cross-platform Objective-C API similar to that described by Apple Inc.'s Cocoa documentation. This includes the AppKit, Foundation, Objective-C runtime and support APIs such as CoreGraphics and CoreFoundation.
Also see this blog post: Win-win with Cocotron and Xcode 4.3 — code for Mac, build for Windows (Part 1)
Although the last entry on the Cocotron site was from 2010 - so it may or may not still be alive

Related

Can I still work on C Project with OpenGL using gcc under macOS Mojave?

I read that macOS Mojave does not support OpenGL anymore. I have to make a small C project for University with OpenGL using gcc.
Does macOS Mojave not supporting OpenGL anymore mean that I wont be able to compile such files anymore under macOS? Or will it still be possible?
Or do I have to install Linux / Windows for that?
OpenGL does still work, and can be compiled against, under Mojave (i.e. the OpenGL.framework is still in System/Library/Frameworks, and you can select the framework in in Xcode for development).
However, Apple announced that it is deprecated from now on. This means that it might be removed in any later version and limited development will go into it (i.e. don't expect bug fixes any more).

Linux-native C libraries: How to configure Visual Studio Code to work with them on Windows?

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.

Dos.h + Pc.h in C and Windows Vista

I am currently looking to work with Mesa3D to create a software rendered graphic application with OpenGL.
I am looking a a few tutorials right now on how to use it, and many are written with DOS or older versions of Windows in mind. As I run Vista I don't seem to have the right files I need.
The Mesa3D tutorial I am using uses outportb() and a few other commands which I can't seem to get working. After looking around I have found you require the 2 include files:
dos.h
pc.h
These do not seem to be found within the Window's SDK that comes with Visual Studio 2010 (Express) or even the older version of 2005 (Professional) which I currently have.
They seem to be found with the DJGPP compiler that only works under DOS and is not supported in Vista, even with compatability mode. Running DosBox still does not get this to work.
I am wondering - is there perhaps a new functions replacing outportb or can I use these DJGPP files with my C/C++ complier with VS or PellesC (which I find better for C-only programs)?
In addition the conio.h include file I have with both VS and PellesC doesn't have the textmode() function, but the DJGPP version does.
If anyone could help either getting DJGPP working on Vista or allowing me to use the dos,pc and conio.h files from DJGPP with either VS or PellesC that'd be a great help!
Port-manipulating functions will simply not work in Win32 programs. Either use Win32 APIs to do I/O (rendering included) or stick to DOS and run your program in DOS or whatever DOS emulator you can find that works. Vista and later Windows won't run most DOS programs directly as the support for DOS is either severely reduced or removed altogether (e.g. in 64-bit Windows).
The low-level hardware access that functions like outportb give you is not available to programs in modern Windows environments. Such capabilities are reserved for specially-trusted code (OS internals and drivers). You need to go through higher-level APIs or drivers in order to access the same functionality.
The Mesa3D website has a readme for Windows developers that has information about what you need to install and configure. It also references some official demo code that you can use as the basis for your project. The Mesa3D website also has a repository full of demo programs that will probably serve as better examples than the out-of-date tutorials that you mentioned.
Do not use 16bit compilers on vista and higher.. instead use DOSBOX to run your programs.

which development software should be used for VLC on mac?

i want to do some modification and development for VLC. i download its source code, vlc-1.1.5. and it is written by C. so usually which development environment should i use, xcode or some others?
thx...
I thought VLC was developed in Qt. Do you see the class names starting with Q? In case it is developed in Qt, Qt Creator or KDevelop would be a good choice of development environment.
The VideoLAN folks provide a wiki page with information about compiling their source on multiple platforms. The page relevant to OS X is here: http://wiki.videolan.org/OSXCompile
Compiling VLC media player on Mac OS X is different from normal linux compiling and OS X compiling. We do not use Xcode, but a simple ./configure and then make isn't enough either.
The page provides a step-by-step guide to setting up a machine running either OS X 10.5 or 10.6.
Any editor of choice should suffice. Looking at the code, it seems that VLC uses Unix-style building (autotools, make, etc). On Win32, it uses MinGW, so plain old gcc and make is probably used on OSX as well.

Good IDE/compiler for simple C dll's

I'm trying to disassemble a C/C++ DLL, and have made some progress, but I would like to create my own C DLL with the same function the original exports, and compare disassemblies.
Visual Studio adds to much crap, and when I remove the crap and build my project, the expected DLL is missing.
I need a lightweight, preferably IDE, tool to edit and build very simple C libraries.
Take a look at Code::Blocks
I need a lightweight, preferably IDE, tool to edit and build very simple C libraries.
I have found that one of the best ways to do integrated C-only Win32 development is using the freely available Lcc Win32 Compiler which comes with a built-in IDE, including resource editor.
In fact, it is really very lightweight and can be run from a USB stick with some manual tweaking.
It's indeed a really small download of just 6 mb and you can even download an optional Win32 API help file which is really useful while doing development.
The compiler also comes with a C tutorial, as well as good user documentation detailing how to use the integrated Win32 resource editor "wedit", there's also an advanced manual about more complex development tasks.
Dev-C++ is a nice and fast IDE which works well with MingW.
But it's all been asked and answered before ...
MinGW adds its own crap. Install your VC express properly and save yourself a lifetime of trouble.
Btw, you don't need to use Visual Studio for its compiler or vice versa. The oddity of missing a build dll is probably because you are not looking at the right path.
If you are building C DLLs you really would benefit from its command line toolset and utilities, sdks, easy config etc. MS lock-in proprietary extensions are widely used (in context of you trying to emulate another dll), and last thing you need is chasing cross compiler issues..
GCC + any text editor such as VIM is a very light alternative.
For Windows Development, all you need is inside MinGW
Edit: If you are in dire need of an IDE you can also use the MinGW tools from Eclipse with the CDT plugin. Although it adds weight to the solution because of the installation of Eclipse, this is what I really use to build my small DLLs (JNI wrappers in my case).
You can setup your small and direct makefiles or let Eclipse do it automatically for you and concentrate only on the source files (*.h, *.c).
The best part of using this approach instead other IDE is that you do not need Eclipse to further build the DLL, since the underlying project files generated are standard ones directly usable by integrated dev inside MinGW (or any Unix distro) such as make, configure, automake, and so on.
I'll second the vote for Code::Blocks, it's what I use (despite having VS 2008 installed as well). It is very simple and lightweight but has basically all the features you'd expect out of an IDE. It comes with several predefined project templates for all kinds of C and C++ development, including templates for DLLs.
Download the version that includes MinGW and you get a complete lightweight IDE ready to start compiling. You can also easily configure it to use the Visual Studio compiler instead of gcc if you prefer.
try Open Watcom. A cross-platform product, well-supported by the community, lets you develop in DOS, Windows, OS/2 etc for a lot of platforms. Version 1.8 was released recently. Has a light-weight IDE indeed

Resources