8

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
Cœur
  • 37,241
  • 25
  • 195
  • 267
Kira
  • 1,153
  • 4
  • 28
  • 63
  • 2
    Please post _all_ of the errors. I'll bet somewhere in the top is an error saying it can't find the correct library. Have you installed the 64-bit library? – Some programmer dude Mar 28 '13 at 09:17
  • No I didn't ^^'. I just tried to build tinyxml for x64 platforms but I couldn't. Here is the error I got when building tinyxml : `Error 1 error LNK1561: entry point must be defined path\tinyxml_2_6_2\tinyxml\LINK ` – Kira Mar 28 '13 at 09:23
  • What exactly are you compiling ? The dll, or xmltest ? And how ? – Synxis Apr 01 '13 at 12:51
  • I was trying to build xmltest and target x64 platforms. I've solved the issue by adding all .h and .cpp files that are related to tinyxml, to my project and now it works, thanks @Synxis :) – Kira Apr 01 '13 at 14:02
  • It doesn't seem like TinyXML has Windows-(in fact, MSVC)-specific dll export directives implemented. While Unix-like systems typically export symbols from dynamic libraries automatically, Windows requires to do it explicitly with `__declspec(dllexport)` directives. See the answer to question http://stackoverflow.com/questions/7651671/how-can-i-set-an-entrypoint-for-a-dll to start getting into this. NB: if the problem is really in exporting dll symbols, TinyXML shouldn't be buildable by Visual C++ even for 32-bit platforms. – Dmitry Apr 05 '13 at 14:38
  • *I meant, buildable as a shared library, just to clarify. – Dmitry Apr 05 '13 at 20:14

3 Answers3

6

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.

Kira
  • 1,153
  • 4
  • 28
  • 63
  • 2
    This does not actually use tinyxml shared library - it's just some ugly form of static linkage. Note that you will need to recompile your app if you want to use new version of tinyxml (but does it change so often anyway?) – j_kubik Apr 04 '13 at 20:42
3

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.

Community
  • 1
  • 1
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
3

The errors occurs when you define TIXML_USE_STL for the compilation of the library, but not for the sources that link to the library. The end result is that the library is compiled with different code from the sources using the library.

Patrick
  • 31
  • 1