Compilation error with EXV_HAVE_XMP_TOOLKIT undefined
Added by Fulvio Senore almost 11 years ago
I have compiled exiv2lib with the symbol EXV_HAVE_XMP_TOOLKIT undefined to disable xmp support and I received compilation errors about line 423 of xmp.cpp. The file contains the following code:
#ifdef EXV_HAVE_XMP_TOOLKIT
void XmpParser::registerNs(const std::string& ns,
const std::string& prefix)
{
try {
initialize();
SXMPMeta::DeleteNamespace(ns.c_str());
SXMPMeta::RegisterNamespace(ns.c_str(), prefix.c_str());
}
catch (const XMP_Error& e) {
throw Error(40, e.GetID(), e.GetErrMsg());
}
} // XmpParser::registerNs
#else
bool XmpParser::registerNs(const std::string& /*ns*/,
const std::string& /*prefix*/)
{
initialize();
return true;
} // XmpParser::registerNs
#endif
so it looks like a change in the return type of the function has been forgotten after the "#else" line.
I changed the return value from bool to void, and I removed the return statement.
Now the library seems to work, but you will surely know the best way to fix this problem.
Fulvio Senore
P.S. I had to disable xmp support to remove the memory leaks that I reported about one year ago in this forum. I suspect that the problem lies in using an older version of expat, but I hope to find the time to check this in the future.
Replies (5)
RE: Compilation error with EXV_HAVE_XMP_TOOLKIT undefined - Added by Robin Mills almost 11 years ago
Fulvio
Happy New Year.
I think the fix is to change the #else ... #endif code by changing bool -> void and delete the line return true; The bool return signature seems inconsistent with the declaration in xmp.hpp
I don't believe expat has been upgraded and has been at 2.0.1 for quite some time (3+ years). Are you sure that it is expat that leaks, or could it be that XMP is leaking by failing to release expat resources in an appropriate manner?
Another subject. I tested Andreas' fixes yesterday for the 7.1 compiler stall. I've tested his fix with all the compilers (VS2003/5/8/10 msvc (32 bit) and msvc64(64 and 32 bit) and that seems to be fine now. Good Job, Andreas (as always). I submitted documentation and test changes to msvc.
Robin
RE: Compilation error with EXV_HAVE_XMP_TOOLKIT undefined - Added by Fulvio Senore almost 11 years ago
Robin,
Happy New Year to you too!
I am using wxWidgets which ships with expat 1.95.6: it is a very old version. I can use exiv2 with this version and I do not have linking errors, but those memory leaks with tiff files are so obvious that I cannot believe that nobody noticed them: Visual Studio is screaming at me when I close the program. As a reference, here is the older post:
http://dev.exiv2.org/boards/3/topics/339
Since the leaks are so obvious and they disappear when I disable xmp support I think that they are probably caused by using a very old version of expat. Maybe the older version has some different behaviours and XMP is failing to release resources as you suggested.
Probably the only way to find a solution would be to graft a newer version of expat in wxWidgets, but I am not sure of how I should do it.
Fulvio
RE: Compilation error with EXV_HAVE_XMP_TOOLKIT undefined - Added by Robin Mills almost 11 years ago
Gosh, Fulvio. The expat/wxWidgets/exiv2/xmpsdk/VS2003 memory management sounds like a build engineering/product integration matter. If you can avoid the leak by simply leaving EXV_HAVE_XMP_TOOLKIT undefined then that might be fine (provided you don't require XMP support). I'm happy to support you with issues involving code from the exiv2 library. On the other hand if this is a complex plot involving all manner of other libraries, you'll appreciate that you'll probably have to dig around with the Microsoft heap debug code to track down the causes.
RE: Compilation error with EXV_HAVE_XMP_TOOLKIT undefined - Added by Andreas Huggel almost 11 years ago
Thanks for reporting this blunder, Fulvio. It's fixed as bug #749.
As for the memory leaks, the only issue we sometimes hear is a memory leak if XmpParser::terminate() is not called. (The library calls initialize() automatically as needed.) Try this at the end of your program and see if the leaks go away.
If you can reproduce any memory leak with the exiv2 command line tool alone or a sample program that uses only the exiv2 library, please feedback details.
Andreas
RE: Compilation error with EXV_HAVE_XMP_TOOLKIT undefined - Added by Fulvio Senore almost 11 years ago
Thank you very much for pointing me to XmpParser::terminate()!
I added that call at program termination and now the memory leaks have disappeared.
It looks like some other code misses that call, probably because I have an older version of expat.
As usual, thank you for your work and for you quick help.
Fulvio