I have a .dll project with both __gc and __nogc classes, managed and
unmanaged code. In my unmanaged code, I want to call sqrt() from math.h.
So, I've #included <math.h> in the .cpp file, but I'm getting an unresolved
external symbol linker error. I have the same code in an .exe project and
it works fine. What the hell, Mel?
David Goon [MSFT] - 15 Dec 2003 17:51 GMT
Hi,
Given that you're facing a linker and not a compiler error, it should be
just choking on the name that the linker needs to resolve to an export from
a library. One possible problem could be the way the compiler is storing
the name for the linker. If you are compiling a .cpp file, it could be
possible that the compiler is decorating the function name (C++). Check by
looking at the linker error message and compare it with the output for the
function from the following:
dumpbin msvcrt.lib /exports (it should be _sqrt)
If you see something like ?sqrt@@YGE (I made this up) in the linker error,
then this is the problem.
To get around it, get the compiler to assume C style function names.
extern "C" {
#include <math.h>
}
Hope this provides some hints,
David Goon
Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm