Although everything works fine under linux, on win XP, when I build the 1.4 debug version of collada_dom and then link the libs into my project I get this:
LINK : warning LNK4075: ignoring ‘/EDITANDCONTINUE’ due to ‘/INCREMENTAL:NO’ specification
MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib ‘msvcrt.lib’ conflicts with use of other lib
s; use /NODEFAULTLIB:library
collada_dae.lib(daeLIBXMLPlugin.obj) : error LNK2001: unresolved external symbol _xmlFree
D:\kLab\output\demoAppWithModel\msvc\debug\link-static\demoAppWithModel.exe : fatal error LNK1120: 1
I used to get loads of unresolved externals because I wasn’t linking in libxml2, but now I am (I’ve added it to “Additional Dependencies” of the LIBXMLPlugin project).
Also, both collada_dom and my project use /MD (and /MDd for debug).
Any ideas on how to get past this? (This is using VC++7).
Hmm, I’ve never seen someone put the libxml2 libs as additional dependencies for the LIBXMLPlugin project.
They should be linked in the app, not the libraries. I would try that first.
I know I have seen a similar link error (only _xmlfree) but I’m sorry I don’t recall exactly what the solution was.
I have tried your suggestion below (i.e. I’ve taken libxml2 out of the collada project, and just added it to my app), but I get the same link error…(which I guess makes sense).
Anyway…any other suggestions?
I remember this error too but it’s been a long time since I saw it…trying to remember the fix.
If your release build is working ok, it’s probably the first thing I mention below. Also check to make sure there aren’t any important preprocessor defines your release has and your debug doesn’t.
The problem may be related to the warning regarding msvcrt.lib. This is usually caused by parts of your program being built debug and parts being built for release (probably libxml in this case).
You can do the /NODEFAULTLIB thing as the warning suggests.
Also, it looks like the libxml headers define xmlFree differently based on whether things are built multithreaded or not so make sure your code is built with settings that match the libraries you’re linking to.
If you have code that directly or indirectly includes the libxml headers, you might also have to define WIN32 or LIBXML_STATIC (if you’re static linking).
Since I’m not sure which of these things is causing your problem, I’d suggest you try them one at a time rather than all at once.
Yay! Some progress…I’ll post this here in case it’s of any use to anyone else…
The shared (aka dynamic) version of the pre-build win32 libxml2 stuff is NOT working properly and appears to be missing xmlFree.
If you link against the static version (i.e. libxml2_a.lib instead of libxml2.lib) everything works fine!
Now both the linux and windows versions work fine!!!
Ouch, I’m being bitten by this problem now. I’m using Visual Studio 2003 and I changed dae.vcproj to link against libxml dynamically by linking against libxml2.lib instead of libxml2_a.lib. I’m doing this because I’m using libxml2 in some of my own DLLs and I’d like to avoid statically linking it into multiple places. Now I’m getting the “unresolved external symbol _xmlFree” error that g0l3m was seeing.
The funny thing is that I was able to throw together a test app that dynamically links against libxml2 (using the latest libxml2 from this site) without any errors. It’s only dae.vcproj that seems to generate an error.
Linking against libxml2_a.lib works fine. Andy if you’re able to remember what the solution to this error was please let us know
I just needed to remove “LIBXML_STATIC” from the preprocessor defines in LIBXMLPlugin.vcproj. Now everything links perfectly.
Yup! That was it! Sorry I couldn’t remember that earlier.
Maybe this should be fixed in the release?
The thing is, I don’t think this is really an error. If you’re linking against libxml statically you’re supposed to define LIBXML_STATIC. You can look in xmlexports.h in libxml to see how it’s used.
So if you want to switch to linking against libxml dynamically in the libxml plugin, you need to both change the lib you’re linking against and remove LIBXML_STATIC. I’ll make a note of this in the code or the release notes somewhere.