* How to compile Objective-C code with GCC ?
@ 2013-01-16 17:39 niXman
2013-01-16 19:44 ` niXman
0 siblings, 1 reply; 10+ messages in thread
From: niXman @ 2013-01-16 17:39 UTC (permalink / raw)
To: gcc-help
Hi,
When I try to compile this code that I got form here([1]) with gcc:
#import <stdio.h>
#import <objc/Object.h>
@interface Hello: Object
- (void) init;
- (void) say;
@end
@implementation Hello
- (void) init {
[super init];
}
- (void) say {
printf("Hello, world!\n");
}
@end
int main() {
Hello *hello = [Hello new];
[hello say];
[hello free];
return 0;
}
Comand line: g++ -x objective-c++ test.mm -otest -lobjc
When code is compiled I get the following warnings:
test.mm:11:14: warning: ‘Object’ may not respond to ‘-init’ [enabled by default]
test.mm:11:14: warning: (Messages without a matching method signature
[enabled by default]
test.mm:11:14: warning: will be assumed to return ‘id’ and accept
[enabled by default]
test.mm:11:14: warning: ‘...’ as arguments.) [enabled by default]
test.mm: In function ‘int main()’:
test.mm:19:28: warning: ‘Hello’ may not respond to ‘+new’ [enabled by default]
test.mm:21:14: warning: ‘Hello’ may not respond to ‘-free’ [enabled by default]
If I try to run - I get SIGSEGV:
$> ./test
$> Segmentation fault
What I am doing wrongly?
Thanks.
[1] http://en.wikipedia.org/wiki/List_of_Hello_world_program_examples#Objective-C
--
Regards,
niXman
___________________________________________________
Dual-target(32 & 64-bit) MinGW compilers for 32 and 64-bit Windows:
http://sourceforge.net/projects/mingwbuilds/
___________________________________________________
Another online IDE: http://liveworkspace.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to compile Objective-C code with GCC ?
2013-01-16 17:39 How to compile Objective-C code with GCC ? niXman
@ 2013-01-16 19:44 ` niXman
2013-01-17 14:01 ` niXman
0 siblings, 1 reply; 10+ messages in thread
From: niXman @ 2013-01-16 19:44 UTC (permalink / raw)
To: gcc-help
Oops =)
linux-x86_64, gcc-4.7.2
--
Regards,
niXman
___________________________________________________
Dual-target(32 & 64-bit) MinGW compilers for 32 and 64-bit Windows:
http://sourceforge.net/projects/mingwbuilds/
___________________________________________________
Another online IDE: http://liveworkspace.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to compile Objective-C code with GCC ?
2013-01-16 19:44 ` niXman
@ 2013-01-17 14:01 ` niXman
2013-01-17 14:52 ` Tim Prince
0 siblings, 1 reply; 10+ messages in thread
From: niXman @ 2013-01-17 14:01 UTC (permalink / raw)
To: gcc-help
ping?
--
Regards,
niXman
___________________________________________________
Dual-target(32 & 64-bit) MinGW compilers for 32 and 64-bit Windows:
http://sourceforge.net/projects/mingwbuilds/
___________________________________________________
Another online IDE: http://liveworkspace.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to compile Objective-C code with GCC ?
2013-01-17 14:01 ` niXman
@ 2013-01-17 14:52 ` Tim Prince
2013-01-17 16:08 ` niXman
0 siblings, 1 reply; 10+ messages in thread
From: Tim Prince @ 2013-01-17 14:52 UTC (permalink / raw)
To: gcc-help
On 1/17/2013 5:14 AM, niXman wrote:
> ping?
>
>
Does your g++ -v show that objective-c++ was included in the build
options? If not, you would build your own copy with that option
included. Then you would use that front end, rather than expecting g++
to make the switch automatically.
Your messages have several spam filter baits; more people would see them
sooner if you would clean it up.
--
Tim Prince
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to compile Objective-C code with GCC ?
2013-01-17 14:52 ` Tim Prince
@ 2013-01-17 16:08 ` niXman
2013-01-18 21:22 ` niXman
0 siblings, 1 reply; 10+ messages in thread
From: niXman @ 2013-01-17 16:08 UTC (permalink / raw)
To: tprince, gcc-help
2013/1/17 Tim Prince <n8tm@aol.com>:
> Does your g++ -v show that objective-c++ was included in the build options?
Hi,
output:
nixman-home:~/v8-3# g++-4.7 -v
Using built-in specs.
COLLECT_GCC=g++-4.7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.7.2-2ubuntu1'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i686 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1)
Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to compile Objective-C code with GCC ?
2013-01-17 16:08 ` niXman
@ 2013-01-18 21:22 ` niXman
2013-01-19 2:47 ` Germán A. Arias
0 siblings, 1 reply; 10+ messages in thread
From: niXman @ 2013-01-18 21:22 UTC (permalink / raw)
To: gcc-help
ping?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to compile Objective-C code with GCC ?
2013-01-18 21:22 ` niXman
@ 2013-01-19 2:47 ` Germán A. Arias
0 siblings, 0 replies; 10+ messages in thread
From: Germán A. Arias @ 2013-01-19 2:47 UTC (permalink / raw)
To: niXman; +Cc: gcc-help
El sáb, 19-01-2013 a las 00:49 +0400, niXman escribió:
> ping?
Why not try gnustep?
www.gnustep.org
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to compile Objective-C code with GCC ?
2013-01-21 13:29 ` Alec Teal
@ 2013-01-21 15:32 ` Jonathan Wakely
0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Wakely @ 2013-01-21 15:32 UTC (permalink / raw)
To: Alec Teal; +Cc: Åke Forslund, gcc-help
On 21 January 2013 13:11, Alec Teal wrote:
> Could you forward me the original message (just joined the mailing list!)
It's in the archives:
http://gcc.gnu.org/ml/gcc-help/2013-01/msg00132.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to compile Objective-C code with GCC ?
2013-01-21 13:11 Åke Forslund
@ 2013-01-21 13:29 ` Alec Teal
2013-01-21 15:32 ` Jonathan Wakely
0 siblings, 1 reply; 10+ messages in thread
From: Alec Teal @ 2013-01-21 13:29 UTC (permalink / raw)
To: Åke Forslund; +Cc: gcc-help
Could you forward me the original message (just joined the mailing list!)
Surely though this is a job for search engines?
http://ubuntuforums.org/showthread.php?t=1064045 the first result.
http://gcc.gnu.org/onlinedocs/gcc/Objective_002dC.html this *will* have
some useful stuff.
The most useful one however will probably be:
http://en.wikibooks.org/wiki/Objective-C_Programming/Getting_Started
Enjoy
Alec
On 21/01/13 13:04, Åke Forslund wrote:
> I'm not an expert on Objective-C (in fact I haven't worked with it at all) so take my advice with a grain of salt. I think your hello world test is a bit over complicated, I tried this example (found on Swedish Wikipedia):
>
> #import <stdio.h>
> #import <objc/Object.h>
>
> @interface MyClass : Object {
> }
> - (void)world;
> @end
>
> @implementation MyClass
> - (void)world {
> printf("hello, World!\n");
> }
> @end
>
> int main() {
> id hello = [MyClass new];
> [hello world];
> return 0;
> }
>
> I compiled with gcc hello.m -lobjc -o hello
> This worked with no warnings and printed "Hello World!" as expected. (I must admit that my gcc is somewhat old 4.4.5)
>
> /Åke
>
> Åke Forslund
> Lasermax Roll Systems
> Tel: +46 (0) 372-25639
>
>
> -----Ursprungligt meddelande-----
> Från: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] För niXman
> Skickat: den 18 januari 2013 21:49
> Till: gcc-help@gcc.gnu.org
> Ämne: Re: How to compile Objective-C code with GCC ?
>
> ping?
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: How to compile Objective-C code with GCC ?
@ 2013-01-21 13:11 Åke Forslund
2013-01-21 13:29 ` Alec Teal
0 siblings, 1 reply; 10+ messages in thread
From: Åke Forslund @ 2013-01-21 13:11 UTC (permalink / raw)
To: gcc-help
I'm not an expert on Objective-C (in fact I haven't worked with it at all) so take my advice with a grain of salt. I think your hello world test is a bit over complicated, I tried this example (found on Swedish Wikipedia):
#import <stdio.h>
#import <objc/Object.h>
@interface MyClass : Object {
}
- (void)world;
@end
@implementation MyClass
- (void)world {
printf("hello, World!\n");
}
@end
int main() {
id hello = [MyClass new];
[hello world];
return 0;
}
I compiled with gcc hello.m -lobjc -o hello
This worked with no warnings and printed "Hello World!" as expected. (I must admit that my gcc is somewhat old 4.4.5)
/Åke
Åke Forslund
Lasermax Roll Systems
Tel: +46 (0) 372-25639
-----Ursprungligt meddelande-----
Från: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] För niXman
Skickat: den 18 januari 2013 21:49
Till: gcc-help@gcc.gnu.org
Ämne: Re: How to compile Objective-C code with GCC ?
ping?
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-01-21 15:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-16 17:39 How to compile Objective-C code with GCC ? niXman
2013-01-16 19:44 ` niXman
2013-01-17 14:01 ` niXman
2013-01-17 14:52 ` Tim Prince
2013-01-17 16:08 ` niXman
2013-01-18 21:22 ` niXman
2013-01-19 2:47 ` Germán A. Arias
2013-01-21 13:11 Åke Forslund
2013-01-21 13:29 ` Alec Teal
2013-01-21 15:32 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).