Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <kst-u@mib.org> |
| Newsgroups | comp.lang.c |
| Subject | Re: Xcode issues, doesn't compile files |
| Date | Sat, 25 Apr 2015 13:25:57 -0700 |
| Organization | None to speak of |
| Lines | 93 |
| Message-ID | <87sibogdka.fsf@kst-u.example.com> (permalink) |
| References | <f48581af-5efd-4b44-b982-d64c048adc2e@googlegroups.com> <03L_w.5955$Jg1.2546@uutiset.elisa.fi> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="9be37d943435275679235b07c7947eef"; logging-data="2448"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bQ3I1bSa3oxk4B7REfyao" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| Cancel-Lock | sha1:54Jz5U9kfWEGkZBUR6QzGsoqmGg= sha1:RyNXSBNqx3Erd0pTotk5NLwtX9Q= |
| Xref | csiph.com comp.lang.c:61100 |
Show key headers only | View raw
Hiidenkivi <hiidenkivi@nospam.no> writes:
> Alla _ kirjoitti:
>> I've written simple programs from Chapter 3 exercises (Programming in
>> C). A few people have tested them on their machines, and they work:
>> their Xcode compiles both programs. My one does not.
>>
>> Here is the first one.
>>
>> #include <math.h>
>> #include <stdio.h>
>>
>> int main (void)
>> {
>> float x = 2.55, y1, y2 ;
>> int i = 3, z = 2 ;
>> y1 = pow( x, i ) ;
>> y2 = pow( x, z ) ;
>> float result ;
>>
>> result = 3 * y1 - 5 * y2 + 6 ;
>> printf ("If x equals %f, then the given polynomial equals %f\n", x, result) ;
>>
>> return 0 ;
>> }
>>
>> Here is what I get after trying to compile:
>>
>> alla [11:41 AM]
>> 95-28-37-123:~ Alla$ gcc Prog3task6add.c -o Prog3task6add
>> Undefined symbols for architecture x86_64:
>> "_main", referenced from:
>> start in crt1.10.6.o
>> ld: symbol(s) not found for architecture x86_64
>> collect2: ld returned 1 exit status
>
> Try to compile this:
>
> #include <stdio.h>
> #include <math.h>
>
> int main (void)
> {
> float result;
> float x = (float) 2.55;
The cast is pointless. The double value of 2.55 will be implicitly
converted to float. You could write 2.55f if you really want to
avoid the conversion, but the result is going to be the same.
> float y1, y2;
> int i = 3, z = 2;
>
> y1 = (float) pow( x, i );
> y2 = (float) pow( x, z );
Again, the casts are pointless, merely specifying a conversion that
would be done implicitly. You could use powf() rather than pow()
-- or, probably better, change all the float variables to double.
(powf() wasn't introduced until C99, which might be relevant in
some environments.)
> result = 3 * y1 - 5 * y2 + 6;
> printf ("If x equals %f, then the given polynomial equals %f\n", x, result);
>
> return 0;
> }
>
> I just want to see if it makes any difference.
I can nearly guarantee that it won't. On my system, both programs
produce the same output. On the OP's system, the original program
doesn't produce any output at all, because it doesn't build.
The error message is:
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
which means that the C implementation itself is misconfigured.
Tweaking the code isn't going to change that. I expect the OP
would have exactly the same problem with *any* C program, including
the trivial:
int main(void){}
You need to read and understand the error message before you can figure
out how to fix the problem.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Xcode issues, doesn't compile files Alla _ <modelling.data@gmail.com> - 2015-04-23 02:53 -0700
Re: Xcode issues, doesn't compile files Bartc <bc@freeuk.com> - 2015-04-23 11:51 +0100
Re: Xcode issues, doesn't compile files Alla _ <modelling.data@gmail.com> - 2015-04-23 04:39 -0700
Re: Xcode issues, doesn't compile files Bartc <bc@freeuk.com> - 2015-04-23 13:19 +0100
Re: Xcode issues, doesn't compile files Alla _ <modelling.data@gmail.com> - 2015-04-23 07:20 -0700
Re: Xcode issues, doesn't compile files Bartc <bc@freeuk.com> - 2015-04-23 15:33 +0100
Re: Xcode issues, doesn't compile files Alla _ <modelling.data@gmail.com> - 2015-04-23 08:50 -0700
Re: Xcode issues, doesn't compile files Johann Klammer <klammerj@NOSPAM.a1.net> - 2015-04-23 20:31 +0200
Re: Xcode issues, doesn't compile files Robert Wessel <robertwessel2@yahoo.com> - 2015-04-23 14:25 -0500
Re: x86_64 Noob <root@127.0.0.1> - 2015-04-23 21:39 +0200
Re: Xcode issues, doesn't compile files G G <gdotone@gmail.com> - 2015-04-23 12:50 -0700
Re: Xcode issues, doesn't compile files Alla _ <modelling.data@gmail.com> - 2015-04-24 10:37 -0700
Re: Xcode issues, doesn't compile files G G <gdotone@gmail.com> - 2015-04-24 11:15 -0700
Re: Xcode issues, doesn't compile files Keith Thompson <kst-u@mib.org> - 2015-04-23 13:02 -0700
Re: Xcode issues, doesn't compile files Alla _ <modelling.data@gmail.com> - 2015-04-24 06:22 -0700
Re: Xcode issues, doesn't compile files G G <gdotone@gmail.com> - 2015-04-24 10:13 -0700
Re: Xcode issues, doesn't compile files Alla _ <modelling.data@gmail.com> - 2015-04-24 10:34 -0700
Re: Xcode issues, doesn't compile files Hiidenkivi <hiidenkivi@nospam.no> - 2015-04-25 14:41 +0300
Re: Xcode issues, doesn't compile files Hiidenkivi <hiidenkivi@nospam.no> - 2015-04-25 15:05 +0300
Re: Xcode issues, doesn't compile files Keith Thompson <kst-u@mib.org> - 2015-04-25 13:25 -0700
Re: Xcode issues, doesn't compile files Hiidenkivi <hiidenkivi@nospam.no> - 2015-05-03 23:29 +0300
Re: Xcode issues, doesn't compile files Keith Thompson <kst-u@mib.org> - 2015-05-03 13:46 -0700
Re: Xcode issues, doesn't compile files Hiidenkivi <hiidenkivi@nospam.no> - 2015-05-04 03:06 +0300
Re: Xcode issues, doesn't compile files Keith Thompson <kst-u@mib.org> - 2015-05-03 18:06 -0700
csiph-web