Link to home
Start Free TrialLog in
Avatar of mindwarpltd
mindwarpltd

asked on

Installed GNUStep, have msys.bat how can I add CD "C:\My Documents\ObjC"

I've just installed GNUStep so I can do some Objective C on my Windows XP while I'm away from home / my Mac Mini.

There's a shortcut to shell, which calls Msys.bat

How can I default shell to CD "C:\My Documents\ObjC"

I'm always going to was to do this to compile programs
Avatar of pgnatyuk
pgnatyuk
Flag of Israel image

Try it first. It is not the same as Objective-C 2.0 and Xcode on your Snow Leopard.
Can you imagine a case when you will write a Windows applications in pure C++ on Mac OS X computer? No Win32 API available, right? So you hope that at least printf("Hello, world"); will work? Same with GNUStep. Objective-C without Cocoa is not attractive at all.
 
You can write a program in a text editor and then compile it in the command prompt window.
I hope, I'm wrong. I tried it few months ago for an hour and I cannot say I liked it. I simply un-installed it.
Again, I hope, I'm wrong and someone will advice here how to work with it. If not, maybe you will say what you think about it.

Avatar of mindwarpltd
mindwarpltd

ASKER

I have tried, I want to write some core functions.
Core? For Windows? On Windows computer you can write a "core function" for Windows. You mean a core of project probably. Even in this case, in Xcode, any class you make begins as:
@interface Hello: NSObject
{
}
It does not compile in GNUStep. NSObject does not exist there. Without NSObject you lose a lot.
Try yourself. Open Notepad++ (whatever you have) and write a helloWorld program (or any core function).

On Wiki you can find how to install GNUStep on Windows (if you have a trouble with it):
Installation on Windows
http://wiki.gnustep.org/index.php/Installation_on_Windows

This is a shorter article and it has a hello example in the end (it works):
Installing and using GNUstep and Objective-C on Windows
http://www.techotopia.com/index.php/Installing_and_using_GNUstep_and_Objective-C_on_Windows

It's all work. I tested all that few months ago.

You may need Cygwin or MinGW. I have tried Cocoatron too. It has much more than GNUStep.
http://www.cocotron.org/

Do not forget that the Objective-C run-time is different even for Leopard and Snow Leopard. A lot of nice Objective-C features are presented only in the 64-bit.
After Mac OS X it's somehow not convenient to work on a Windows computer. At least, it is correct about Objective-C programming. Better to use C# for Windows.

I hope, I'm wrong. So someone will fix me. I really wish you good luck. Please let me know if you will get something good, a better than my experience with it.


I followed this earlier
http://www.roseindia.net/iphone/objectivec/compiling-objective-c.shtml

I had hoped to write some sqlite functions and get all my sql embedded in the code.
Although I haven't looked for an sqlite library for windows.

I figured I'd have problems finding an alternative to xcode on windows, but thought I'd be able to do the data access stuff as mentioned.
I wish you good luck.

It is a very short article. I passed that point. I even wrote something like you say "core" (not about my sql).
no not my sql

sqlite, theres libraries in xcode.
how I know (I'm not a database programmer), you can work with sqllite from standard C++. So you may make such code in Visual Studio.
Please let me know if you will have a better results than me.
Hmmm thats an idea.
Still might have a look for sqlite for gnustep
Oh just realised I don't have vs on my laptop as my laptop is old and slow, looking for something lighter, gnustep would have been great
Just found this article:
Compile Objective-C Programs Using gcc
http://blog.lyxite.com/2008/01/compile-objective-c-programs-using-gcc.html

Seems like this guy with GNUStep compiles a foundation tool program: with a class derived from NSObject.
Cool, have you verified this ?

Have you found sqlite too :P
I have only Mac today. I attached a code that I compile without Xcode, in the terminal with gcc as:
gcc -arch i386 test.m -lobjc -o test

Them I launch the app:
./test

and it even works.

(-arch i386 it's because I'm on the 64-bit)

That's all I can test today on Mac from that article.

#include <objc/Object.h>
#include <stdio.h>
#include <stdio.h>

@interface Test : Object
{
}

- (void) sayHello;

@end;

@implementation Test


- (void) sayHello
{
  printf("Hello\n");
}

@end

int main(void)
{
  id t;
  t = [Test new];
  [t sayHello];
  [t free];
  return 0;
}

Open in new window

What about your compiler flag / command line ?
You see it in the previous comment:
gcc -arch i386 test.m -lobjc -o test

I think, you need: gcc test.m -lobjc -o test
You have installed Mingw? Do you have gcc?
yes I have gcc

Hmmm I get...

Administrator@iron ~
$ cd "C:\My Documents\ObjC"

Administrator@iron /c/My Documents/ObjC
$ gcc test.m -lobjc -o test
test.m:1:25: error: objc/Object.h: No such file or directory
test.m:6: error: cannot find interface declaration for 'Object', superclass of '
Test'
test.m: In function 'main':
test.m:26: warning: 'Test' may not respond to '+new'
test.m:26: warning: (Messages without a matching method signature
test.m:26: warning: will be assumed to return 'id' and accept
test.m:26: warning: '...' as arguments.)
test.m:28: warning: no '-free' method found

Administrator@iron /c/My Documents/ObjC
$

I took the other includes out and left

#include <stdio.h>

But I got the same errors expect the first one with Object.h
you need to setup the environment on your computer. All LIB, PATH, etc.
One of the links above explains how to do that on Windows.
http://www.techotopia.com/index.php/Installing_and_using_GNUstep_and_Objective-C_on_Windows
There is full "Hello" example.

Or use full path to this library.
User variables
PATH
C:\GNUstep\mingw\bin;C:\GNUstep\GNUstep\System\Tools

System variables
PATH has stuff in too

I don't have a LIB or ALL LIB  
For a test use the full path to the libraries in the command line. It will compile.
Which command line ?
gcc the_file_with_your_code -lobjc

If you on a Windows computer, in the command prompt go to the folder with your program and type this line above. It will look like:
>c:\mingw\bin\gcc my_program.m -lc:\gnustep\lib\objc
Hmmm, think this should have worked, have I missed something ?

C:\My Documents\ObjC>gcc test.m -lc:\gnustep\lib\objc
test.m:4: error: cannot find interface declaration for 'Object', superclass of '
Test'
test.m: In function 'main':
test.m:24: warning: 'Test' may not respond to '+new'
test.m:24: warning: (Messages without a matching method signature
test.m:24: warning: will be assumed to return 'id' and accept
test.m:24: warning: '...' as arguments.)
test.m:26: warning: no '-free' method found
It's a progress.
I saw same errors today on Snow Leopard (64 bit). The fix was -arch i386. Try to use it. After gcc add this parameters.
Is this what you meant ?

C:\My Documents\ObjC>gcc -arch i386 test.m -lc:\gnustep\lib\objc
gcc: i386: No such file or directory
cc1obj.exe: error: unrecognized command line option "-arch"

C:\My Documents\ObjC>gcc test.m -arch i386 -lc:\gnustep\lib\objc
gcc: i386: No such file or directory
cc1obj.exe: error: unrecognized command line option "-arch"
That worked on my Mac. I've told: I'm on 64-bit and have to use this -arch i386 to compile the GNUStep Objective-C program. Strange that your gcc does not recognize these options.
Check:
gcc -v
and tell me what is the version.
You can try to add that:
-fgnu-runtime

Check if you can compile the attached code.
#include <stdio.h>
#include <objc/objc.h>

int main (void)
{
 
  return 0;
}

Open in new window

Seems like the command line should be:
gcc -fgnu-runtime  test.m  -lobjc

Of course with the correct path for the gcc, m-file and the library.

C:\My Documents\ObjC>gcc -fgnu-runtime test.m -lobjc
test.m:4: error: cannot find interface declaration for 'Object', superclass of '
Test'
test.m: In function 'main':
test.m:24: warning: 'Test' may not respond to '+new'
test.m:24: warning: (Messages without a matching method signature
test.m:24: warning: will be assumed to return 'id' and accept
test.m:24: warning: '...' as arguments.)
test.m:26: warning: no '-free' method found
C:\My Documents\ObjC>gcc `gnustep-config --objc-flags` -o test test.m -L c:/GNUs
tep/GNUstep/System/Library/Libraries -lobjc -lgnustep-base
gcc: `gnustep-config: No such file or directory
cc1obj.exe: error: unrecognized command line option "-fobjc-flags`"
Which Windows version you use? I have here a computer, hopefully, with Windows XP. If you have the same I will install GNUStep. :)
gcc test.m -lobjc
for test.m:

#include
#include

int main (void)
{
 
  return 0;
}

works?
Yes windows XP
C:\My Documents\ObjC>gcc test2.m -lobjc
test2.m:2:23: error: objc/objc.h: No such file or directory
add the path before objc. We did it once. If you cannot compile this test.m we cannot continue. Your compiler does not find the objective-c. Should be c:\ObjC\objc something like that.

I have a C:\My Documents\ObjC which has my m files in.

I did a search on the GNUstep folder heres the results, not sure what path to use ?
objc-files.png
C:\My Documents\ObjC
Sorry can you give me the command line, I don't see how this would work ?
Heres my my docs\objc files
mydocs-objc.png
Actually it took 5 minutes to install GNUStep exactly as it is described here:
http://www.gnustep.org/experience/Windows.html
I found this link from here: http://www.techotopia.com/index.php/Installing_and_using_GNUstep_and_Objective-C_on_Windows
I iunstalled MSYS and the the Core. Then I launched the shell. It is in Start->All Programs->GNUStep->Shell.
now gcc compiler can be launched. I used vi to type a small test.m file:
#include <stdio.h>
int main(void)
{
  printf("hello\n");
  return 0;
}
then typed: gcc test.m. Just to test. This is actually c program. I got a.exe. It works.

gnustepshell.JPG
Next step. I modified test.m file. It still compiles and works. All is attached.
#include <objc/object.h>
#include <stdio.h>

int main(void)
{
  printf("Hello, Objective-C\n");
  return 0;
}

Open in new window

gnustepshell1.JPG
Next step
#include <objc/object.h>
#include <stdio.h>

@interface Test : Object
{
}
- (void)sayHello;
@end

@implementation Test

- (void) sayHello
{
   printf("Hello from Objective-C class\n");
}

@end

int main(void)
{
  id t;
  t = [Test new];
  [t sayHello];
  [t free];
  return 0;
}

Open in new window

gnustepshell2.JPG
You know - thank you. This time GNUStep works as promissed for me. Now I suspect that we can compile a foundation tool on Windows XP. :) Pay attention that the output files are standard Windows executables.
When I installed GNUStep I did change any default parameter. The foilder is C:\GNUStep. In this folder 'home'. In this folder I se ethe folder with my uiser name. It's like HOME on Mac. In this folder you can create files with any Windows editor. For example, with Notepad++.
 
So what do I need to do ?
Foundation tool is also works. The command line is long:
$ gcc `gnustep-config --objc-flags` -L /GNUstep/System/Library/Libraries test1.m -o test1.exe -lgnustep-base -lobjc
 

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

        NSLog (@"Hello. It's Foundation Tool");
        [pool drain];
        return 0;
}

Open in new window

gnustepshell3.JPG
>>So what do I need to do ?
1. Install GNUStep.
2. Launch a text editor and type of the samples from this thread and save it in /GNUStep/home/<user name> folder.
3. Launch Shell. It is in Start->All Programs->GNUStep->Shell.
4. In the shell type gcc.... - the command to compile the file you just saved. All these gcc strings are in this thread.
 
Hmmm, I must have some enviromental variables, or something wrong then ?

C:\My Documents\ObjC>gcc `gnustep-config --objc-flags` -L /GNUstep/System/Librar
y/Libraries test1.m -o test1.exe -lgnustep-base -lobjc
gcc: `gnustep-config: No such file or directory
cc1obj.exe: error: unrecognized command line option "-fobjc-flags`"
no. Everything's set when you launched the shell. It is a bat-file.
I'm afraid you didn't install something.
Download first two links from here:
http://www.gnustep.org/experience/Windows.html
Uninstall everything you have about GNUStep.
Then install - the order is important.
This is actually the page I followed I downloaded and installed in this order...

GNUstep MSYS System       Required       0.25.1       none       MSYS/MinGW System
GNUstep Core       Required       0.25.0       none       GNUstep Core
GNUstep Devel       Optional       1.1.1       None       Developer Tools

I didn't install the last one... Cario backend
No. You need to install GNUStep MSYS System and GNUStep Core. The order is important. So uninstall and install again.
Thats the order I did them, I didn't have gcc until I installed GNUstep Devel.

I installed

GNUstep MYSUS System  then
GNUstep Core then
GNUstep Devel
I didn't install GNUStep Devel.
As you wish, it's your computer. :)
Huh ?

What do I do ?
Whatever you think is right. I've said what I think. So now it is your problem to decide. :)
1. Uninstall everything GNUStep related from your Windows XP computer.
2. Install GNUstep MSYS System. No changes in the installation wizard.
3. GNUstep Core. No changes in the installation wizard.
4. Launch Shell. Start->All Programs->GNUStep->Shell.
5. In the shell type gcc -v. It will show you the version number. I see gcc version 3.4.5 .

Other option: invite me to visit you. :)
OK, I've uninstalled and now on point 2, 2 secs
Ok, I followed those 5 points exactly...

Setting up GNUstep Environment.

Administrator@iron ~
$ gcc -v
sh: gcc: command not found

Administrator@iron ~
$
Do you see it in the GNUStep shell?
Did you have mingw installed before?
Yes I have GNUstep

Setting up GNUstep Environment...

Administrator@iron ~
$ gcc -v
sh: gcc: command not found

Administrator@iron ~
$


No I dont have mingw installed now, it would have only been installed when I installed GNUstep.

The only other thing which seems relevant to mention is GNU Aspell, but I dont think that relevant.

Any further ideas?

No.
I'm leaving. I have no idea. Sorry. Good luck.
Oh dear :(

I'll try another machine tomorrow, thanks, I will post back to see how it goes.
Maybe theres something odd about my laptop.

Was your machine clean before you installed ?
No env variables etc too ?
No. I installed everything on my old HP desktop. It's really old. It was with Windows XP from the beginning, from the shop. I have a million of SDK's, studios, apps, drivers,... installed on it. The download, installation and these 3 samples took me about 15 minutes.
Hmmm, so you could have had something else installed or a env sys var too
I checked Add/Remove Programs before the installation.
Read here: http://www.techotopia.com/index.php/Installing_and_using_GNUstep_and_Objective-C_on_Windows
It's exactly what I did.
In the previous round you had gcc working but there was a problem with the libraries. You can try to install this Devel, if it helps. And try to compile.
Ok, I tried yet another uninstall and reinstall on my laptop and still no joy.
I noticed it created another GNUstep sub folder, so I copied that into the root and that didnt work either.

I think I'll try installing the exact versions in that last article.

Where are you UK ?

Thanks, I'll report back.
Which subfolder? It's installed on C drive. I have C:\GNUStep and C:\MINGW. I didn't change anything n the installation wizard.
>>I think I'll try installing the exact versions in that last article.
Of course.
OK, I now have

$ gcc -v
Reading specs from C:/GNUstep/mingw/bin/../lib/gcc/mingw32/3.4.5/specs
Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --wi
th-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --dis
able-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --d
isable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --with
out-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enabl
e-hash-synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.5 (mingw-vista special r3)


:)

I went back and tried the command line before we discovered I had a gcc problem and this has the same error too.

C:\My Documents\ObjC>gcc `gnustep-config --objc-flags` -L /GNUstep/System/Librar
y/Libraries test1.m -o test1.exe -lgnustep-base -lobjc
gcc: `gnustep-config: No such file or directory
cc1obj.exe: error: unrecognized command line option "-fobjc-flags`"
Ahhh but

Administrator@IRON ~
$ cd "c:\my documents\objc"

Administrator@IRON /c/my documents/objc
$ gcc `gnustep-config --objc-flags` -L /GNUstep/System/Library/Libraries test1.
m -o test1.exe -lgnustep-base -lobjc
Info: resolving ___objc_class_name_NSAutoreleasePool by linking to __imp____objc
_class_name_NSAutoreleasePool (auto-import)
Info: resolving ___objc_class_name_NSConstantString by linking to __imp____objc_
class_name_NSConstantString (auto-import)
C:\GNUstep\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: wa
rning: auto-importing has been activated without --enable-auto-import specified
on the command line.
This should work unless it involves constant data structures referencing symbols
 from auto-imported DLLs.
Administrator@IRON /c/my documents/objc
$
And

C:\My Documents\ObjC>test1
2010-08-14 09:18:20.674 test1[2664] Hello. It's Foundation Tool

C:\My Documents\ObjC>
Great!
Congratulations.
I tried the example before that....

Administrator@IRON /c/my documents/objc
$ gcc `gnustep-config --objc-flags` -L /GNUstep/System/Library/Libraries test.m
 -o test.exe -lgnustep-base -lobjc
test.m:5: error: cannot find interface declaration for `Object', superclass of `
Test'
The code from this post 33433130 above
Read the error message: Object is the superclass and the compiler does not find the headers.
Anyway, you don't need this example. You need the one you have compiled - with the Foundation imported.
Have a nice weekend.
Isn't there a command line which will do everything ?
Any ideas about sqlite ?
Ah lol, you haven't answered the original question :)
I'm trying to put some basic code together, without much look, any ideas ?
#import <Foundation/Foundation.h>

@interface Test : NSObject
{
}

- (void) fred;
@end;

@implementation Test
- (void) fred {
{
  printf("Hello\n");
}
@end

int main (int argc, const char * argv[])
{
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

  	id t;
  	t = [Test new];
  	[t fred];
  	[t free];
  
        NSLog (@"Hello. It's Foundation Tool");
        [pool drain];
        return 0;
}

Open in new window

Ah found this, a good example which compiles and runs without errors :)

Now what do you think about sqlite ?
#import <Foundation/Foundation.h>
 
 
/* Interface */
@interface Fraction: NSObject 
{
	int numerator;
	int denominator;
}
 
-(void) print;
-(void) setNumerator: (int) n;
-(void) setDenominator: (int) d;
-(void) dealloc;
@end
 
 
/* Implementation */
@implementation Fraction;
-(void) print
{
	NSLog (@"The value of the fraction is %i/%i", numerator, denominator);
	
}
 
-(void) setNumerator: (int) n {
	numerator = n;
}
 
-(void) setDenominator: (int) d {
	denominator = d;
}
 
-(void) dealloc {
	NSLog(@"Release called. Deallocating memory...");
	[super dealloc];
}
@end
 
int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
 
	Fraction *myFraction = [[Fraction alloc] init];
	
	// Set fraction to 3/4
	[myFraction setNumerator: 3];
	[myFraction setDenominator: 4];
	
	// the 'print' method was never called, decided to put the message there
	// Display the fraction
	[myFraction print];
	
        //avoid memory leak with release and super delloc
	[myFraction release];
    [pool drain];
    return 0;
}

Open in new window

If you can tell me how can I default shell to CD "C:\My Documents\ObjC", which was the original question, I'll accept your solution.

I think the sqlite is another question.

Thanks
Is it a weekend? :)
>>default shell to CD "C:\My Documents\ObjC"
What do you mean? If you need to change the folder use:
cd "C:\My Document\Objc"
Your current folder will be "C:\My Document\Objc"
It's correct for Windows batch-file and for the bash-shell on Mac OS X.

To see the current folder in the GNUStep shell type pwd:
$pwd

To change folder use cd. Go to the root:
$ cd /

One level up: cd ..

ls will show the content:
$ ls

I do not know what you mean with this "c:/my document/objc". If it your working folder, make it in the GNUStep. It will be more convenient to compile the programs. It's supposed to work in this way. It is a shell from GNUStep. When you launch it sets up all environment variables.

If in the Shell you will type ls C: you will see the content of C. You can go to My Documents, but it looks, probably, so:
"c:\Documents and Settings\\My Documents\ObjC".
so you can use it with cd command.

In C:\GNUStep\etc you can find your profile files and can modify them. But It is not recommended. I'd say, do not touch them. At least not now. in 'profile' you will see the HOME folder. It's correct. It behaves exactly as bash-shell on Mac by default.

Feel free to delete this question, if you think that this thread didn't help you. Moreover, I'd prefer that way instead of seeing grade "C" or "B" for my answers.
c:\My Documents\ObjC Is the code folder.

I just wanted the shell to default to that folder so I didn't have to do CD "C:\My Documents\ObjC" everytime I open shell.
* c:\My Documents\ObjC Is my code folder.
1. Find file "profile" in GNUStep/etc folder.
2. Make a back-up copy of this file.
3. In the end of this file you will see cd "HOME". Modify it for whatever you want. For example:
cd "C:|My Documents\ObjC"


ASKER CERTIFIED SOLUTION
Avatar of pgnatyuk
pgnatyuk
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial