3

I have a question relating to this question Unable to Compile Objective C using Gnustep on windows

I am trying to compile my first objective c app on Windows. The file is hello.m (all files below created in Visual Studio)

#import <../Program Files/GNUstep/System/Library/Headers/Foundation/Foundation.h>

int main(int argc, const char* argv[])
{
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
    NSLog(@"Hello from Hello.m!");

    [pool release];
    return 0;
}

In order to compile it I have a GNUmakefile in the same directory:

include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = hello
YourProg_OBJC_FILES = hello.m
include $(GNUSTEP_MAKEFILES)/tool.make

As I understand it, when I run make the command "make" the GNUmakefile will execute.

When I do this in the GNUStep shell I get an error

GNUmakefile:1 *** missing separator. Stop.

I tried adding a tab to the first line. This did nothing. Yes, I am sure it was a tab, not a space.

Community
  • 1
  • 1
Petras
  • 4,686
  • 14
  • 57
  • 89
  • 1
    Incidentally, will your `#include <../blah>` work? I'm used to C requiring `#include "../blah"` for paths relative to the source. – sarnold Jan 23 '11 at 02:53
  • @sarnold it might or might not work. The difference between "" and <> is where the search for include headers starts. "" is related to the project sources and <> normally starts at the system defined include paths. – MKroehnert Feb 18 '11 at 09:53

4 Answers4

3

I Had the same problem. I used Notepad++ to make the GNUmakefile. My default encoding with Notepad++ is UTF8. But make.exe from MINGW32 seems to wait a file with ANSI encoding.

So, verify if your file is encoded with ANSI.

Balmat
  • 163
  • 1
  • 1
  • 8
1

In your GNUmakefile, YourProg_OBJC_FILES should be modified to be hello_OBJC_FILES, just like below

include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = hello
hello_OBJC_FILES = hello.m
include $(GNUSTEP_MAKEFILES)/tool.make

Or you can also just compile in command line like this

$ gcc `gnustep-config --objc-flags` hello.m -o hello `gnustep-config --base-libs`

The gnustep-config like pkg-config command can print out the compiling and linking options for gcc.

Yantao Xie
  • 12,300
  • 15
  • 49
  • 79
1

make is complaining about your makefile, so you probably have a syntax error somewhere.

See: http://www.gnu.org/software/automake/manual/make/Error-Messages.html:

This means that make could not understand much of anything about the makefile line it just read. GNU make looks for various separators (:, =, recipe prefix characters, etc.) to indicate what kind of line it's parsing. This message means it couldn't find a valid one.

Try you might try compiling directly:

gcc -o hello hello.m -I/c/GNUstep/GNUstep/System/Library/Headers \
    -L /c/GNUstep/GNUstep/System/Library/Libraries -lobjc -lgnustep-base \
    -fconstant-string-class=NSConstantString
Seth
  • 45,033
  • 10
  • 85
  • 120
  • it is usually better to use gnustep-config to setup most of the necessary compile flags like indicated here: http://stackoverflow.com/questions/3538051/how-to-compile-an-objective-c-program-under-windows-with-independant-mingw/3538097#3538097 – MKroehnert Feb 18 '11 at 09:47
1

you should never have to provide the full path for the Foundation.h header file. It should always be #import <Foundation/Foundation.h>.

This together with your makefile problem indicate that something is not setup correctly on your machine. Did you run the make command from an msys shell or from the Windows commandline? If you chose to go with the Windows command line you will face some problems because the environment is not setup correctly there in contrary to the msys shell provided with the GNUstep installer.

If you want to run gcc manually on the other hand you can have a look at this SO answer.

Community
  • 1
  • 1
MKroehnert
  • 3,637
  • 2
  • 34
  • 43