As a very Apple addicted person I always wanted to learn developing iOS and Mac apps. When I got my first iPod touch last december I started to love it's operating system called iOS. And I was amazed by the iMacs and Macbook Pros in Apple stores but I couldn't buy one yet. You know, money matters :( Even though I don't have a Mac to do iOS developing I wanted to do those stuff so badly. Objective C is used for that and I wanted to learn it so badly. But I couldn't as I had my high school exams. But finally last night i figured it out :D So if you are a person just like me, who have endless willings to learn iOS and Mac programming without a mac this is the place :)
Objective C is used to make iOS and Mac apps. This language is derived from C language and this is a mid level object oriented programming language which was developed by Apple Inc. Prior experience with C++ or C will be a extra advantage. But it's not necessary. Objective C is currently compiled with xCode software in Mac Os X. But don't worry you can do it as this way too.... Okay let's get to work then.
You should have installed Linux ubuntu for this. I tried this via linux Ubuntu 11.04 - Natty Narwhal. But this should work with other versions too. Please kind enough to inform me if there's any problem with older versions. Well this guide consist of two steps. 1) Installing 2) Compiling ............. Let's do this :) Remember to enter your computer password whenever terminal requies it :D
Installing GNUSTEP in Ubuntu and getting it worked :)
1) Open the terminal. And enter below commands one by one. You should have a working internet connection dude :)
2) sudo apt-get -y install build-essential
3) sudo apt-get -y install gnustep
4) sudo apt-get install gobjc
5) sudo apt-get install gnustep-make
6) sudo apt-get install libgnustep-base-dev
Okay It's done.... Now you have successfully installed GNUSTEP in your computer. Well I know it took some long time to download it as it cost about 200MB :P But be happy you can run Objective C ! :D
Compiling a simple program with GNUSTEP !
1) Open the terminal.
2) Type gedit name.m
Info - You should use the .m extension to compile Objective C programmes. If you use .txt it will be frikkin useless. And use your desired name in the "name" field. And use it by changing everywhere hereafter in my codes.
3) After you hit ENTER key after typing last code a Gedit text editor will be opened. As "Home" directory is the default in terminal this will be saved in "Home" directory...
4) Then type this simple sample code in that text editor. And then hit the " Save " button and close it ;)
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Objective C is great");
[pool drain];
return 0;
}
5) Now come back to the terminal and type- . /usr/share/GNUstep/Makefiles/GNUstep.sh
info - You should enter this code everytime you start a new terminal window. I know this is a disadvantage. But it does the job ;)
6) gcc `gnustep-config --objc-flags` -lgnustep-base name.m -o name
info - Change the "name" field to the name of gedit file you created at first step!
7) ./name
info - After hitting enter button you will get a phrase in the terminal saying " Objective C is great :D "
Congratulations dude,,,, You have just made your first effort a success in Objective C :)
AND FOR LEARNING OBJECTIVE C I recommend you the book " PROGRAMMIN IN OBJECTIVE C 2.0 by Stephen G. Kochan " .. I downloaded a copy from thepiratebay.org But I don't remember the link for that torrent. If you couldn't find any book and need a one so badly, just ask me and I'll upload it. :)
Any questions??? Feel free to ask ;)
Dude your explanation of the code is wrong it displays Hello world acc. to your code
Its of great help though thanks for sharing
yeah I was so busy and just copy pasted the code from my tutorial and added a picture from my first program. forgot to edit the code. Thanks a lot for showing it.. I made it now :)
Hey, I like your thoughts but you should check out the design at my site and let me know what you think!nyc one keep it up :D,Thank You so much for the tutorial.
I was just wondering if there was any way that this could be made into posts. Thank you for any help
dedicated hosting reviews
Hi,
my compilation goes in error:
can you help me?
wadev@WADev01:~/Objective-C/HelloWorld$ gcc `gnustep-config --objc-flags` -lgnustep-base HelloWorld.m
/tmp/cc03Jef3.o: In function `main':
/home/wadev/Objective-C/HelloWorld/HelloWorld.m:5: undefined reference to `objc_get_class'
/home/wadev/Objective-C/HelloWorld/HelloWorld.m:5: undefined reference to `objc_msg_lookup'
/home/wadev/Objective-C/HelloWorld/HelloWorld.m:5: undefined reference to `objc_msg_lookup'
/home/wadev/Objective-C/HelloWorld/HelloWorld.m:7: undefined reference to `NSLog'
/home/wadev/Objective-C/HelloWorld/HelloWorld.m:8: undefined reference to `objc_msg_lookup'
/tmp/cc03Jef3.o: In function `__objc_gnu_init':
/home/wadev/Objective-C/HelloWorld/HelloWorld.m:10: undefined reference to `__objc_exec_class'
/tmp/cc03Jef3.o:(.data.rel+0x0): undefined reference to `__objc_class_name_NSConstantString'
/tmp/cc03Jef3.o:(.data.rel+0x8): undefined reference to `__objc_class_name_NSAutoreleasePool'
collect2: ld returned 1 exit status
wadev@WADev01:~/Objective-C/HelloWorld$
Are you using Linux kernal 3.0 or higher? Because ther are some library changings in kernal 3.0.. this installation only works fine under kernal 3.. no good options yet for over 3.0 kernal...
to check your kerna;, open the terminal and type
uname -a
yes my kernel is 3.0
Linux 3.0.0-14-generic #23-Ubuntu
There are some fix for kernel 3.0?
No luck yet :(
Does anyone know if there has been an update to work with vernon 3 kernel yet?
Thanks
Regarding Salvatore's comment above, it looks like it can be compiled via a command like:
gcc `gnustep-config --objc-flags` source_name.m -o program_name -lobjc -lgnustep-base
So the only change here is to add -lobjc. (This btw came up in a comment on somebody else's blog who was going about it in a similar way.)
I've test this, and it works, on ubuntu 12.04.
Of course in general you'd want to put it in a build script of some sort, and the gnustep project has an elaborate makefile system set up to do it.
So that's probably a better approach, although i realize i'm being pretty vague (because, i'm pretty ignorant!!).
Thanks Dan! Very helpful: worked for me.
Thanks Dan! After a lot of googling around...this solution worked for me on ubuntu 11.10 with Linux Kernel 3.0.0.20-generic
How can i debug some app created using this way, in linux?; thanks
Very very thanks. Also Dan thank you...
Its like you read my thoughts! You seem to know so much approximately this, like you wrote
the guide in it or something. I feel that you just could do with some % to force the message house a bit, but other than that, this is fantastic blog. An excellent read. I will certainly be back.
Also visit my web page - fred marvin associates
Appreciate this post. Will try it out.
my web-site: remedy for snoring
On compiling in UBUNTU-12.04 i got an below error.
gcc `gnustep-config --objc-flags` helloworld.m -o helloworld -lobjc-lgnutstep-base
helloworld.m:1:34: fatal error: Foundation/Foundation.h: No such file or directory
compilation terminated.
can any one help me out on this