Mangled member function name different during dllimport - dllimport

I'm getting some unresolved externals when importing a DLL of a project (Project 1) in a .exe project (Project 2) using MSVC 2013 (it compiles fine in Mingw 4.8.1):
main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class chakra::Message * __thiscall chakra::PublisherSubscriberChannel::GetMessageA(unsigned __int64)" (__imp_?GetMessageA#PublisherSubscriberChannel#chakra##QAEPAVMessage#2#_K#Z) referenced in function "public: virtual void __thiscall Bar2::ProcessMessages(void)" (?ProcessMessages#Bar2##UAEXXZ)
test_wrap.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class chakra::Message * __thiscall chakra::PublisherSubscriberChannel::GetMessageA(unsigned __int64)" (__imp_?GetMessageA#PublisherSubscriberChannel#chakra##QAEPAVMessage#2#_K#Z)
The function GetMessage is a member function of class PublisherSubscriberChannel of namespace chakra in Project 1.
Examined the .exp and .dll file of Project 1 using dumpbin.exe /exports and found the function to be exported as ?GetMessage#PublisherSubscriberChannel#chakra##QAEPAVMessage#2#_K#Z whereas during importing it is looking for ?GetMessageA#PublisherSubscriberChannel#chakra##QAEPAVMessage#2#_K#Z as per the above error.
It happens only when I #include "Ogre.h" or any of the other Ogre headers in test_wrap.cxx file (which is a SWIG generated file).
Does anyone have any idea why the function name mismatch with the extra 'A'?

Related

Linking errors on VS2012 for CImageList and CBitmap apis

I am using mfc class CImageList in my project and using its APIs like Add(), Create() etc. It works fine with vs2010.
Now, I am upgrading the project to vs2012. It compiles and links fine for 32 bit platform, however throws below linking errors for 64 bit.
File1.obj : error LNK2019: unresolved external symbol imp_ImageList_ReplaceIcon referenced in function "public: int __cdecl CImageList::Add(struct HICON *)"
File2.obj : error LNK2019: unresolved external symbol __imp_ImageList_AddMasked referenced in function "public: int __cdecl CImageList::Add(class CBitmap *,unsigned long)"
Similarly, below error is thrown for calling CBitmap api.
File2.obj : error LNK2019: unresolved external symbol __imp_CreateMappedBitmap referenced in function "public: int __cdecl CBitmap::LoadMappedBitmap(unsigned int,unsigned int,struct _COLORMAP *,int)"
It seems that the libraries having these implementations might have been changed. However, I could not find any clue on how to resolve them.
Finally figured out the reason for this error.
ImageList_ReplaceIcon & CreateMappedBitmap symbols are present in comctl32.lib.
There was an older version comctl32.lib present in a path which was included in Additional Include Directories of my project settings.
So, instead of picking this lib from Microsoft SDK folder, the linker was picking from this directory and hence causing problems.

How to port Cocos2dx-wp8 from Application (.exe) to Dynamic Library (.dll)

I've been going at this problem for almost a week now and I still have 700+ errors. Definitely need all your help! Thanks.
Problem: Need to use
Cocos2dx for Windows Phone 8
in my C++/DirectX Visual Studio 2012 project that also uses C#/XAML UI.
Given: Cocos2dx-wp8 as an Application .exe project downloaded from http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Download
Solution:
Open my C#/XAML/DirectX Game1 solution .sln project in Visual Studio 2012.
Right click on solution in Solution Explorer. Add --> Existing Project...
Selected: \cocos2dx-0.13.0-wp8-0.8\HelloWorld\cocos2d.vcxproj and clicked open
Renamed the HelloWorld project to something else like "Cocos2dxWp8" and delete the HelloWorld Classes folder and all the Assets you don't want (like the squirrels and background images)
Click Properties --> Configuration Properties --> General --> Configuration Type --> from "Application (.exe) change to "Dynamic Library (.dll)"
Added new paths to Properties --> C/C++ --> Additional Include Directories -->
$(ProjectDir); $(IntermediateOutputPath); ..\cocos2dx\include;
..\cocos2dx; ..\cocos2dx\platform\third_party\win8_metro\libpng;
..\cocos2dx\platform\third_party\win8_metro\zlib;
..\cocos2dx\platform\third_party\win8_metro; ....\Cocos2dxWp8;
..\cocos2dx\platform\win8_metro;
..\cocos2dx\platform\third_party\win8_metro\freetype;
..\cocos2dx\platform\third_party\win8_metro\libjpeg;
..\CocosDenshion\include; ..\cocos2dx\platform; inc;
%(AdditionalIncludeDirectories)
Updated the paths in Properties --> Linker --> Input --> Additional Dependencies -->
..\cocos2dx\platform\third_party\win8_metro\libraries\x86\freetype.lib;
..\cocos2dx\platform\third_party\win8_metro\libraries\x86\zlib.lib;
..\cocos2dx\platform\third_party\win8_metro\libraries\x86\libjpeg.lib;
..\cocos2dx\platform\third_party\win8_metro\libraries\x86\libpng.lib;
dxguid.lib;xaudio2.lib;dxgi.lib;uuid.lib;d3d11.lib;%(AdditionalDependencies)
Updated paths in VC++ Directories:
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\freetype;
$(SolutionDir); $(ProjectDir)inc;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\CocosDenshion\include;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\zlib;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libraries;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libpng;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libjpeg;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\libxml2;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\third_party\win8_metro\;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform\win8_metro;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\platform;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx\include;
$(SolutionDir)GameWp8Dx\Cocos2dxWp8\cocos2dx; $(IncludePath)
From here, it builds successfully!
It outputs a .dll file but no .lib file, so...
In CCPlatformMacros.h, I enabled exporting classes to dll:
#define CC_DLL __declspec(dllexport)
Yah, .lib is being written to then...
715 Errors, 772 Warnings
Error 773 error LNK2001: unresolved external symbol "public: virtual
__thiscall cocos2d::CCKeypadHandler::~CCKeypadHandler(void)" (??1CCKeypadHandler#cocos2d#UAE#XZ)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCSpriteBatchNode.obj
Cocos2dXWp8Framework Error 774 error LNK2001: unresolved external
symbol "public: virtual __thiscall
cocos2d::CCKeypadHandler::~CCKeypadHandler(void)"
(??1CCKeypadHandler#cocos2d#UAE#XZ)
I've included the header file for where CCKeyHandler class is defined (inside CCKeypadDelegate.h) and CCSpriteBatchNode.h is also in the same include folder.
Class signatures look like this:
class CC_DLL CCKeypadHandler : public CCObject
class CC_DLL CCSpriteBatchNode : public CCNode, public CCTextureProtocol
Errors continue as is...
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\cocos2dorig.obj
Cocos2dXWp8Framework Error 775 error LNK2001: unresolved external
symbol "public: virtual __thiscall
cocos2d::CCKeypadHandler::~CCKeypadHandler(void)"
(??1CCKeypadHandler#cocos2d##UAE#XZ)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCImage_win8_metro.obj
Cocos2dXWp8Framework
...
Error 1482 error LNK2001: unresolved external symbol "public: virtual
void __thiscall cocos2d::CCTMXMapInfo::textHandler(void *,char const
*,int)" (?textHandler#CCTMXMapInfo#cocos2d#UAEXPAXPBDH#Z) F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCDrawingPrimitives.obj
Cocos2dXWp8Framework Error 1483 error LNK2001: unresolved external
symbol "public: virtual void __thiscall
cocos2d::CCTMXMapInfo::textHandler(void *,char const *,int)"
(?textHandler#CCTMXMapInfo#cocos2d#UAEXPAXPBDH#Z)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\cocos2d.obj
Cocos2dXWp8Framework Error 1484 error LNK2019: unresolved external
symbol "public: virtual __thiscall
cocos2d::CCKeypadDispatcher::~CCKeypadDispatcher(void)"
(??1CCKeypadDispatcher#cocos2d#UAE#XZ) referenced in function "public:
virtual void * __thiscall cocos2d::CCKeypadDispatcher::`vector
deleting destructor'(unsigned int)"
(??_ECCKeypadDispatcher#cocos2d#UAEPAXI#Z)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCDirector.obj
Cocos2dXWp8Framework Error 1485 error LNK2001: unresolved external
symbol "public: virtual __thiscall
cocos2d::CCKeypadDispatcher::~CCKeypadDispatcher(void)"
(??1CCKeypadDispatcher#cocos2d#UAE#XZ)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCLayer.obj
Cocos2dXWp8Framework Error 1486 error LNK2001: unresolved external
symbol "public: virtual __thiscall
cocos2d::CCKeypadDispatcher::~CCKeypadDispatcher(void)"
(??1CCKeypadDispatcher#cocos2d#UAE#XZ)
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\CCEGLView_win8_metro.obj
Cocos2dXWp8Framework Error 1487 error LNK1120: 48 unresolved externals
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\Win32\Debug\cocos2d\Cocos2dXWp8Framework.dll
Cocos2dXWp8Framework
Solution / Project paths:
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx.sln
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\GameWp8Dx\GameWp8Dx.csproj
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\GameWp8DxComponent\GameWp8DxComponent.vcxproj
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\cocos2d.vcxproj
Cocos2d Include files:
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\cocos2dx\include
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\cocos2dx\platform
Object files built here:
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\HelloWorld\Win32\Debug*.obj
.dll / .lib built here:
F:\src\WindowsPhone\GameWp8Dx\GameWp8Dx\Cocos2dxWp8\Win32\Debug\cocos2d
Sorry for the long post, but I hope that's enough details to get this question going. Thanks.
I created a new dynamic library project, then copied over the files. I got the .dll and .lib built, but didn't work for an ARM CPU build target (used for devices). Also, the setup for the Cocos2dx director and scene layer doesn't seem to work well with an existing C#/XAML with DirectX project that renders onto a DrawingSurfaceBackgroundGrid control. So at the end, I didn't end up using Cocos2dx in my mixed project setup.
If anyone else got better suggestions, please let me know. Thanks.
ON TOPIC:
Perhaps you did not properly set project dependencies inside your SLN ?
I got Cocos2d to partially work with XAML+D3d Interop, but because calls go back and forward from the XAMLComponent DLL to the Cocos2d DLL, it seems to be messing up pointers and memory.
Right now I tried to move all Cocos2D source files to my D3Dcomponent project, but something is terribly wrong, and I get a weird kernelbase.dll first chance exception.
OFF TOPIC:
I was also trying to put a game done over cocos2d-x on an XAML+D3D Interop project, and used the template that comes with Visual Studio 2012. However, only a smudgy background was displayed. I was using DrawingSurfaceBackgroundGrid, and found out later that on Windows Phone 8, it has some issues related to Z-order. I ended up replacing it with DrawingSurface.

Unresolved externals while creating static lib which uses PugiXml

I'm writing a static library that uses PugiXml for xml parsing. Here is the linker output from Visual Studio 2010 (I've replaced the symbol with ellipses for readability):
error LNK2019: unresolved external symbol "public: __thiscall Dae_Library<class Dae_Geometry>::Dae_Library<class Dae_Geometry>(void)" (...) referenced in function "private: bool __thiscall Dae_Doc::ParseDae(void)" (...)
error LNK2019: ^ "public: wchar_t const * __thiscall pugi::xml_node::name(void)const " (...) referenced in function "private: bool __thiscall Dae_Doc::ParseDae(void)" (...)
error LNK2001: ^ "public: wchar_t const * __thiscall pugi::xml_node::name(void)const " (...)
error LNK2019: ^ "public: wchar_t const * __thiscall pugi::xml_attribute::value(void)const " (...) referenced in function "public: void __thiscall Dae_Node::SetXmlNode(class pugi::xml_node &)" (...)
error LNK2019: ^ "public: class pugi::xml_attribute __thiscall pugi::xml_node::attribute(wchar_t const *)const " (...) referenced in function "public: void __thiscall Dae_Node::SetXmlNode(class pugi::xml_node &)" (...)
Things I've tried:
Explicitly instantiating my template class.
Linking PugiXml source in with test project (it is currently with the static lib I'm building)
Building PugiXml as a static lib and referencing it in both my lib project and the test project
Writing do nothing functions in place of my pure virtual functions.
Providing default constructors that do not reference pugixml at all
This has been driving me nuts for the past two days and I really have no idea what to do. If anyone can give me any direction at all I would greatly appreciate it!
Edit:
It's worth noting that creating a simple static library that uses pugixml compiles and tests fine, so maybe there is something wrong with how I've written my templates and classes?
From the error messages it looks like you're setting PUGIXML_WCHAR_MODE inconsistently.
It's likely that you're setting it in your project configuration, and using one of the bundled vcproj files from scripts/ folder inside pugixml distribution as is.
This define controls the type of character used in pugixml (char or wchar_t); you have to set it in the same way for both pugixml.cpp and the code that uses pugixml - it is recommended to either set it in pugiconfig.hpp, or to make sure that it's on in all projects that have source files that include pugixml.hpp. In your case, if you don't want to modify pugiconfig.hpp, you'll have to change the vcproj for pugixml static library.

mysql++ problem with linking

I have problem, I use mysql++ 3.1.0:
after building mysql++.sln in debug and release mode for vc2008, and using instal.hta then
adding dirrectoires in vc++ directories to lib and include folders,
and adding in project properties-> Linker-> General Additional Library Directories directory to lib folder which have mysqlpp.dll, mydqlpp.lib, mysqlpp_d.dll, mydqlpp_d.lib.
These code:
#include <iostream>
#include <mysql++.h>
using namespace std;
using namespace mysqlpp;
int main()
{
Connection con;
return 0;
}
gets these errors:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall mysqlpp::Connection::~Connection(void)" (__imp_??1Connection#mysqlpp##UAE#XZ) referenced in function _main
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall mysqlpp::Connection::Connection(bool)" (__imp_??0Connection#mysqlpp##QAE#_N#Z) referenced in function _main
in visual studio 2008. How can I fix this?
I think you missed the last step here, which adds several libraries to your project: the MySQL++ DLL import library, the MySQL C API library, and the Winsock DLL import library.

Problems linking ACE in VC++

I've built ACE.dll and ACE.lib of the ACE library. But when I link it to my program, I get several errors like
Error 2 error LNK2019: unresolved
external symbol "void * __cdecl
ACE_OS::memcpy(void *,void const
*,unsigned int)" (?memcpy#ACE_OS##YAPAXPAXPBXI#Z)
referenced in function "public: void
__thiscall ACE_String_Base::set(char const
*,unsigned int,bool)" (?set#?$ACE_String_Base#D##QAEXPBDI_N#Z)
client_handler.obj Server
Error 3 error LNK2001: unresolved
external symbol "void * __cdecl
ACE_OS::memcpy(void *,void const
*,unsigned int)" (?memcpy#ACE_OS##YAPAXPAXPBXI#Z)
Server.obj
I've set include paths,lib paths, lib dependencies etc etc. I dont know what I'm missing :(
The linker is unable to find a definition for ACE_OS::memcpy. Check the documentation and see if you need to provide a suitable definition or not (or if there is one in the sample, if any samples are present at all).
This could also be because you've not defined a platform specific macro that would enable the default definition of this function. Please check the readme.

Resources