Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: [HOWTO] Installing and using the GNUStep Framework

  1. #1
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    [HOWTO] Installing and using the GNUStep Framework

    Hi again!

    Some people know my How-to guide to compile Objective-C code using gcc (http://ubuntuforums.org/showthread.php?t=1064045). In that How-to I showed how to create an executable without GNUStep. The only requirement was the GNU Objective-C Runtime, which is something completely different.

    But for sure Objective-C is usually used with the OpenStep libraries or aka. "Framework". There are several implementations of the OpenStep framework; the most used and most stable one is Apple NeXTStep, derived from NeXT NeXTStep. In the Free Software world, we've got two ones: GNU GNUStep and SideStep (a GNUStep fork). Both Free ones are outdated with respect to the current OpenStep specifications; the reasons are many, specially lack of interest in the GNU/Linux community and the outdated GNU Objective-C Runtime (still doesn't support Objective-C 2.0... this means no automatic Garbage Collection, for example).

    There's also another issue with GNUStep. You may have read that NeXT/GNUStep is an "object-oriented framework" and seen a picture of NeXT's desktop environment or its GNU clone called Window Maker. Sometimes people call these Desktop Environments as NeXT/GNUStep, which is as false as to say GTK+ is a DE. But don't think this is because people are just plain idiots that don't do their research... No, the situation is a bit comparable to GTK+: GTK+ was initially just a part of GIMP but it grew up into a different project. So, the OpenStep libraries were initially just part of NeXT's NeXTStep OS, then became the OS's API, the OS got extincted but the libraries proved to be useful independently... and the name wasn't changed. Nowadays OpenStep is a bunch of libraries, a framework, that includes lots of things: a general programming library, a GUI toolkit, etc.

    If you hear about Apple Cocoa, you should know it is how the Apple GUI toolkit from Apple is known and is NeXTStep based. Nothing else. Don't confuse it with Apple Carbon (the Mac OS Classic compatibility layer)! (yeah... Apple should use more descriptive names).

    Actually, much of my intention on writing this How-to is about giving a clearer image of what OpenStep, GNUStep, NeXTStep really are. Having these concepts clear, the steps to follow will be really much easier to follow.

    1. Installing (and how to install what)
    The best thing you can do is to install gnustep-devel. That package also includes the development documentation.

    Code:
    sudo aptitude install gnustep-devel
    You can, though, install GNUStep partially. For example, if you're not interested on the GUI toolkit, you could install libgnustep-base-dev... but that might be uncomfortable for someone making his first steps with GNUStep.

    2. An example source code
    You'll have to learn how to use the GNUStep API, of course. The most important thing is probably, that you use NSObject as your root class instead of Object (declared at objc/Object.h). The NSObject class has a lot of advantages over the minimal Object one.

    Here's a little example of an Objective-C/GNUStep application (taken from
    Code:
    /* 
     * Copyright c 2001-2004 Free Software Foundation 
     *
     * Permission is granted to make and distribute verbatim copies of this manual
     * provided the copyright notice and this permission notice are preserved on all
     * copies.
     *
     * Permission is granted to copy and distribute modified versions of this manual
     * under the conditions for verbatim copying, provided also that the entire
     * resulting derived work is distributed under the terms of a permission notice
     * identical to this one.
     *
     * Permission is granted to copy and distribute translations of this manual into
     * another language, under the above conditions for modified versions.
     */
    
    
    #include <stdio.h>
    /*
     * The next #include line is generally present in all Objective-C
     * source files that use GNUstep. The Foundation.h header file
     * includes all the other standard header files you need.
     */
    #include <Foundation/Foundation.h>
    
    /*
     * Declare the Test class that implements the class method (classStringValue).
     */
    @interface Test
    + (const char *) classStringValue;
    @end
    
    /*
     * Define the Test class and the class method (classStringValue).
     */
    @implementation Test
    + (const char *) classStringValue;
    {
        return "This is the string value of the Test class";
    }
    @end
    
    /*
     * The main() function: pass a message to the Test class
     * and print the returned string.
     */
    int main(void)
    {
        printf("%s\n", [Test classStringValue]);
        return 0;
    }
    3. Compiling
    Ok, there are two ways of compiling a GNUStep program. One is using GNUStep Makefiles, which are usually a hassle to use with small projects as they have to be customized in order to avoid having the whole GNUStep Framework linked to your program. The other one is to do this, which will just link the GNUStep base library:

    Code:
    gcc -o test test.m -I/usr/include/GNUstep -L/usr/lib/GNUstep -lobjc -lgnustep-base -Wall
    First, "GNUstep" is the correct name of the directory, as annoying it can be. Second, you still have to link to libobjc.so, which is the Objective-C Runtime!

    For GNUStep Makefiles, refer to the Manual. For GUI applications and big stuff, they may be much more useful than the command I've given above. But for someone that just wants to learn about GNUStep, this is all what's needed.

    @end

  2. #2
    Join Date
    Apr 2008
    Beans
    1

    Re: [HOWTO] Installing and using the GNUStep Framework

    Quote Originally Posted by nvteighen View Post
    Hi again!

    Some people know my How-to guide to compile Objective-C code using gcc (http://ubuntuforums.org/showthread.php?t=1064045). In that How-to I showed how to create an executable without GNUStep. The only requirement was the GNU Objective-C Runtime, which is something completely different.

    But for sure Objective-C is usually used with the OpenStep libraries or aka. "Framework". There are several implementations of the OpenStep framework; the most used and most stable one is Apple NeXTStep, derived from NeXT NeXTStep. In the Free Software world, we've got two ones: GNU GNUStep and SideStep (a GNUStep fork). Both Free ones are outdated with respect to the current OpenStep specifications; the reasons are many, specially lack of interest in the GNU/Linux community and the outdated GNU Objective-C Runtime (still doesn't support Objective-C 2.0... this means no automatic Garbage Collection, for example).

    There's also another issue with GNUStep. You may have read that NeXT/GNUStep is an "object-oriented framework" and seen a picture of NeXT's desktop environment or its GNU clone called Window Maker. Sometimes people call these Desktop Environments as NeXT/GNUStep, which is as false as to say GTK+ is a DE. But don't think this is because people are just plain idiots that don't do their research... No, the situation is a bit comparable to GTK+: GTK+ was initially just a part of GIMP but it grew up into a different project. So, the OpenStep libraries were initially just part of NeXT's NeXTStep OS, then became the OS's API, the OS got extincted but the libraries proved to be useful independently... and the name wasn't changed. Nowadays OpenStep is a bunch of libraries, a framework, that includes lots of things: a general programming library, a GUI toolkit, etc.

    If you hear about Apple Cocoa, you should know it is how the Apple GUI toolkit from Apple is known and is NeXTStep based. Nothing else. Don't confuse it with Apple Carbon (the Mac OS Classic compatibility layer)! (yeah... Apple should use more descriptive names).

    Actually, much of my intention on writing this How-to is about giving a clearer image of what OpenStep, GNUStep, NeXTStep really are. Having these concepts clear, the steps to follow will be really much easier to follow.

    1. Installing (and how to install what)
    The best thing you can do is to install gnustep-devel. That package also includes the development documentation.

    Code:
    sudo aptitude install gnustep-devel
    You can, though, install GNUStep partially. For example, if you're not interested on the GUI toolkit, you could install libgnustep-base-dev... but that might be uncomfortable for someone making his first steps with GNUStep.

    2. An example source code
    You'll have to learn how to use the GNUStep API, of course. The most important thing is probably, that you use NSObject as your root class instead of Object (declared at objc/Object.h). The NSObject class has a lot of advantages over the minimal Object one.

    Here's a little example of an Objective-C/GNUStep application (taken from
    Code:
    /* 
     * Copyright c 2001-2004 Free Software Foundation 
     *
     * Permission is granted to make and distribute verbatim copies of this manual
     * provided the copyright notice and this permission notice are preserved on all
     * copies.
     *
     * Permission is granted to copy and distribute modified versions of this manual
     * under the conditions for verbatim copying, provided also that the entire
     * resulting derived work is distributed under the terms of a permission notice
     * identical to this one.
     *
     * Permission is granted to copy and distribute translations of this manual into
     * another language, under the above conditions for modified versions.
     */
    
    
    #include <stdio.h>
    /*
     * The next #include line is generally present in all Objective-C
     * source files that use GNUstep. The Foundation.h header file
     * includes all the other standard header files you need.
     */
    #include <Foundation/Foundation.h>
    
    /*
     * Declare the Test class that implements the class method (classStringValue).
     */
    @interface Test
    + (const char *) classStringValue;
    @end
    
    /*
     * Define the Test class and the class method (classStringValue).
     */
    @implementation Test
    + (const char *) classStringValue;
    {
        return "This is the string value of the Test class";
    }
    @end
    
    /*
     * The main() function: pass a message to the Test class
     * and print the returned string.
     */
    int main(void)
    {
        printf("%s\n", [Test classStringValue]);
        return 0;
    }
    3. Compiling
    Ok, there are two ways of compiling a GNUStep program. One is using GNUStep Makefiles, which are usually a hassle to use with small projects as they have to be customized in order to avoid having the whole GNUStep Framework linked to your program. The other one is to do this, which will just link the GNUStep base library:

    Code:
    gcc -o test test.m -I/usr/include/GNUstep -L/usr/lib/GNUstep -lobjc -lgnustep-base -Wall
    First, "GNUstep" is the correct name of the directory, as annoying it can be. Second, you still have to link to libobjc.so, which is the Objective-C Runtime!

    For GNUStep Makefiles, refer to the Manual. For GUI applications and big stuff, they may be much more useful than the command I've given above. But for someone that just wants to learn about GNUStep, this is all what's needed.

    @end
    Sorry this doesn't work with ubuntu 10.4 gnustep-devel is a broken package

  3. #3
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: [HOWTO] Installing and using the GNUStep Framework

    Quote Originally Posted by stylx View Post
    Sorry this doesn't work with ubuntu 10.4 gnustep-devel is a broken package
    Hm... I don't know. Ask the package mantainers; I'm no longer using Ubuntu and gnustep-devel was the way to make it work... and is still the way in Debian.

  4. #4
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: [HOWTO] Installing and using the GNUStep Framework

    I've been playing around with Objective-C and GNUstep and I've got as far as getting simple command-line tools to work, both using vanilla gcc and GNUmakefiles.

    So a program like this works:

    Code:
    #import <Foundation/Foundation.h>
    
    int main (void) { 
      NSLog (@"Executing");
      return 0;
    }
    with a GNUmakefile like this:

    Code:
    include $(GNUSTEP_MAKEFILES)/common.make
    
    TOOL_NAME = LogTest
    LogTest_OBJC_FILES = source.m
    
    include $(GNUSTEP_MAKEFILES)/tool.make
    It works

    $ ./obj/LogTest
    2010-07-24 12:57:30.356 LogTest[29863] Executing

    Just a pity the Objective-C 2.0 features aren't supported.

    But when I try to create a GUI application:

    Code:
    #import <Foundation/Foundation.h>
    #import <AppKit/AppKit.h>
    
    int main (void) {
    	NSAutoreleasePool *pool;
    	pool = [NSAutoreleasePool new];
    	[NSApplication sharedApplication];
    	NSRunAlertPanel (@"Test", @"Hello from the GNUstep AppKit", nil, nil, nil);
    	return 0;
    }
    with the appropriate GNUmakefile (I found these examples in a GNUstep tutorial):

    Code:
    include $(GNUSTEP_MAKEFILES)/common.make
    
    APP_NAME = AppTest
    AppTest_OBJC_FILES = source.m
    
    include $(GNUSTEP_MAKEFILES)/application.make
    That doesn't work

    $ openapp ./AppTest.app
    Segmentation fault

    EDIT: The segmentation fault occurs on the line in red where it tries to show the alert.

    Any ideas? I'm running 10.04, all up to date, 64-bit.

    I also get segmentation faults when I try to run any of the GNUstep tools, such as Project Center. I did find a post that suggested installing Gorm, which I think may be what makes gnustep-devel "broken", but that doesn't help?
    Last edited by r-senior; July 24th, 2010 at 01:23 PM. Reason: Added note on which line faults

  5. #5
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: [HOWTO] Installing and using the GNUStep Framework

    Quote Originally Posted by r-senior View Post
    I've been playing around with Objective-C and GNUstep and I've got as far as getting simple command-line tools to work, both using vanilla gcc and GNUmakefiles.

    So a program like this works:

    Code:
    #import <Foundation/Foundation.h>
    
    int main (void) { 
      NSLog (@"Executing");
      return 0;
    }
    with a GNUmakefile like this:

    Code:
    include $(GNUSTEP_MAKEFILES)/common.make
    
    TOOL_NAME = LogTest
    LogTest_OBJC_FILES = source.m
    
    include $(GNUSTEP_MAKEFILES)/tool.make
    It works

    $ ./obj/LogTest
    2010-07-24 12:57:30.356 LogTest[29863] Executing

    Just a pity the Objective-C 2.0 features aren't supported.

    But when I try to create a GUI application:

    Code:
    #import <Foundation/Foundation.h>
    #import <AppKit/AppKit.h>
    
    int main (void) {
    	NSAutoreleasePool *pool;
    	pool = [NSAutoreleasePool new];
    	[NSApplication sharedApplication];
    	NSRunAlertPanel (@"Test", @"Hello from the GNUstep AppKit", nil, nil, nil);
    	return 0;
    }
    with the appropriate GNUmakefile (I found these examples in a GNUstep tutorial):

    Code:
    include $(GNUSTEP_MAKEFILES)/common.make
    
    APP_NAME = AppTest
    AppTest_OBJC_FILES = source.m
    
    include $(GNUSTEP_MAKEFILES)/application.make
    That doesn't work

    $ openapp ./AppTest.app
    Segmentation fault

    EDIT: The segmentation fault occurs on the line in red where it tries to show the alert.

    Any ideas? I'm running 10.04, all up to date, 64-bit.

    I also get segmentation faults when I try to run any of the GNUstep tools, such as Project Center. I did find a post that suggested installing Gorm, which I think may be what makes gnustep-devel "broken", but that doesn't help?
    Hum... I'm experiencing something similar on Debian Squeeze... but it's not segfaulting... Let me check.

  6. #6
    Join Date
    Feb 2006
    Location
    ~/Leicester
    Beans
    1,103
    Distro
    Ubuntu

    Re: [HOWTO] Installing and using the GNUStep Framework

    I get a whole list of errors to do with loading /var/lib/defoma/gnustep -nfont.d/Font/name of font whenever I try to run any GS app.
    I <3 ROX!

    Zimbo, zimbo, zimbo, zimbo, zimbo
    Zimbo, zimbo, zimbo, zimbo, zimbo

  7. #7
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: [HOWTO] Installing and using the GNUStep Framework

    Quote Originally Posted by Mark76 View Post
    I get a whole list of errors to do with loading /var/lib/defoma/gnustep -nfont.d/Font/name of font whenever I try to run any GS app.
    There's a really bad major bug (http://bugs.debian.org/568307) that's preventing GNUStep working on Ubuntu and Debian (testing, which Ubuntu always syncs with)... Just look at Google, it seems to be defoma's fault or something.

    Moreover, the gnustep-back-common package at Debian Squeeze's repos cannot purge the fonts when uninstalled... you have to manually remove /var/lib/defoma/gnustep-nfont.d and then run defoma-reconfigure (everything as root).

    It seems gnustep-back-common version 0.18.0 fixes this, but that's on Debian unstable...

  8. #8
    Join Date
    Feb 2006
    Location
    ~/Leicester
    Beans
    1,103
    Distro
    Ubuntu

    Re: [HOWTO] Installing and using the GNUStep Framework

    Okay. I removed the gnustep-nfont.d folder, ran defoma-reconfigure and then tried running GWorkspace from the terminal and got

    2010-07-24 16:13:04.517 GWorkspace[16096] No fonts found!
    I <3 ROX!

    Zimbo, zimbo, zimbo, zimbo, zimbo
    Zimbo, zimbo, zimbo, zimbo, zimbo

  9. #9
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: [HOWTO] Installing and using the GNUStep Framework

    Well it's good to see I'm not the only one

    I'm not seeing font problems. I tried running the GUI application with debug set and I get this:

    Code:
    (gdb) run
    Starting program: /home/richard/GNUstep/Projects/AppTest/AppTest.app/AppTest 
    [Thread debugging using libthread_db enabled]
    
    Program received signal SIGSEGV, Segmentation fault.
    0x00007ffff70eb75e in ?? () from /usr/lib/libgnustep-base.so.1.19

  10. #10
    Join Date
    Feb 2006
    Location
    ~/Leicester
    Beans
    1,103
    Distro
    Ubuntu

    Re: [HOWTO] Installing and using the GNUStep Framework

    That's because you have no fonts installed.

    Either that or you hate anti-aliasing.
    I <3 ROX!

    Zimbo, zimbo, zimbo, zimbo, zimbo
    Zimbo, zimbo, zimbo, zimbo, zimbo

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •