1

So building off my last question, I'm receiving the error message:

LINK : fatal error LNK1194: cannot delay-load 'libxml2.dll' due to import of data symbol '__imp__xmlFree'; link without /DELAYLOAD:libxml2.dll

Which is, to my understanding, happening because libxml2 defines and undefines xmlFree:

globals.h
XMLPUBVAR xmlFreeFunc xmlFree;
#undef  xmlFree

...

xmlFreeFunc xmlFree;

#ifdef LIBXML_THREAD_ENABLED
XMLPUBFUN  xmlFreeFunc * XMLCALL __xmlFree(void);
#define xmlFree \
(*(__xmlFree()))
#else
XMLPUBVAR xmlFreeFunc xmlFree;
#endif

How do I fix my code so that I can delay-load libxml2 while still deallocating memory (if I comment out just the xmlFree line, my code works fine)?

Community
  • 1
  • 1
NobleUplift
  • 5,631
  • 8
  • 45
  • 87
  • Take a look at [this SO Q&A](http://stackoverflow.com/questions/5232912/how-to-use-delay-loading-with-a-dll-that-exports-c-classes) – LPs Jun 16 '16 at 06:58
  • Yes, comment it out if you don't need it. If you need it, make sure it has the right prototype. The prototype should be something like `void xmlFree(void);` --- If the prototype is not exactly the same as the one in DLL, then you get the link error. – Barmak Shemirani Jun 16 '16 at 11:59
  • Thanks for the reply @LPs. That was the first result I found in my search for a solution prior to posting, but it seems to be related to exporting the member data and functions of a class, which I can't do in pure C, right? – NobleUplift Jun 17 '16 at 16:32
  • Huh, I've failed to post this comment three times now: Hi @BarmakShemirani, glad to see you found my next question :) I tried to cast my parameter to void and it told me `error C2095: 'xmlFree' : actual parameter has type 'void' : parameter 1`. From what I can tell, it is the same. – NobleUplift Jun 18 '16 at 21:53
  • 1
    My earlier comment was useless. @LPs is probably on the right track. I download the library, I'll see if I can run it with /delay option. – Barmak Shemirani Jun 19 '16 at 17:29
  • Thanks! My code is essentially a combination of [this example from cURL](https://curl.haxx.se/libcurl/c/getinmemory.html), and [this tutorial from libxml2](http://xmlsoft.org/tutorial/ar01s05.html), if these help. – NobleUplift Jun 19 '16 at 19:26

0 Answers0