Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #97634

Re: Can't link a simple header file to an even more simple program

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: Can't link a simple header file to an even more simple program
Date 2016-11-28 13:39 +0000
Organization A noiseless patient Spider
Message-ID <87twariv0q.fsf@bsb.me.uk> (permalink)
References <e11bcfb9-8cb4-48c2-89ea-b2586ab4a5f1@googlegroups.com> <46815a4d-c447-4742-a930-fc714076bf61@googlegroups.com>

Show all headers | View raw


Alla _ <modelling.data@gmail.com> writes:

> <snip>
> I think I have found the solution: I have completely forgotten that I
> have to compile both .c files together
> by using gcc -o final_file functions.c main.c
> where functions.c contains functions for the header file, and main.c
> is the main program.

Or you can compile them separately:

  gcc -c main.c
  gcc -c functions.c

and then link the resulting .o files:

  gcc main.o functions.o

When programs get bigger, compiling just the bits you need can start to
pay off.

-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 02:41 -0800
  Re: Can't link a simple header file to an even more simple program BartC <bc@freeuk.com> - 2016-11-28 11:00 +0000
    Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 03:17 -0800
  Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 03:04 -0800
    Re: Can't link a simple header file to an even more simple program Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-28 13:39 +0000
  Re: Can't link a simple header file to an even more simple program Ike Naar <ike@iceland.freeshell.org> - 2016-11-28 12:48 +0000
    Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 08:05 -0800
      Re: Can't link a simple header file to an even more simple program Richard Heathfield <rjh@cpax.org.uk> - 2016-11-28 16:20 +0000
        Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 09:26 -0800
          Re: Can't link a simple header file to an even more simple program Richard Heathfield <rjh@cpax.org.uk> - 2016-11-28 17:56 +0000
            Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 10:04 -0800
              Re: Can't link a simple header file to an even more simple program Richard Heathfield <rjh@cpax.org.uk> - 2016-11-28 18:08 +0000
          Re: Can't link a simple header file to an even more simple program "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-28 12:57 -0500
            Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 10:10 -0800
              Re: Can't link a simple header file to an even more simple program Richard Heathfield <rjh@cpax.org.uk> - 2016-11-28 18:13 +0000
                Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 10:17 -0800
              Re: Can't link a simple header file to an even more simple program "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-28 13:19 -0500
                Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 10:22 -0800
            Re: Can't link a simple header file to an even more simple program David Thompson <dave.thompson2@verizon.net> - 2016-12-10 22:40 -0500
  Re: Can't link a simple header file to an even more simple program Richard Heathfield <rjh@cpax.org.uk> - 2016-11-28 12:55 +0000
    Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 08:45 -0800
      Re: Can't link a simple header file to an even more simple program Richard Heathfield <rjh@cpax.org.uk> - 2016-11-28 17:11 +0000
        Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 09:49 -0800
          Re: Can't link a simple header file to an even more simple program Richard Heathfield <rjh@cpax.org.uk> - 2016-11-28 18:00 +0000
            Re: Can't link a simple header file to an even more simple program Alla _ <modelling.data@gmail.com> - 2016-11-28 10:12 -0800

csiph-web