Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: How to find the problem in the object file Date: Thu, 26 Jan 2017 08:29:11 -0800 Organization: None to speak of Lines: 50 Message-ID: References: <23ab01a2-5220-42cb-80b2-20a2b4a35d5c@googlegroups.com> <2beebc58-3f8f-46c6-bd10-e2ec3cf87906@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="c4bbf5deaa7fb5ee9d54a2c91785016f"; logging-data="29903"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cpCicyWlhf6wDRBFNmkrO" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:LtKif7G3oycejSHf2dQsYSqFQ5M= sha1:oxZ7Fk8hYhez2jvN2Px54QtQ4zs= Xref: csiph.com comp.lang.c:102470 BartC writes: > On 26/01/2017 14:20, Alla _ wrote: >> On Thursday, January 26, 2017 at 4:53:30 PM UTC+3, Richard Heathfield wrote: >>> On 26/01/17 13:14, Alla _ wrote: >>>> Hello! >>>> Please, help me with this unexpected issue: for the whole >>>> day I am trying to find the problem, and I can't. I have added >>>> some information to my program, tested it, it worked; but now >>>> when only one more function left to be "turned on" in this >>>> part of the program, I get an undefined symbol error from >>>> compiler. >>> >>> It was not the compiler, but the linker, that complained. This suggests >>> that you have a prototype for the function, and a call to the function, >>> but not the body of the function itself. >>> >>> Check your spelling of the function name at the point where the function >>> is defined. >>> >> Yes, the linker, sorry. >> And ... it can't get more embarrassing than this! just can't. >> A few hours, hours, of writing, re-writing the code, copying, etc. >> Yes, a tiny misspelling - how could I miss it?! > > Either your compiler is at fault or it's not set up properly to report > undeclared functions. And blame the language for allowing undeclared > functions to go undiagnosed by the compiler. Not necessarily. It's possible *and legal* to call a function that's been declared but not defined. For example, this source file / translation unit: void not_defined(void); int main(void) { not_defined(); } is perfectly valid, and a compiler has no reason to complain about it, but it won't *link* unless you provide the linker with something that defines the function. Normally the function declaration should be in an included header file, but that doesn't affect the issue. -- Keith Thompson (The_Other_Keith) kst-u@mib.org 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"