sqrtf in a program

This seems really dumb, but I cannot for the life of me get this too work.

Small test program named skware.c:

#include <stdio.h>
#include <math.h>

int main (void) {
float val = 4.0;
printf(“Square of %g is %g\n” , val, sqrtf(val));
exit(o);
}

then on the command line type

cc skware.c

I get link errors. I’ve tried various incantations, played with -v,
yadayada and until I spec it explicitely, I cannot get around this.
Here’s what I have to do to get this thing to compile

qcc -o skware skware.c -l/x86/lib/libm.a

This seems like a BIG HAMMER approach to getting sqrt code to compile.
Anybody tell me what’s going on? This is on intel laptop, running the
free download version.


Travis Griggs (a.k.a. Lord of the Fries)
Member, Fravenic Skreiggser Software Collective
Key Technology
“It had better be a pretty good meeting to be better than no meeting at
all”-- Boyd K. Packer

Hi
I tried this out in Linux. It gives errors ld:linker error. You change the
options to be passed to
gcc skware.c -Wl,/usr/lib/libm.a
where the -Wl will pass the arguments to linker as it is in the command line.

Also change the exit(o) to exit(0)

cheers
n gowrisankar.


If all the world is a stage, where will the audience sit ?


Travis Griggs wrote:

This seems really dumb, but I cannot for the life of me get this too work.

Small test program named skware.c:

#include <stdio.h
#include <math.h

int main (void) {
float val = 4.0;
printf(“Square of %g is %g\n” , val, sqrtf(val));
exit(o);
}

then on the command line type

cc skware.c

I get link errors. I’ve tried various incantations, played with -v,
yadayada and until I spec it explicitely, I cannot get around this.
Here’s what I have to do to get this thing to compile

qcc -o skware skware.c -l/x86/lib/libm.a

This seems like a BIG HAMMER approach to getting sqrt code to compile.
Anybody tell me what’s going on? This is on intel laptop, running the
free download version.


Travis Griggs (a.k.a. Lord of the Fries)
Member, Fravenic Skreiggser Software Collective
Key Technology
“It had better be a pretty good meeting to be better than no meeting at
all”-- Boyd K. Packer

Previously, Travis Griggs wrote in comp.os.qnx:

then on the command line type

cc skware.c

Just use “make”. There should be a default make file on all modern
systems that does “the right thing”.

make skware

Should work, and product the expected results.

Cheers,
Camz.


Martin Zimmerman camz@passageway.com
Camz Software Enterprises www.passageway.com/camz/qnx/
QNX Programming & Consulting

Just do cc skware.c -lm
The math library is not linked to your program by default, that’s all.
Markus

“Travis Griggs” <tgriggs@keyww.com> wrote in message
news:3AD788A7.1090306@keyww.com

This seems really dumb, but I cannot for the life of me get this too work.

Small test program named skware.c:

#include <stdio.h
#include <math.h

int main (void) {
float val = 4.0;
printf(“Square of %g is %g\n” , val, sqrtf(val));
exit(o);
}

then on the command line type

cc skware.c

I get link errors. I’ve tried various incantations, played with -v,
yadayada and until I spec it explicitely, I cannot get around this.
Here’s what I have to do to get this thing to compile

qcc -o skware skware.c -l/x86/lib/libm.a

This seems like a BIG HAMMER approach to getting sqrt code to compile.
Anybody tell me what’s going on? This is on intel laptop, running the
free download version.


Travis Griggs (a.k.a. Lord of the Fries)
Member, Fravenic Skreiggser Software Collective
Key Technology
“It had better be a pretty good meeting to be better than no meeting at
all”-- Boyd K. Packer

Martin Zimmerman wrote:

Previously, Travis Griggs wrote in comp.os.qnx:

then on the command line type

cc skware.c


Just use “make”. There should be a default make file on all modern
systems that does “the right thing”.

make skware

Should work, and product the expected results.

It doesn’t work. It gives a link error because it doesn’t find the sqrtf
function anywhere. Doing a make -v skware shows that it is including
certain libraries, but not the math one.

\

Travis Griggs (a.k.a. Lord of the Fries)
Member, Fravenic Skreiggser Software Collective
Key Technology
“It had better be a pretty good meeting to be better than no meeting at
all”-- Boyd K. Packer

Markus Loffler wrote:

Just do cc skware.c -lm
The math library is not linked to your program by default, that’s all.
Markus

Yup, did the trick. I (once again) forgot about leaving the lib part off
(because the substiter puts it there). In reality I was trying to link
against liblibm. Duh. Thanks for humoring me on this one.

Travis Griggs (a.k.a. Lord of the Fries)
Member, Fravenic Skreiggser Software Collective
Key Technology
“It had better be a pretty good meeting to be better than no meeting at
all”-- Boyd K. Packer