
15 Most Recent [RSS]
More...
|
Playing with Objective C on Debian
I felt like playing with Linux a bit, so I went and installed Debian on a partition. Apart from a few failed attempts to install it on an external drive (something which works fine with MacOS X, so I was spoiled) and a bit of confusion when it asked me for my drive name (how would I know a cryptic character combination like hdb4? And I selected that drive in your UI before, can't you let me use that same selector again?), it went pretty smooth. Once having installed Debian, I wanted to play a little with GCC on there. However, by default, like a nice desktop OS, the developer tools weren't installed, so I opened a root Terminal window and typed in apt-get install gcc cpp binutils libc6-dev make gobjc Most of the items after install are what any web site on Debian will tell you is needed to use GCC: GCC itself, the C preprocessor, binutils (mainly for the ld linker and the as assembler), the C standard library and the make command line tool for making it easier to build complex build commands (think a command line version of Xcode project files).But the last one, gobjc, installs the GNU Objective-C runtime and compiler. This is only the runtime with the old Object base class, i.e. without -retain and -release. You get Object by including objc/Object.h. You'll also want to add a -lobjc option to your GCC command line, or you'll get lots of error message about missing objc_msgSend() etc. These headers get installed in /usr/lib/gxx/x86_64-linux-gnu/4.3/include (or whatever GCC version you installed, and whatever architecture your Mac has), in case you want to find out how Object looks.. To get a more familiar Foundation "framework", I built and installed libNuFound, a Foundation clone that works alongside the GNU runtime, written for use with the Nu programming language. The basic installation is detailed on their github page, essentially the traditional ./configuremakemake install dance, except that you need to copy the headers yourself:cp -r Foundation /usr/local/include Then, if you wanted to build a Foundation tool whose source code is in a file main.m, what you need to do is:export LD_RUN_PATH="$LD_RUN_PATH:/usr/local/lib"gcc main.m -lobjc -lNuFound -lm -ldl -fconstant-strings-class=NSConstantString The thing with LD_RUN_PATH is needed so the linker can write the full path of the library into the executable. Otherwise you get an error like error while loading shared libraries: libNuFound.so.0: cannot open shared object file:No such file or directory There are other options to solve this problem that make will tell you about when you build/install libNuFound. The -lobjc option pulls in the GNU ObjC library, -lNuFound grabs the Foundation library we just built, and -lm and -ldl grabs the standard C math library and a code-loading library needed by libNuFound. The last parameter tells the ObjC compiler that Objective C string constants like @"Cool" should generate NSConstantString objects, not the old String flavor.But hey, now I have a Debian installation that runs Objective-C code. Neat :-) No UI libraries, though. Update: Note that you will probably want to install this on 32-bit CPU with a 32-bit Debian. With some investigation, Mr. Mo and me found that libNuFound seems to have a few bugs on 64-bit CPUs at the moment. Ahruman writes: GNUstep base is fine for Foundation-level stuff, as long as you don’t mind it dropping .GNUstep directories and such around the place. I would suggest not even looking at the UI layer, though. It’s just depressing.
|
Leon writes: I found GNUstep really nice (at least for a GNU oss project). Though Obj-C on linux (any other OS than OS X imho) is sadly a mess. So I revert to using ruby on those OSes if I have to do anything on them - which is really sad as I love Obj-C ;)
|
Andy writes: Very interesting!
Makes me wonder if I could use this on my Debian based (Ubuntu Hardy) webserver?
|
Uli Kusterer replies: ★ Ben, I thought the Cocotron was mainly aimed at cross-development: Create your software on a Mac, run it on Windows. Also, although I saw mention of its Linux support, I was unable to actually find anything useful to download and install.
|
Uli Kusterer replies: ★ Ahruman, Leon: I did check out GNUstep, and I think for some uses it's good (it's definitely the Cocoa clone that's progressed the most so far), but I wanted something clean and lightweight, and as you say, GNUstep is enormous and creates folders and other things most projects don't need. It is as if GNUstep was unable to make up its mind whether it's an operating system that owns the machine, or just a piece of software that's a guest there.
|
Uli Kusterer replies: ★ Andy, I think that should work. Though I'm not sure whether there's a good CGI library at the moment that runs atop libNuFound. But that shouldn't be too hard to port, I'd guess. |
|  |