www.digitalmars.com         C & C++   DMDScript  

c++.rtl - cos and sin missing when linking in opengl libraries

reply Damian Dixon <damian.dixon tenetdefence.com> writes:
Hi,

I was creating a small OpenGL test program at the weekend and found that
when linking in the the OpenGL libraries that sin and cos were missing.

The project was a standard console application, with no changes to the
compiler or linker settings (other then setting up include directories) and
adding the OpenGL libraries.

To fix the problem I had to do the following:

#ifdef __DMC__
#undef cos
#undef sin
extern "C" double cos(double a)
{
    return _inline_cos(a);
}

extern "C" double sin(double a)
{
    return _inline_sin(a);
}
#endif


This was on Windows 98 not using the OpenGL libraries supplied with the
compiler (which may be the problem).

By the way the link phase works on NT with the OpenGL libraries supplied
with the compiler.

I will do some further investigation and also give it a go with the new CD-ROM
when I have been able to order the CD-ROM (Takes awhile setting up an
international pay-pal account, so my order will not be able to
go in until the end of this week :< Looking foraward to a signed copy :>> ).

Regards
Damain
Jun 12 2001
next sibling parent Jan Knepper <jan smartsoft.cc> writes:
Damian,

Are you sure you're using the latest math,h?
Mine seems to be from 02/25/2001!

Jan



Damian Dixon wrote:

 Hi,

 I was creating a small OpenGL test program at the weekend and found that
 when linking in the the OpenGL libraries that sin and cos were missing.

 The project was a standard console application, with no changes to the
 compiler or linker settings (other then setting up include directories) and
 adding the OpenGL libraries.

 To fix the problem I had to do the following:

 #ifdef __DMC__
 #undef cos
 #undef sin
 extern "C" double cos(double a)
 {
     return _inline_cos(a);
 }

 extern "C" double sin(double a)
 {
     return _inline_sin(a);
 }
 #endif

 This was on Windows 98 not using the OpenGL libraries supplied with the
 compiler (which may be the problem).

 By the way the link phase works on NT with the OpenGL libraries supplied
 with the compiler.

 I will do some further investigation and also give it a go with the new CD-ROM
 when I have been able to order the CD-ROM (Takes awhile setting up an
 international pay-pal account, so my order will not be able to
 go in until the end of this week :< Looking foraward to a signed copy :>> ).

 Regards
 Damain

Jun 12 2001
prev sibling parent "Walter" <walter digitalmars.com> writes:
The compiler normally inlines sin() and cos(). To defeat that,  just #undef
them. What you did will work too. -Walter


Damian Dixon wrote in message <1103_992332827 dilbert>...
Hi,

I was creating a small OpenGL test program at the weekend and found that
when linking in the the OpenGL libraries that sin and cos were missing.

The project was a standard console application, with no changes to the
compiler or linker settings (other then setting up include directories) and
adding the OpenGL libraries.

To fix the problem I had to do the following:

#ifdef __DMC__
#undef cos
#undef sin
extern "C" double cos(double a)
{
    return _inline_cos(a);
}

extern "C" double sin(double a)
{
    return _inline_sin(a);
}
#endif


This was on Windows 98 not using the OpenGL libraries supplied with the
compiler (which may be the problem).

By the way the link phase works on NT with the OpenGL libraries supplied
with the compiler.

I will do some further investigation and also give it a go with the new

when I have been able to order the CD-ROM (Takes awhile setting up an
international pay-pal account, so my order will not be able to
go in until the end of this week :< Looking foraward to a signed copy

Regards
Damain

Jun 12 2001