Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tinyxml - Link errors when targeting x64 platform

Tags:

c++

tinyxml

I'm using tinyxml library for parsing XML files in my project. When I try to target x64 platforms I get LINKER errors and here is one fo them:

Error 4 error LNK2001: unresolved external symbol "private: static struct TiXmlString::Rep TiXmlString::nullrep_" (?nullrep_@TiXmlString@@0URep@1@A) ClassThatUsesTinyXML.obj

Update : I figured that the x64 version of tinyxml was not installed but when I tried to build the library for x64 platforms I got this error :

LNK1561: entry point must be defined
like image 276
Kira Avatar asked Mar 28 '13 09:03

Kira


2 Answers

Instead of building tinyxml for x64 platforms and then adding tinyxml.h and tinystr.h to the project, I just added all the library files including the .cpp files and now I can target x64 platforms, the library is, in fact, being built when I build the whole project.

like image 78
Kira Avatar answered Oct 08 '22 16:10

Kira


It does not look like tinyxml supports shared library builds out of the box.

Here are the steps that I followed to build a DLL from the tinyxml 2.6.2 sources:

  1. Open the provided SLN file, tinyxml.sln, in MS Visual Studio Express 2012 for Windows Desktop. Elect to convert the old project files to the new format when prompted.
  2. From "Solution Platforms", select "Configuration Manager..."
  3. From "Active solution platform:" select "<New...>"
  4. In "Type or select the new platform:" select "x64" if not already selected. Make sure to copy settings from the "Win32" configuration. Click OK. Click Close to exit the Configuration Manager.
  5. Right click on the tinyxml project in Solution Explorer. Select "Properties".
  6. For "Configuration:", select "All Configurations". Similarly, for "Platform:" select "All Platforms".
  7. On the Configuration Properties → General page, change "Configuration Type" to "Dynamic Library (.dll)". Change "Target Extension" to ".dll". Click OK to exit the tinyxml Properties Pages dialog.
  8. Select the "Release" configuration and "x64" platform.
  9. Right click on the tinyxml project in Solution Explorer again and select "Rebuild".

Within tinyxml_2_6_2\tinyxml\x64\Release you will find tinyxml.dll, but no import library (tinyxml.lib). This is because no symbols are exported. See How do I build an import library (.lib) AND a DLL in Visual C++?

If you want to go the shared library route, you will need to export the desired symbols via the MSVC-specific __declspec(dllexport) modifier. See Symbol Visibility in Windows.

like image 23
Daniel Trebbien Avatar answered Oct 08 '22 18:10

Daniel Trebbien