Closer to get a functional objective-c++ compiler [Help is needed]

Objective-C++ is a front-end to the GNU Compiler Collection, which can compile source files that use a combination of C++ and Objective-C syntax. Objective-C++ adds to C++ the extensions that Objective-C adds to C. As nothing is done to unify the semantics behind the various language features.

I've edited the Makefile of lang/gcc47

The file is on Attachments.

Now I have a GCC with objective-c++ support.

Code:
$ gcc47 -v
Using built-in specs.
COLLECT_GCC=gcc47
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc47/gcc/x86_64-portbld-freebsd9.0/4.7.2/lto-wrapper
Target: x86_64-portbld-freebsd9.0
Configured with: ./../gcc-4.7-20120804/configure --disable-nls --enable-languages=c,c++,objc,obj-c++,fortran --libdir=/usr/local/lib/gcc47 --libexecdir=/usr/local/libexec/gcc47 --program-suffix=47 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc47/include/c++/ --with-ld=/usr/local/bin/ld --with-libiconv-prefix=/usr/local --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --enable-languages=c,c++,objc,obj-c++,fortran,java --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc47 --build=x86_64-portbld-freebsd9.0
Thread model: posix
gcc version 4.7.2 20120804 (prerelease) (FreeBSD Ports Collection)

The error without objective-c++ support is to large, see this thread :http://forums.freebsd.org/showthread.php?t=33018http://forums.freebsd.org/showthread.php?t=33018

(I need execute it before compile)
Code:
$ . /usr/local/GNUstep/System/Library/Makefiles/GNUstep.sh

With clang
Code:
$ clang -ObjC++ main.mm -o hello  `gnustep-config --objc-flags` -I/usr/local/lib/gcc42/gcc/x86_64-portbld-freebsd9.0/4.2.5/include -fconstant-string-class=NSConstantString  -I/usr/local/GNUstep/System/Library/Headers -L/usr/local/GNUstep/System/Library/Libraries -L/usr/local/lib -lgnustep-base
In file included from main.mm:1:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/Foundation.h:33:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/FoundationErrors.h:29:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/NSObject.h:30:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/NSObjCRuntime.h:114:
In file included from /usr/local/GNUstep/System/Library/Headers/GNUstepBase/GSObjCRuntime.h:62:
/usr/local/lib/gcc42/gcc/x86_64-portbld-freebsd9.0/4.2.5/include/objc/objc-api.h:488:10: error: cannot initialize return
      object of type 'MetaClass' (aka 'objc_class *') with an rvalue of type 'Class'
  return CLS_ISCLASS(_class)?_class->class_pointer:Nil;
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/lib/gcc42/gcc/x86_64-portbld-freebsd9.0/4.2.5/include/objc/objc-api.h:298:26: note: expanded from:
#define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS))
                         ^
/usr/local/lib/gcc42/gcc/x86_64-portbld-freebsd9.0/4.2.5/include/objc/objc-api.h:576:10: error: cannot initialize return
      object of type 'MetaClass' (aka 'objc_class *') with an rvalue of type 'Class'
  return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from main.mm:1:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/Foundation.h:33:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/FoundationErrors.h:29:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/NSObject.h:30:
/usr/local/GNUstep/System/Library/Headers/Foundation/NSObjCRuntime.h:166:20: error: use of undeclared identifier
      'INTPTR_MAX'
enum {NSNotFound = NSIntegerMax};
                   ^
/usr/local/GNUstep/System/Library/Headers/Foundation/NSObjCRuntime.h:64:24: note: expanded from:
#       define NSIntegerMax  INTPTR_MAX
                             ^
3 errors generated.

With gcc47

Code:
gcc47 main.mm -o hello  `gnustep-config --objc-flags` -I/usr/local/lib/gcc42/gcc/x86_64-portbld-freebsd9.0/4.2.5/include -fconstant-string-class=NSConstantString  -I/usr/local/GNUstep/System/Library/Headers -L/usr/local/GNUstep/System/Library/Libraries -L/usr/local/lib -lgnustep-base
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/NSObject.h:30:0,
                 from /usr/local/GNUstep/System/Library/Headers/Foundation/FoundationErrors.h:29,
                 from /usr/local/GNUstep/System/Library/Headers/Foundation/Foundation.h:33,
                 from main.mm:1:
/usr/local/GNUstep/System/Library/Headers/Foundation/NSObjCRuntime.h:166:20: error: 'INTPTR_MAX' was not declared in this scope
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/Foundation.h:68:0,
                 from main.mm:1:
/usr/local/GNUstep/System/Library/Headers/Foundation/NSFileManager.h:190:8: warning: 'NSDirectoryEnumerator' has a field 'NSDirectoryEnumerator::_flags' whose type uses the anonymous namespace [enabled by default]



To workaround the problem, I've edited /usr/local/GNUstep/System/Library/Headers/Foundation/NSObjCRuntime.h

adding

Code:
# if __WORDSIZE == 64 
#  define INTPTR_MIN  (-9223372036854775807L-1) 
#  define INTPTR_MAX  (9223372036854775807L) 
#  define UINTPTR_MAX  (18446744073709551615UL) 
# else 
#  define INTPTR_MIN  (-2147483647-1) 
#  define INTPTR_MAX  (2147483647) 
#  define UINTPTR_MAX  (4294967295U) 
# endif

And now

With clang

Code:
clang -ObjC++ main.mm -o hello  `gnustep-config --objc-flags` -I/usr/local/lib/gcc42/gcc/x86_64-portbld-freebsd9.0/4.2.5/include -fconstant-string-class=NSConstantString  -I/usr/local/GNUstep/System/Library/Headers -L/usr/local/GNUstep/System/Library/Libraries -L/usr/local/lib -lgnustep-base
In file included from main.mm:1:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/Foundation.h:33:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/FoundationErrors.h:29:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/NSObject.h:30:
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/NSObjCRuntime.h:114:
In file included from /usr/local/GNUstep/System/Library/Headers/GNUstepBase/GSObjCRuntime.h:62:
/usr/local/lib/gcc42/gcc/x86_64-portbld-freebsd9.0/4.2.5/include/objc/objc-api.h:488:10: error: cannot initialize return
      object of type 'MetaClass' (aka 'objc_class *') with an rvalue of type 'Class'
  return CLS_ISCLASS(_class)?_class->class_pointer:Nil;
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/lib/gcc42/gcc/x86_64-portbld-freebsd9.0/4.2.5/include/objc/objc-api.h:298:26: note: expanded from:
#define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS))
                         ^
/usr/local/lib/gcc42/gcc/x86_64-portbld-freebsd9.0/4.2.5/include/objc/objc-api.h:576:10: error: cannot initialize return
      object of type 'MetaClass' (aka 'objc_class *') with an rvalue of type 'Class'
  return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

With gcc47

Code:
gcc47 main.mm -o hello  `gnustep-config --objc-flags` -I/usr/local/lib/gcc42/gcc/x86_64-portbld-freebsd9.0/4.2.5/include -fconstant-string-class=NSConstantString  -I/usr/local/GNUstep/System/Library/Headers -L/usr/local/GNUstep/System/Library/Libraries -L/usr/local/lib -lgnustep-base
In file included from /usr/local/GNUstep/System/Library/Headers/Foundation/Foundation.h:68:0,
                 from main.mm:1:
/usr/local/GNUstep/System/Library/Headers/Foundation/NSFileManager.h:190:8: warning: 'NSDirectoryEnumerator' has a field 'NSDirectoryEnumerator::_flags' whose type uses the anonymous namespace [enabled by default]
/var/tmp//ccm02ZKe.o: In function `gnustep_base_user_main(int, char**)':
main.mm:(.text+0xcf): undefined reference to `std::ctype<char>::_M_widen_init() const'
collect2: error: ld returned 1 exit status


The code file than I am using

Code:
#import <Foundation/Foundation.h> 
#include <iostream> 

int main(int argc, char *argv[]) 
{ 

   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 
   
   NSLog(@"hello"); 
   std::cout << "world" << std::endl;
   
   [pool drain]; 

return 0; 
}

I have hope anyone can help.

Best regards.
 

Attachments

  • Makefile.txt
    4.6 KB · Views: 226
Back
Top