hello world link error
|
|
Thread rating:  |
Jonathan L Cunningham - 20 Oct 2005 21:06 GMT Hi,
I'm trying to port some code to the Mac - but it's years since I last used a Mac, so I can't RTFM until I find out *which* manual to start with. Honestly, I expect to be doing a lot of reading/catching up - but I haven't a clue where to start. (Oh, I *do* have *lots* of experience programming on other platforms, including the old 68K Macs - but my experience of the current Macs is such that I even had to guess which app was the web browser!)
Anyway ...
I wrote a one line "Hello World" program, which would work on either Windows or Linux (or most other *nixes) and tried to compile it with $ cc hello.cc (presumably this is invoking some variant of the gnu compiler) and got a link error:
/usr/bin/ld: Undefined symbols: ___gxx_personality_v0
Googling on "personality" is not a lot of help. (And do I really need a "Hello World" with personality??)
Suggestions for where I start?
Eventually, I need to get the program I want to port using Xlib, so this is just the start of a looonng project - any hints as to what I'll need to read next also appreciated.
Thanks for any help - just compiling "Hello world" would feel like progress at this stage! :-)
Jonathan
 Signature I've been busy, and despite deleting a few hundred posts unread, I'm still keeping threads I've participated in - and my rasfc backlog is currently around 1200.
Mail to spam auto-deleted, use jlc1 instead. (That's jay ell cee one, if your font makes l and 1 look the same)
Reinder Verlinde - 20 Oct 2005 23:08 GMT > I wrote a one line "Hello World" program, which would work on > either Windows or Linux (or most other *nixes) and tried to [quoted text clipped - 7 lines] > > Googling on "personality" is not a lot of help. Why would you google on "personality"? If you really want to know what's wrong, Google on "___gxx_personality_v0", instead.
<http://www.google.com/search?q=%22___gxx_personality_v0%22+Mac+OS+X>
> Suggestions for where I start? You should at least browse 'UNIX development on Mac OS X' at <http://developer.apple.com/unix/>, if only for the section "Configuring and Running X11 Applications on Mac OS X"
Also, you really, really, should at least start out using XCode. It makes it trivial to build command-line programs (you want what XCode calls a "C++ tool" or a "Standard Tool")
These XCode project templates do not use make, but they do use gcc, and XCode can show you the command lines it uses to compile things.
Reinder
Jonathan L Cunningham - 21 Oct 2005 10:22 GMT >> I wrote a one line "Hello World" program, which would work on
>> /usr/bin/ld: Undefined symbols: >> ___gxx_personality_v0 [quoted text clipped - 3 lines] >Why would you google on "personality"? If you really want to know what's >wrong, Google on "___gxx_personality_v0", instead. I thbought I had - maybe I mistuped it :-). (I tried various other combinations too, but didn't feel like I was getting anywhere.)
><http://www.google.com/search?q=%22___gxx_personality_v0%22+Mac+OS+X> Looks like a lot of people ran into this.
>> Suggestions for where I start? > >You should at least browse 'UNIX development on Mac OS X' at ><http://developer.apple.com/unix/>, if only for the section "Configuring >and Running X11 Applications on Mac OS X" Thanks. That certainly sounds relevant.
>Also, you really, really, should at least start out using XCode. It >makes it trivial to build command-line programs (you want what XCode >calls a "C++ tool" or a "Standard Tool") I've started reading through the manual for this. I have installed the XCode stuff (presumably that's where the gcc came from?) I guess I better resign myself to some serious reading before I can do anything ... I'd have thought a command line "Hello World" would be simple.
>These XCode project templates do not use make, but they do use gcc, and >XCode can show you the command lines it uses to compile things. Thanks again. Even if I had found the documentation you mention by myself, it is reassuring to know that there isn's something *else* that I should read instead, or first.
Jonathan
 Signature I've been busy, and despite deleting a few hundred posts unread, I'm still keeping threads I've participated in - and my rasfc backlog is currently around 1200.
Mail to spam auto-deleted, use jlc1 instead. (That's jay ell cee one, if your font makes l and 1 look the same)
Patrick Machielse - 21 Oct 2005 01:26 GMT > I wrote a one line "Hello World" program, which would work on > either Windows or Linux (or most other *nixes) and tried to [quoted text clipped - 8 lines] > Googling on "personality" is not a lot of help. (And do I really > need a "Hello World" with personality??) try: g++ hello.cc
g++ sets a number of compile argurments for you.
cc hello.cc -lstdc++
may also work.
patrick
Jonathan L Cunningham - 21 Oct 2005 10:38 GMT >> I wrote a one line "Hello World" program, which would work on >> either Windows or Linux (or most other *nixes) and tried to [quoted text clipped - 17 lines] > >may also work. Ok, worth a try ...
I just tried it - and it didn't work (couldn't find the library). From some more googling (without typos this time - see my reply to Reinder) I'm guessing I need to set up the library search path ... but, I think it's best if I leave that until after I sit down and start wading through the xcode documentation.
I've also been looking at the manual entry for gcc. It's long! And there are Apple-specific extensions. There may be a compiler switch which would make it work - but, again, it's probably best if I ignore that, and concentrate on the xcode approach.
Unless anyone has different advice?
Jonathan
 Signature I've been busy, and despite deleting a few hundred posts unread, I'm still keeping threads I've participated in - and my rasfc backlog is currently around 1200.
Mail to spam auto-deleted, use jlc1 instead. (That's jay ell cee one, if your font makes l and 1 look the same)
vze35xda@verizon.net - 21 Oct 2005 10:47 GMT I did this:
#include <stdio.h>
int main(int argc,char **argv ) { printf("Hello world\n"); return( 0 ); } saved it in test.c then typed:
[Pandora:~] jim% gcc test.c [Pandora:~] jim% ./a.out Hello world
--jim
Jonathan L Cunningham - 23 Oct 2005 12:05 GMT >I did this: > [quoted text clipped - 10 lines] >[Pandora:~] jim% ./a.out >Hello world That's what I would have expected to happen! :-)
What's the value of: $ echo $LIBRARY_PATH
My LIBRARY_PATH is not set - (but I haven't had a chance to read the documentation yet - busy yesterday).
Jonathan
 Signature Mail to spam auto-deleted, use jlc1 instead. (That's jay ell cee one, if your font makes l and 1 look the same)
vze35xda@verizon.net - 23 Oct 2005 13:44 GMT (1) No $LIBRARY_PATH set (did printenv under csh and not there).
PATH=/usr/local/bin:/usr/local/aplus-fsf-4.18/bin:/Users/jim/bin:/bin:/sbin:/usr/bin:/usr/sbin SECURITYSESSIONID=419ab0 HOME=/Users/jim SHELL=/bin/tcsh USER=jim __CF_USER_TEXT_ENCODING=0x1F6:0:0 TERM_PROGRAM=Apple_Terminal TERM_PROGRAM_VERSION=133 TERM=vt100 LOGNAME=jim HOSTTYPE=powermac VENDOR=apple OSTYPE=darwin MACHTYPE=powerpc SHLVL=1 PWD=/Users/jim GROUP=jim HOST=Pandora.local ATREE=/usr/local/aplus-fsf-4.18 CVSROOT=/Users/Shared/cvsrep
(2) /usr/bin/gcc is a link /usr/bin/gcc-4.0 /usr/bin/gcc-4.0 seems to be binary executable of gcc not a script.
I have XCode 2.1 installed. If you have Tiger and have not gotten 2.1 run don't walk to the Apple Developers site and get it. 2.0 was rushed out and 2.1 is the REAL version 2 with a bunch of stuff fixed.
--jim
Patrick Machielse - 23 Oct 2005 16:58 GMT > I have XCode 2.1 installed. If you have Tiger and have not gotten 2.1 > run don't walk to the Apple Developers site and get it. 2.0 was rushed > out and 2.1 is the REAL version 2 with a bunch of stuff fixed. How about that 'preview' Xcode 2.2 version? (as if 2.1 isn't a 'preview') I'm using 2.1 too, but Xcode's UI seems soooo slow, f.i. when changing build styles.
Oh, and I can't link to a static lib located in my project, when there is a space in the path? (-L option is not quoted, in 2005!).
patrick
Eric Albert - 23 Oct 2005 19:40 GMT > Oh, and I can't link to a static lib located in my project, when there > is a space in the path? (-L option is not quoted, in 2005!). Have you filed a bug report on that?
-Eric
 Signature Eric Albert ejalbert@cs.stanford.edu http://outofcheese.org/
Patrick Machielse - 23 Oct 2005 20:09 GMT > > Oh, and I can't link to a static lib located in my project, when there > > is a space in the path? (-L option is not quoted, in 2005!). > > Have you filed a bug report on that? I just noticed it a few days ago. I have not tried Xcode 2.2 yet, so maybe it has been fixed. If I don't get around to that 800 MB donwload over the next few days, I'll file it anyway.
The 2.2 release notes say: "Quoting problems with build settings have been fixed."
So maybe it's taken care of. Although that statement could mean any number of things, when you look at it long enough.
patrick
Eric Albert - 24 Oct 2005 04:14 GMT > > > Oh, and I can't link to a static lib located in my project, when there > > > is a space in the path? (-L option is not quoted, in 2005!). [quoted text clipped - 4 lines] > maybe it has been fixed. If I don't get around to that 800 MB donwload > over the next few days, I'll file it anyway. In general, if you're already using the latest public release (as you are here), file first and update with new testing information later. The sooner Apple gets your bug report the better.
> The 2.2 release notes say: > "Quoting problems with build settings have been fixed." > > So maybe it's taken care of. Although that statement could mean any > number of things, when you look at it long enough. It may not refer to the specific build setting you're interested in. Or maybe it does. :) That's tough to know till you try it...or until you file a bug report and get a note back saying that this is fixed in 2.2.
-Eric
 Signature Eric Albert ejalbert@cs.stanford.edu http://outofcheese.org/
Patrick Machielse - 24 Oct 2005 09:30 GMT > > The 2.2 release notes say: > > "Quoting problems with build settings have been fixed." [quoted text clipped - 5 lines] > maybe it does. :) That's tough to know till you try it...or until you > file a bug report and get a note back saying that this is fixed in 2.2. Chances are excellent they'll tell me "it's a duplicate", in which case I'm none the wiser ;-). Let's hear what they have to say...
patrick
Ben Artin - 23 Oct 2005 20:54 GMT > How about that 'preview' Xcode 2.2 version? (as if 2.1 isn't a > 'preview') I'm using 2.1 too, but Xcode's UI seems soooo slow, f.i. when > changing build styles. I believe that's improved in 2.2.
> Oh, and I can't link to a static lib located in my project, when there > is a space in the path? (-L option is not quoted, in 2005!). Known and fixed in 2.2 AFAIK
So, yeah, get 2.2.
Ben
 Signature If this message helped you, consider buying an item from my wish list: <http://artins.org/ben/wishlist>
I changed my name: <http://periodic-kingdom.org/People/NameChange.php>
Patrick Machielse - 23 Oct 2005 22:42 GMT > > How about that 'preview' Xcode 2.2 version? (as if 2.1 isn't a > > 'preview') I'm using 2.1 too, but Xcode's UI seems soooo slow, f.i. when [quoted text clipped - 6 lines] > > Known and fixed in 2.2 AFAIK Thanks, that should be a noticable improvement. I'll give it a spin.
(that whole 'spaces in paths' thing must be one of unix worst features. I noticed even MPW was picky about it, and it has been popping up in different places in OS X.)
patrick
Jonathan L Cunningham - 24 Oct 2005 19:28 GMT >(1) No $LIBRARY_PATH set (did printenv under csh and not there). > >PATH=/usr/local/bin:/usr/local/aplus-fsf-4.18/bin:/Users/jim/bin:/bin:/sbin:/usr/bin:/usr/sbin (snip)
Completely different on my machine ...
>(2) /usr/bin/gcc is a link /usr/bin/gcc-4.0 > /usr/bin/gcc-4.0 seems to be binary executable of gcc not a script. Seems to be the same ...
>I have XCode 2.1 installed. If you have Tiger and have not gotten 2.1 >run don't walk to the Apple Developers site and get it. 2.0 was rushed >out and 2.1 is the REAL version 2 with a bunch of stuff fixed. You are right - I have got 2.0. I don't know if it will make any difference (to compiling direct from the command line with gcc) but I guess I need to learn this xcode thing anyway, and I may as well start with a good version ...
IIRC, it's always the odd-numbered versions which are best to use anyway - version 0 has bugs, version 1 they fix the bugs, version 2 they add clever new features which break the things in version 1, then version 3 they fix the new features ... :-)
<sigh> IDEs are a Good Thing, but it's a pain to have to keep learning the same things over and over and over again, because everybody always "improves" things, or does them slightly differently ... I must be getting old, or something, I used to *like* learning the 29th different way to provide the same features ... oh well, maybe there will actually be some *new* feature I haven't seen before in other IDEs :-).
(I notice that the default "empty" xcode C++ project is, in fact, a program to print "Hello World". Cute.)
Anyway, thanx again for everyone's help. I'll just go away now and alternate my time between beating my head against the wall and working through the documentation. Who knows? I may even end up liking it ...
Jonathan (getting far too cynical for his own good)
 Signature Mail to spam auto-deleted, use jlc1 instead. (That's jay ell cee one, if your font makes l and 1 look the same)
Jonathan L Cunningham - 24 Oct 2005 19:50 GMT >>> I wrote a one line "Hello World" program, which would work on >>> either Windows or Linux (or most other *nixes) and tried to >>> compile it with >>> $ cc hello.cc
>>try: >> g++ hello.cc >> >>g++ sets a number of compile argurments for you. I need a (virtual) slap with a wet fish ... you are quite right, using g++ instead of cc and it *does* compile without the link error.
It seems cc is a symbolic link to /usr/bin/gcc-4.0 and that g++ is a symbolic link to /usr/bin/g++-4.0.
Both files are 39524 bytes in size ... which suggests that they are identical except for the search paths they use??
Anyway, not asking for more help (I'm committed to plowing through the xcode stuff for now) but just thought I ought to apologise for not reading your OP carefully enough.
It's nice to know I *can* compile from the command line if I really want to. It would be even nicer to know what's going on! :-).
Jonathan
 Signature Mail to spam auto-deleted, use jlc1 instead. (That's jay ell cee one, if your font makes l and 1 look the same)
Patrick Machielse - 24 Oct 2005 20:50 GMT > >>try: > >> g++ hello.cc [quoted text clipped - 4 lines] > right, using g++ instead of cc and it *does* compile without > the link error. [SLAP!]
> It's nice to know I *can* compile from the command line if > I really want to. It would be even nicer to know what's > going on! :-). In that case, use the -v option! (I have more virtual fish lying around, just give the word...). GCC has about 1 milion options, and wading through the man pages isn't that convenient. I wonder if O'Reilly has a nice gcc book...
Ah, they don't, but the following seems like a nice stocking filler (might put it on my own wish list):
<http://www.amazon.com/gp/product/0954161793/102-5369748-1482538?v=glanc e&n=283155&n=507846&s=books&v=glance>
cheers,
patrick
Dave Seaman - 24 Oct 2005 22:47 GMT > I need a (virtual) slap with a wet fish ... you are quite > right, using g++ instead of cc and it *does* compile without > the link error.
> It seems cc is a symbolic link to /usr/bin/gcc-4.0 and > that g++ is a symbolic link to /usr/bin/g++-4.0.
> Both files are 39524 bytes in size ... which suggests that > they are identical except for the search paths they use?? The files are probably identical, but that does not mean the names are interchangeable. One could even be a direct link to the other, but it still makes a difference what name you use.
A program can look at the name it was originally called with (it's available as argv[0]) and can then do different things depending on whether it was called as "g++" or as "gcc", for example.
 Signature Dave Seaman Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling. <http://www.commoncouragepress.com/index.cfm?action=book&bookid=228>
jquadri - 26 Oct 2005 23:31 GMT There is a package called X11User.pkg found on the Tiger CD/DVD whic when installed will install X1
-- jquadr
Regards
macosx.com - The Answer to Mac Support - http://www.macosx.co
arydberg - 20 Nov 2005 22:15 GMT the following worked for me
#include <CoreServices/CoreServices.h> #include<stdio.h>
int main( int argc, char *argv[]) {
printf("junk2short\n");
return 0; }
> Hi,
> I'm trying to port some code to the Mac - but it's years since > I last used a Mac, so I can't RTFM until I find out *which* [quoted text clipped - 4 lines] > the current Macs is such that I even had to guess which app > was the web browser!)
> Anyway ...
> I wrote a one line "Hello World" program, which would work on > either Windows or Linux (or most other *nixes) and tried to > compile it with > $ cc hello.cc > (presumably this is invoking some variant of the gnu compiler) > and got a link error:
> /usr/bin/ld: Undefined symbols: > ___gxx_personality_v0
> Googling on "personality" is not a lot of help. (And do I really > need a "Hello World" with personality??)
> Suggestions for where I start?
> Eventually, I need to get the program I want to port using Xlib, > so this is just the start of a looonng project - any hints as to > what I'll need to read next also appreciated.
> Thanks for any help - just compiling "Hello world" would feel > like progress at this stage! :-)
> Jonathan
> -- > I've been busy, and despite deleting a few hundred posts unread, I'm > still keeping threads I've participated in - and my rasfc backlog is > currently around 1200.
> Mail to spam auto-deleted, use jlc1 instead. > (That's jay ell cee one, if your font makes l and 1 look the same) * posted via http://www.mymac.ws * please report abuse to http://xinbox.com/mymac
David Phillip Oster - 20 Nov 2005 22:19 GMT > $ cc hello.cc > (presumably this is invoking some variant of the gnu compiler) > and got a link error: > > /usr/bin/ld: Undefined symbols: > ___gxx_personality_v0 you are using the C compiler to compile C++. (A .cc extension is C++, not C.)
try opening a Terminal window and typing:
man gcc
for more info.
|
|
|