This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using Math Functions


>>>>> "Tkil" == tkil  <tkil at scrye dot com> writes:

Tkil> Or, if you have multiple files:

Tkil>    gcc -c my_lib.c
Tkil>    gcc -c my_prog.c
Tkil>    gcc -o my_prog my_lib.o my_prog.o -lm
                        ^^^^^^^^ ^^^^^^^^^^

Open foot, insert mouth.  Assuming my_prog.c calls routines in
my_lib.c, it needs to be the other way around:

   gcc -o my_prog my_prog.o my_lib.o -lm

Tkil> Note that "-lm" should be after any of your object files that
Tkil> use functions from it, as symbols are resolved from
Tkil> left-to-right on the command line.

I even knew that.

t.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]