exporting global operator+ function from DLL
-
if I want to export a global operator+ overload, like String operator+( const String& lhs, const int& rhs ); If I define this in a header, like
__declspec( dllexport ) String operator+( const String& lhs, const int& rhs );
and then implement this in a .cpp like
__declspec( dllexport ) String operator+( const String& lhs, const int& rhs )
{
return ....//rest of code omitted
}it compiles and builds the DLL fine. When I link to the dll from an exe, however, I get linker errors claiming "String operator+(..." isn't defined. What am I doing wrong? Is it not possible to have the implementation in a .cpp file? Thanks ! ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!
-
if I want to export a global operator+ overload, like String operator+( const String& lhs, const int& rhs ); If I define this in a header, like
__declspec( dllexport ) String operator+( const String& lhs, const int& rhs );
and then implement this in a .cpp like
__declspec( dllexport ) String operator+( const String& lhs, const int& rhs )
{
return ....//rest of code omitted
}it compiles and builds the DLL fine. When I link to the dll from an exe, however, I get linker errors claiming "String operator+(..." isn't defined. What am I doing wrong? Is it not possible to have the implementation in a .cpp file? Thanks ! ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!
May that be a problem of linker decoration, calling convention mismatch? Could using
extern "C"
solve your problem? :~
Fold With Us! Sie wollen mein Herz am rechten Fleck, doch Seh' ich dann nach unten weg Da schlägt es links
-
May that be a problem of linker decoration, calling convention mismatch? Could using
extern "C"
solve your problem? :~
Fold With Us! Sie wollen mein Herz am rechten Fleck, doch Seh' ich dann nach unten weg Da schlägt es links
Well I did try the "extern" keyword and that didn't make any difference. I'm really at a loss, and I guess I'll just have to try and put the impl in the header, which I really didn't want to have to do. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!
-
if I want to export a global operator+ overload, like String operator+( const String& lhs, const int& rhs ); If I define this in a header, like
__declspec( dllexport ) String operator+( const String& lhs, const int& rhs );
and then implement this in a .cpp like
__declspec( dllexport ) String operator+( const String& lhs, const int& rhs )
{
return ....//rest of code omitted
}it compiles and builds the DLL fine. When I link to the dll from an exe, however, I get linker errors claiming "String operator+(..." isn't defined. What am I doing wrong? Is it not possible to have the implementation in a .cpp file? Thanks ! ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!
-
Is the __declspec( dllexport ) hard coded in the header? If so you might try forward declaring the prototype with dllimport and try that. Thank You Bo Hunter
nope, I am using the traditional DLL_API kind of macro to shift it to import or export as the case may be. ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!