discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Failure to compile a Windows application


From: Mihai Barbos
Subject: Failure to compile a Windows application
Date: Mon, 31 Jan 2022 09:22:20 +0100

Hi guys

I am trying to compile the following:

#import <Foundation/Foundation.h>

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

   NSString *test = @"test";
   unichar a;
   int index = 5;

   @try {
       a = [test characterAtIndex:index];
       NSLog(@"Selected character is %c", a);
   }
   @catch (NSException *exception) {
       NSLog(@"%@", exception.reason);
       NSLog(@"Char at index %d cannot be found, max index is: %lu", index, (unsigned long)([test length] - 1));
   }
   @finally {
       NSLog(@"Finally statement executed");
   }

   return 0;
}


Compiling:

1. MSVC: clang version 12.0.0

clang -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNUSTEP_RUNTIME=1 -D_NONFRAGILE_ABI=1 -DGNUSTEP_BASE_LIBRARY=1 -DGNUSTEP_WITH_DLL -fno-strict-aliasing -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -pthread -Wno-microsoft-include -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -O2 -fobjc-runtime=gnustep-2.0 -fblocks -fconstant-string-class=NSConstantString -I. -IC:/GNUstep/x86/Debug/include -c hello.m

clang -fuse-ld=lld -fexceptions -fobjc-runtime=gnustep-2.0 -fblocks -LC:/GNUstep/x86/Debug/lib -lgnustep-base -lobjc -o hello.exe hello.o

clang crashes probably when it encounters a "finallyā€¯. It looks like it's a known problem.
Without "finally" it compiles, but this is not an option.

2. MinGW:

 clang -x objective-c -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_RUNTIME=1 -fno-strict-aliasing -fexceptions -fobjc-exceptions -fvisibility=hidden -D_NATIVE_OBJC_EXCEPTIONS -pthread -Wno-import -fmessage-length=0 -fconstant-string-class=NSConstantString -fobjc-runtime=gnustep-2.0 -fblocks -D_NONFRAGILE_ABI=1 -O2 -g -I/c/GNUstep/x86/Debug/include -c hello.m -o hello.o

Compilation goes ok but when I try to link it:
$ clang -fuse-ld=lld -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-2.0 -fblocks -L/c/GNUstep/x86/Debug/lib -lgnustep-base -lobjc hello.o -o hello.exe
ld.lld: error: undefined symbol: _objc_begin_catch
>>> referenced by hello.m:17
>>>               hello.o:(_main)
>>> referenced by hello.m:21
>>>               hello.o:(_main)

ld.lld: error: undefined symbol: _objc_end_catch
>>> referenced by hello.m:21
>>>               hello.o:(_main)
>>> referenced by hello.m:21
>>>               hello.o:(_main)
>>> referenced by hello.m:24
>>>               hello.o:(_main)

ld.lld: error: undefined symbol: ___gnustep_objc_personality_v0
>>> referenced by hello.o:(.eh_frame)
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Can somebody shed some light ?

Thank you
Mihai


reply via email to

[Prev in Thread] Current Thread [Next in Thread]