NeXTSTEP 3.3 "Hello World" Console Version

NeXT Computer, Inc. -> Porting New Software

Title: NeXTSTEP 3.3 "Hello World" Console Version
Post by: pTeK on January 10, 2024, 12:48:52 PM
Hi

 If you're like me, you will pick up a book on Objective-C at the library which is (2005+) and it will have a Hello World example which uses NSLog.

 Here is a working example for NeXTSTEP 3.3. Type the following code below in to a raw text file and save it as hello.m.

/*
 * cc -Wall -o hello hello.m -lFoundation_s
 * hello-world.m
 */

#import <foundation/NSAutoreleasePool.h>
#import <foundation/NSUtilities.h>

int main(int argc, char *argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    NSLog(@"Hello World!");
    [pool release];
    return 0;
}

and use the following to compile it:

cc -Wall -o hello hello.m -lFoundation_s

and execute with:

./hello

UPDATE Fri 12/Jan/2024: I had a typo in the #import, fixed to #import <foundation/NSAutoreleasePool.h>
Title: Re: NeXTSTEP 3.3 "Hello World" Console Version
Post by: oevl on January 11, 2024, 11:05:25 AM
Hello,

Also starting to learn about software development on the NeXT platform.

I have compiled the "Little" example in /NextLibrary/Documentation/NextDev/Examples/Little but with your code the compiler cannot find the Foundation library, even as it exists on /NextDeveloper/Headers/foundation. Surely it is a compiler configuration, but cannot make it work.

Title: Re: NeXTSTEP 3.3 "Hello World" Console Version
Post by: pTeK on January 11, 2024, 01:29:33 PM
Quote from: oevl on January 11, 2024, 11:05:25 AMI have compiled the "Little" example in /NextLibrary/Documentation/NextDev/Examples/Little but with your code the compiler cannot find the Foundation library, even as it exists on /NextDeveloper/Headers/foundation. Surely it is a compiler configuration, but cannot make it work.

I never knew about the Little example, thanks for mentioning it  8)

Here is a screenshot of my example under NextStep 3.3 under Virtualbox (x86), can I get more details on the errors with you?
Title: Re: NeXTSTEP 3.3 "Hello World" Console Version
Post by: oevl on January 11, 2024, 06:15:03 PM
This is the code, the error message and the $PATH environment variable.


Title: Re: NeXTSTEP 3.3 "Hello World" Console Version
Post by: pTeK on January 11, 2024, 11:18:57 PM
Quote from: oevl on January 11, 2024, 06:15:03 PMThis is the code, the error message and the $PATH environment variable.
I though the $PATH environment variable was just for binaries?!

But I think I located a typo error in your screenshot at line 6 you have:

I made a typo in the source code posted above

#import <foundation/NSAutorelasePool.h>
you are missing the e in <foundation/NSAutorelease.h>
it should be:
#import <foundation/NSAutoreleasePool.h>

Happens to me a lot  :'(

UPDATE 12/Jan/2024: I made a typo in the source posted in post #1, this is fixed now
Title: Re: NeXTSTEP 3.3 "Hello World" Console Version
Post by: oevl on January 12, 2024, 07:50:46 AM
Oh, just a typo!

Fixed it and now the code works, I was of the impression that there was something wrong with my NS3.3 system and the Developer stuff.
Title: Re: NeXTSTEP 3.3 "Hello World" Console Version
Post by: pTeK on January 12, 2024, 01:11:41 PM
Quote from: oevl on January 12, 2024, 07:50:46 AMOh, just a typo!

Fixed it and now the code works, I was of the impression that there was something wrong with my NS3.3 system and the Developer stuff.
That error was 100% my end  ;D , I'm glad someone tried the example and couldn't get it working or else I wouldn't have picked up on it.

I really need to get off my @$$ and get NFS up and running because getting files of my VirtualBox NS3.3/OS4.2 has been non existent at the moment and involves me retyping them  :'(

I see you use vi as well with :set tabstop=4

my ~/.exrc is:

:set tabstop=4

What is yours?
Title: Re: NeXTSTEP 3.3 "Hello World" Console Version
Post by: oevl on January 12, 2024, 01:55:31 PM
I should have place more attention to the name of the headers in the code, as I said, I was not confident about this system configuration for NS development so I assumed the code was OK.

"Assumptions kill" !

I use vim version 6.2 and my simple .vimrc looks like this:

set nocompatible
set t_Co=256
set background=dark
" Status bar
set laststatus=2
" Last line
set showmode
set showcmd
set backspace=indent,eol,start
set tabstop=4

Regarding NFS, I use Previous and latest versions include a local NFS "server" that shares your home folder with the emulated machine, but also I have a FreeBSD machine with a NFS export that I can connect to.

Go to top  Forum index