public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: <llewelly@dbritsch.dsl.xmission.com>
To: Claudiu BRASOVEAN <claudiu@rdscj.ro>
Cc: gcc-help@gcc.gnu.org
Subject: Re: need help
Date: Tue, 02 May 2000 10:00:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.21.0005021047330.29575-100000@dbritsch.dsl.xmission.com> (raw)
In-Reply-To: <390F02F0.F265AF25@rdscj.ro>

On Tue, 2 May 2000, Claudiu BRASOVEAN wrote:

> Hello....
> 
> Please excuse my childish question but I am new in the field and I am lost due to a very simple problem.

Please note that this list is for questions specific to gcc; your question
is a general C question that is not specific to gcc.


> Here is my problem:
> Main program:
> //main.c
> #include <stdio.h>
> #include "funct.h"
> 
>  void main(void){

Note: the return type of main() should always be 'int'.

> 
>  printf("Calling external function\n");
> 
>  foo(3);
> 
>  }
> ////////////////////
> //funct.h
> .....
> extern void foo(int);
> .....
> 
> ////////////////////
> //funct.c
> #include <stdio.h>
> #include "funct.h"
> ..........
> void foo(int x){printf("My parameter was:%d\n",x);};
> ..................
> Here is what i get from gcc (in fact is ld, isn't it?)
> 
> /tmp/ccahK6eu1.o: In function `main':
> /tmp/ccahK6eu1.o(.text+0x29): undefined reference to `foo'

Did you link funct.c with main.c ?

You need to do something like this:
$gcc funct.c main.c
$./a.out

or:

$gcc -c funct.c
$gcc -c main.c
$gcc funct.o main.o
$./a.out

If I compile and link it this way, your code works fine on my
  i686-linux-pc-gnu box with gcc 2.95.2

> 
> I do not understand why ld can not resolve symbol. 

ld can only resolve what it can see. If you do not pass it the name of the
  module, it will know to look in that module for functions.

> The compiling phase works fine
> I do have a SuSE 6.3 Linux distribution whith gcc-2.7.2.3-63 on it.
> 
> Thank you in advance.
>  
> 

  reply	other threads:[~2000-05-02 10:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-02  9:31 Claudiu BRASOVEAN
2000-05-02 10:00 ` llewelly [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-06-07 12:23 ASHA GOWDA
2007-06-07 14:53 ` Ian Lance Taylor
2005-03-21  8:54 arul kumaran
2005-02-08 12:19 Vijayalakshmic
2004-10-11 17:50 Need Help Sriharsha Vedurmudi
2004-10-13  7:16 ` Muthukumar Ratty
2003-10-01  5:23 need help cro
2003-10-01  6:10 ` Jeffrey Holle
2003-09-26 11:28 Eitan
2003-09-26 11:34 ` Jon Beniston
2003-07-08 16:16 V  Robert
2003-07-09 18:42 ` LLeweLLyn Reese
2002-08-19 10:07 Kitti Kittirutsunetorn
2002-08-19 12:02 ` bjorn rohde jensen
2002-08-19 14:56   ` Oscar Fuentes
2002-08-19 15:29     ` bjorn rohde jensen
2001-07-01 22:30 Need help Martin Kalen
2001-07-01 14:42 Jules FOSSO
2001-07-01 22:02 ` Parameshwari B.
1999-11-05 13:05 Need Help Powell, Sandy
1999-11-30 23:28 ` Powell, Sandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.21.0005021047330.29575-100000@dbritsch.dsl.xmission.com \
    --to=llewelly@dbritsch.dsl.xmission.com \
    --cc=claudiu@rdscj.ro \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).