The best platform for developing Objective‑C is Mac OS. But Objective‑C programs can also be compiled and run on Windows or Linux by using GNUstep and an Objective‑C compiler. GNUstep is an object-oriented library that provides the programmer with a range of libraries and utilities for building Objective‑C applications. GNUstep is generally compatible with recent developments of the MacOS (Cocoa) API.
Objective‑C development environments are not readily available on Windows or Linux. CodeBlocks can be used if additional options are set and an Objective-C compiler is used.. The Example program can also be compiled by using a text editor with compile capability such as SciTE. Or it may be compiled from the command line. Or scripts can be written using Python, Batch, Bash, or other scripting languages. Compile options for each platform are included in the following descriptions.
Objective‑C on Windows requires the GNUstep packages and the MinGW compiler. Installing MinGW is optional since it is included with GNUstep. If MinGW is installed separately be sure to include the Objective‑C compiler package. The GNUstep installation packages are available at the GNUstep Windows Installer page. For development you will need GNUstep MSYS, GNUstep Core, and GNUstep Devel. GNUstep Cairo is optional. For now, it is best to use the "stable" packages.
GNUstep MSYS is an application of the MinGW MSYS system. It consists of a console shell and supporting programs that are used to simulate a Linux environment. It can build programs that use the Linux Autoconf system and run shell scripts. There are limits, of course, to what can be done.
GNUstep application packages are an optional install from the installer web page. Since they are Mac applications the menu display will be separate from the application window. This can be changed by running the "System Preferences" program and selecting Themes > WinUXThem. Most applications will then display a window with a menu at the top as in Windows. GWorkspace is a fairly large application that includes source code. It can be used as a reference for Objective‑C coding. The GNUstep MSYS shell must be used for the compile since Autoconf is used. There are INSTALL instructions in the top-level GWorkspace directory.
To compile the Artistic Style Example program the GNUstep development packages must be installed. Artistic Style should be compiled with MinGW as a DLL or static library for linking with the example. MSYS and Autoconf are NOT used for the compile. You can use either the MinGW compiler that comes with MSYS or a separate installation. MinGW can link directly against the DLL, a library file is not necessary (but can be used if you want). In the following options the "-L.\" is for linking with a DLL in the same directory as the example. If the library is in another location the compile option must be changed to reflect this. The option -Wl,-enable-stdcall-fixup disables a warning message for 32‑bit compiles. Options for compiling the Example program using the GNUstep compiler are:
$(GNUstepPath)\bin\gcc Example.m -o Example
-I$(GNUstepPath)\GNUstep\System\Library\Headers -fconstant-string-class=NSConstantString -D_NATIVE_OBJC_EXCEPTIONS
-Os -Wall -Wextra -Wl,-enable-stdcall-fixup
-L$(GNUstepPath)\GNUstep\System\Library\Libraries -lgnustep-base -lobjc
-L.\ -lAStyle
The compiled Example will run as any other console program. If Artistic Style is linked as a DLL it must be in the same directory as the example, or in another system path directory.
Objective‑C on Linux requires the GNUstep packages and the GCC or Clang compiler. On many systems GNUstep will be available as a packaged install. For a typical installation the gobjc, gobjc++, gnustep, and gnustep-core-devel packages are needed. The gobjc packages are the Objective‑C compilers for GCC. If packages are not available they can be compiled with source code available at the GNUstep website.
With Gnome systems, GNUstep programs will be added to the system menu. Applications installed are System Preferences, Gorm, Project Center, GWorkspace, and a few others. Since they are Mac applications the application menu display is separate from the application window. This can NOT be changed with "System Preferences" as on Windows. GWorkspace is a fairly large application that includes source code if downloaded from the website. It can be used as a reference for Objective‑C coding. There are INSTALL instructions in the top-level GWorkspace directory.
To compile the Artistic Style Example program the GNUstep development packages must be installed. Artistic Style should be compiled as a shared or static library for linking with the example. In the following options the "-L./" and "-Wl,-rpath,./" are for linking and executing with a shared library in the same directory as the example. If the library is in another location the compile options must be changed to reflect this. On some installations GNUstep may install to different directories. Options for compiling the Example program are:
gcc Example.m -o Example
-I/usr/include/GNUstep -fconstant-string-class=NSConstantString -D_NATIVE_OBJC_EXCEPTIONS
-Os -Wall -Wextra
-L/usr/lib/GNUstep -lgnustep-base -lobjc
-L./ -lastyle
-Wl,-rpath,./
The compiled Example will run as any other console program. If Artistic Style is linked as a shared library it must be in the same directory as the example when compiled with the above options.