Results 1 to 10 of 10

Thread: _xmlFree linker trouble on win32

  1. #1
    Junior Member
    Join Date
    Nov 2006
    Posts
    6

    _xmlFree linker trouble on win32

    Hello all,

    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:

    msvc.link D:\kLab\output\demoAppWithModel\msvc\debug\link-static\demoAppWithModel.exe
    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
    unresolved externals

    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).

    cheers,
    g.

  2. #2
    Senior Member
    Join Date
    Aug 2005
    Location
    California
    Posts
    165
    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.

    -Andy

  3. #3
    Junior Member
    Join Date
    Nov 2006
    Posts
    6
    Andy,

    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?

    cheers,
    g.

  4. #4
    Senior Member
    Join Date
    Aug 2005
    Location
    California
    Posts
    165
    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.

  5. #5
    Junior Member
    Join Date
    Nov 2006
    Posts
    6
    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!!!

    cheers,
    g.

  6. #6
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    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

  7. #7
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    I just needed to remove "LIBXML_STATIC" from the preprocessor defines in LIBXMLPlugin.vcproj. Now everything links perfectly.

  8. #8
    Senior Member
    Join Date
    Aug 2005
    Location
    California
    Posts
    165
    Yup! That was it! Sorry I couldn't remember that earlier.

    -Andy

  9. #9
    deepone
    Guest
    Maybe this should be fixed in the release?

  10. #10
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •