Technology with opinion

Sunday, November 14, 2010

Getting Started: Programming Objective C on Windows

Why Learn Objective C?

Objective C has made C programming cool again and it's making a comeback. I've been interested in learning Objective C for many reasons: iPhone Development, statically compiled language with dynamic features and to brush up on my C programming.

It's been many years since I've done any C or C++ programming. If the C language gave birth to C++ then Objective C would be its sibling. Current versions of Objective C is basically the C language sandwiched with Smalltalk sprinkled with the goodness of dynamic programming and syntactic sugar.

Many people struggle writting iPhone applications in my opinion because they neglect the fact that Objective C is a first class language and like C# (.Net) or Java require time and patience to learn it first before learning the frameworks and paradigms. This would be akin to trying to learn C#, HTML & JQuery for the first time on an ASP.Net MVC project.

I will be treating Objective C like a first class language and I will be learning it on Windows first because I want to focus on the language first and not the frameworks (such as Cocoa). My first goal is to get a running development environment on Windows for Objective C programming, write a simple "Hello World" app and compile it using both gcc and a make file.

Setting up Development Environment on Windows from scratch

GNUstep is the cross platform, free & open source version of Objective C. First download and install GNUstep Core, GNUstep System, GNUstep Development Environment and your favorite text editor such as Notepad++. After installing this a group will be added to your Start menu in Windows named GNUstep, beneath it is a shortcut to a "Shell". Once open, you will be in a full command shell (BASH) you will be able to compile Objective C code files using make or gcc but we will first have to create a class file

The gcc that comes with GNUstep can compile C or Objective C apps. We will first start with a Hello World app that uses C header files and then tweak it to use Objective C header files to make sure everything is lined up and configured correctly in your development environment. Create a file called main.m and paste the following into it.

Within the GNUstep Shell navigate to the same folder and compile it (within GNUstep shell C:\YourProject would be /c/YourProject) by typing the following:

Then test the output in shell by running the app and make sure the output is correct before continuing.

Next we will modify the helloworld source to use Objective C library and make a build file for it so that it will compile. First, update main.m to below:

GNUstep provides makefiles which include the references to the libraries and folders that you will need. Create a file named GNUmakefile in our project directory and put the following into it.

Now to build it is simple, just type the following into our shell.

Some warnings should appear from the compiler but it should compile. Run the output which should be in a folder named obj and verify the output. There we go, our first Objective C app. For more info on make files within GNUstep see the reference manual.

16 comments:

Konstantina said...
This comment has been removed by the author.
Konstantina said...
This comment has been removed by the author.
Konstantina said...

Thanks a lot for the manual, it is really helpful. The truth is that everything works as it is written until the time that you execute make on the shell. I receive the following error
"make: no targets specified and no makefile found. stop"
Any idea, why is this happening?

Unknown said...

@Konstantina did you name the file GNUmakefile?

Unknown said...

Hey guys, I found the solution for “No target specified and no make file found” error.
Please just save those "make file" without extention, just name it "GNUmakefile" (without extension).

Priya Kannan said...

That was a great message in my carrier, and It's wonderful commands like mind relaxes with understand words of knowledge by information's.
C- C++ Training in Chennai

Prashant Baghel said...

Hotstar Cookies Free Premium Account (100% Working)
Ae Dil Hai Mushkil Full Movie Download In 720p 500mb - Filmyhit, Dailymotion, Watch Online
फेसबुक आईडी कैसे बनाते है
jio keypad phone hard reset
free dish tv channels setting
what is magicpin

traininginstitute said...

This is really very nice post you shared, i like the post, thanks for sharing..
data science training

Block said...

It’s always so sweet and also full of a lot of fun for me personally and
my office colleagues to search your blog a minimum of thrice in a
week to see the new guidance you have got.
best software testing training institute in Chennai
javascript course in Chennai
mysql online course in Chennai

data science said...

I am another customer of this site so here I saw various articles and posts posted by this site,I curious more energy for some of them trust you will give more information further.

PMP Training in Malaysia said...

360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.

Courses said...
This comment has been removed by the author.
Unknown said...

I really enjoy reading and also appreciate your work. data analytics course in mysore

deekshitha said...

This is amazing content, and I would like to read more inspirational and informative posts like this. Becoming Alteryx certified professional by enrolling in a course program given by 360DigiTMG will help you learn how to automate work and keep yourself updated with the latest data analytics and data science trends.full stack developer course

Edward said...

ok

Edward said...


Interesting C programming course.



___________________________________
I am a machine learning engineer