Martin B.
2010-03-22 12:06:45 UTC
Hi all!
We have some issues with unresolved external tokens when
compiling/linking a Mixed C++ Project ( /clr).
Currently we're trying to figure out if the name mangling scheme gets
messed up somehow, but I have a hard time making sense of the
undecorated names we see. I have a little test-setup consisting of a DLL
and and EXE both built with /clr. I get a similar error here.
DLL-Project:
------------
lib.h:
------
#ifdef LIB_EXPORTS
#define LIB_API __declspec(dllexport)
#else
#define LIB_API __declspec(dllimport)
#endif
LIB_API int __cdecl test_fn(void);
lib.cpp:
--------
LIB_API int __cdecl test_fn(void)
{
return 42;
}
EXE-Project:
------------
main.cpp
--------
#include "lib.h"
void f()
{
int ans = test_fn();
}
-----------
The DLL compiles+links without error.
When linking the EXE project I get the following error:
2>main.obj : error LNK2001: unresolved external symbol "int __cdecl
test_fn(void)" (?test_fn@@$$FYAHXZ)
Looking at the generated lib.dll with dependency walker, I see the
following exported symbols:
?test_fn@@YAHXZ
When I disable /clr on the projects, it copiles and links just fine -
the export symbol table for lib.dll show the same function entry.
Any ideas what's going wrong here? What's with that "$$F" ?
cheers,
Martin
We have some issues with unresolved external tokens when
compiling/linking a Mixed C++ Project ( /clr).
Currently we're trying to figure out if the name mangling scheme gets
messed up somehow, but I have a hard time making sense of the
undecorated names we see. I have a little test-setup consisting of a DLL
and and EXE both built with /clr. I get a similar error here.
DLL-Project:
------------
lib.h:
------
#ifdef LIB_EXPORTS
#define LIB_API __declspec(dllexport)
#else
#define LIB_API __declspec(dllimport)
#endif
LIB_API int __cdecl test_fn(void);
lib.cpp:
--------
LIB_API int __cdecl test_fn(void)
{
return 42;
}
EXE-Project:
------------
main.cpp
--------
#include "lib.h"
void f()
{
int ans = test_fn();
}
-----------
The DLL compiles+links without error.
When linking the EXE project I get the following error:
2>main.obj : error LNK2001: unresolved external symbol "int __cdecl
test_fn(void)" (?test_fn@@$$FYAHXZ)
Looking at the generated lib.dll with dependency walker, I see the
following exported symbols:
?test_fn@@YAHXZ
When I disable /clr on the projects, it copiles and links just fine -
the export symbol table for lib.dll show the same function entry.
Any ideas what's going wrong here? What's with that "$$F" ?
cheers,
Martin