Problem using sin() in "QNX C Application Project"

bridged with qdn.public.qnxrtp.newuser
Post Reply
Daniel

Problem using sin() in "QNX C Application Project"

Post by Daniel » Mon Aug 11, 2003 11:45 am

Hi,

I'm using Momentics 6.2.1, with an QNX standard makefile in an QNX C
Application Project (not C++). Now I have a problem, using the math.h
command sin(). The compiler terminates with the error: undefined reference
to `_Sin'. (it's the same with cos(), sinh()...)
What can I do? Can anybody help me? I appended the source-code and the
compiler output.

Thanks,

Daniel



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

int main(int argc, char *argv[])
{
float sinValue;
sinValue = sin(2.1); //ERROR OCCURED: undefined reference to `_Sin'
printf("%f\n",sinValue);
return EXIT_SUCCESS;
}

/*
make CPULIST=x86 -k
make -j 1 -Cx86 -fMakefile
make[1]: Entering directory `/fs/hd1-dos/Projekte/Newsgroup/x86'
make -j 1 -Co -fMakefile ; make -j 1 -Co-g -fMakefile
make[2]: Entering directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o'
/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall -Wc,-Wno-parentheses -O -DNDEBUG -I.
-I/fs/hd1-dos/Projekte/Newsgroup/x86/o -I/fs/hd1-dos/Projekte/Newsgroup/x86
-I/fs/hd1-dos/Projekte/Newsgroup -I/usr/include
/fs/hd1-dos/Projekte/Newsgroup/Newsgroup.c
/bin/rm -f /fs/hd1-dos/Projekte/Newsgroup/x86/o/Newsgroup
/usr/bin/qcc -Vgcc_ntox86 -o/fs/hd1-dos/Projekte/Newsgroup/x86/o/Newsgroup
Newsgroup.o -L. -L/x86/lib -L/x86/usr/lib
Newsgroup.o: In function `main':
Newsgroup.o(.text+0x18): undefined reference to `_Sin'
cc: /usr/bin/ntox86-ld error 1
make[2]: *** [/fs/hd1-dos/Projekte/Newsgroup/x86/o/Newsgroup] Error 1
make[2]: Target `first' not remade because of errors.
make[2]: Leaving directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o'
make[2]: Entering directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o-g'
/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall -Wc,-Wno-parentheses -I. -I/fs/hd1-do
s/Projekte/Newsgroup/x86/o -I/fs/hd1-dos/Projekte/Newsgroup/x86/o-g -I/fs/hd
1-dos/Projekte/Newsgroup/x86 -I/fs/hd1-dos/Projekte/Newsgroup -I/usr/include
-g -DVARIANT_g /fs/hd1-dos/Projekte/Newsgroup/Newsgroup.c
/bin/rm -f /fs/hd1-dos/Projekte/Newsgroup/x86/o-g/Newsgroup_g
/usr/bin/qcc -Vgcc_ntox86 -o/fs/hd1-dos/Projekte/Newsgroup/x86/o-g/Newsgroup
_g Newsgroup.o -L. -L/x86/lib -L/x86/usr/lib -g
Newsgroup.o: In function `main':
/fs/hd1-dos/Projekte/Newsgroup/Newsgroup.c:8: undefined reference to `_Sin'
cc: /usr/bin/ntox86-ld error 1
make[2]: *** [/fs/hd1-dos/Projekte/Newsgroup/x86/o-g/Newsgroup_g] Error 1
make[2]: Target `first' not remade because of errors.
make[2]: Leaving directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o-g'
make[1]: *** [all] Error 2
make: *** [all] Error 2
make[1]: Leaving directory `/fs/hd1-dos/Projekte/Newsgroup/x86'
*/

Derek Leach

Re: Problem using sin() in "QNX C Application Project"

Post by Derek Leach » Mon Aug 11, 2003 2:41 pm

You need to link with libm.so ... someone else will have to indicate
how to achieve this with the IDE.

Regards.

Daniel <daniel-grimm@gmx.de> wrote:
Hi,

I'm using Momentics 6.2.1, with an QNX standard makefile in an QNX C
Application Project (not C++). Now I have a problem, using the math.h
command sin(). The compiler terminates with the error: undefined reference
to `_Sin'. (it's the same with cos(), sinh()...)
What can I do? Can anybody help me? I appended the source-code and the
compiler output.

Thanks,

Daniel
#include <stdlib.h
#include <stdio.h
#include <math.h

int main(int argc, char *argv[])
{
float sinValue;
sinValue = sin(2.1); //ERROR OCCURED: undefined reference to `_Sin'
printf("%f\n",sinValue);
return EXIT_SUCCESS;
}

/*
make CPULIST=x86 -k
make -j 1 -Cx86 -fMakefile
make[1]: Entering directory `/fs/hd1-dos/Projekte/Newsgroup/x86'
make -j 1 -Co -fMakefile ; make -j 1 -Co-g -fMakefile
make[2]: Entering directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o'
/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall -Wc,-Wno-parentheses -O -DNDEBUG -I.
-I/fs/hd1-dos/Projekte/Newsgroup/x86/o -I/fs/hd1-dos/Projekte/Newsgroup/x86
-I/fs/hd1-dos/Projekte/Newsgroup -I/usr/include
/fs/hd1-dos/Projekte/Newsgroup/Newsgroup.c
/bin/rm -f /fs/hd1-dos/Projekte/Newsgroup/x86/o/Newsgroup
/usr/bin/qcc -Vgcc_ntox86 -o/fs/hd1-dos/Projekte/Newsgroup/x86/o/Newsgroup
Newsgroup.o -L. -L/x86/lib -L/x86/usr/lib
Newsgroup.o: In function `main':
Newsgroup.o(.text+0x18): undefined reference to `_Sin'
cc: /usr/bin/ntox86-ld error 1
make[2]: *** [/fs/hd1-dos/Projekte/Newsgroup/x86/o/Newsgroup] Error 1
make[2]: Target `first' not remade because of errors.
make[2]: Leaving directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o'
make[2]: Entering directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o-g'
/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall -Wc,-Wno-parentheses -I. -I/fs/hd1-do
s/Projekte/Newsgroup/x86/o -I/fs/hd1-dos/Projekte/Newsgroup/x86/o-g -I/fs/hd
1-dos/Projekte/Newsgroup/x86 -I/fs/hd1-dos/Projekte/Newsgroup -I/usr/include
-g -DVARIANT_g /fs/hd1-dos/Projekte/Newsgroup/Newsgroup.c
/bin/rm -f /fs/hd1-dos/Projekte/Newsgroup/x86/o-g/Newsgroup_g
/usr/bin/qcc -Vgcc_ntox86 -o/fs/hd1-dos/Projekte/Newsgroup/x86/o-g/Newsgroup
_g Newsgroup.o -L. -L/x86/lib -L/x86/usr/lib -g
Newsgroup.o: In function `main':
/fs/hd1-dos/Projekte/Newsgroup/Newsgroup.c:8: undefined reference to `_Sin'
cc: /usr/bin/ntox86-ld error 1
make[2]: *** [/fs/hd1-dos/Projekte/Newsgroup/x86/o-g/Newsgroup_g] Error 1
make[2]: Target `first' not remade because of errors.
make[2]: Leaving directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o-g'
make[1]: *** [all] Error 2
make: *** [all] Error 2
make[1]: Leaving directory `/fs/hd1-dos/Projekte/Newsgroup/x86'
*/

Derek Leach

Re: Problem using sin() in "QNX C Application Project"

Post by Derek Leach » Mon Aug 11, 2003 2:42 pm

Derek Leach <dleach@dleach.qnx.com> wrote:
You need to link with libm.so ... someone else will have to indicate
how to achieve this with the IDE.

Regards.
If you are just using the common.mk stuff, you just need to
add:

LIBS=m
Daniel <daniel-grimm@gmx.de> wrote:
Hi,

I'm using Momentics 6.2.1, with an QNX standard makefile in an QNX C
Application Project (not C++). Now I have a problem, using the math.h
command sin(). The compiler terminates with the error: undefined reference
to `_Sin'. (it's the same with cos(), sinh()...)
What can I do? Can anybody help me? I appended the source-code and the
compiler output.

Thanks,

Daniel
#include <stdlib.h
#include <stdio.h
#include <math.h

int main(int argc, char *argv[])
{
float sinValue;
sinValue = sin(2.1); //ERROR OCCURED: undefined reference to `_Sin'
printf("%f\n",sinValue);
return EXIT_SUCCESS;
}

/*
make CPULIST=x86 -k
make -j 1 -Cx86 -fMakefile
make[1]: Entering directory `/fs/hd1-dos/Projekte/Newsgroup/x86'
make -j 1 -Co -fMakefile ; make -j 1 -Co-g -fMakefile
make[2]: Entering directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o'
/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall -Wc,-Wno-parentheses -O -DNDEBUG -I.
-I/fs/hd1-dos/Projekte/Newsgroup/x86/o -I/fs/hd1-dos/Projekte/Newsgroup/x86
-I/fs/hd1-dos/Projekte/Newsgroup -I/usr/include
/fs/hd1-dos/Projekte/Newsgroup/Newsgroup.c
/bin/rm -f /fs/hd1-dos/Projekte/Newsgroup/x86/o/Newsgroup
/usr/bin/qcc -Vgcc_ntox86 -o/fs/hd1-dos/Projekte/Newsgroup/x86/o/Newsgroup
Newsgroup.o -L. -L/x86/lib -L/x86/usr/lib
Newsgroup.o: In function `main':
Newsgroup.o(.text+0x18): undefined reference to `_Sin'
cc: /usr/bin/ntox86-ld error 1
make[2]: *** [/fs/hd1-dos/Projekte/Newsgroup/x86/o/Newsgroup] Error 1
make[2]: Target `first' not remade because of errors.
make[2]: Leaving directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o'
make[2]: Entering directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o-g'
/usr/bin/qcc -Vgcc_ntox86 -c -Wc,-Wall -Wc,-Wno-parentheses -I. -I/fs/hd1-do
s/Projekte/Newsgroup/x86/o -I/fs/hd1-dos/Projekte/Newsgroup/x86/o-g -I/fs/hd
1-dos/Projekte/Newsgroup/x86 -I/fs/hd1-dos/Projekte/Newsgroup -I/usr/include
-g -DVARIANT_g /fs/hd1-dos/Projekte/Newsgroup/Newsgroup.c
/bin/rm -f /fs/hd1-dos/Projekte/Newsgroup/x86/o-g/Newsgroup_g
/usr/bin/qcc -Vgcc_ntox86 -o/fs/hd1-dos/Projekte/Newsgroup/x86/o-g/Newsgroup
_g Newsgroup.o -L. -L/x86/lib -L/x86/usr/lib -g
Newsgroup.o: In function `main':
/fs/hd1-dos/Projekte/Newsgroup/Newsgroup.c:8: undefined reference to `_Sin'
cc: /usr/bin/ntox86-ld error 1
make[2]: *** [/fs/hd1-dos/Projekte/Newsgroup/x86/o-g/Newsgroup_g] Error 1
make[2]: Target `first' not remade because of errors.
make[2]: Leaving directory `/fs/hd1-dos/Projekte/Newsgroup/x86/o-g'
make[1]: *** [all] Error 2
make: *** [all] Error 2
make[1]: Leaving directory `/fs/hd1-dos/Projekte/Newsgroup/x86'
*/

Post Reply

Return to “qdn.public.qnxrtp.newuser”