libPNG/libJPEG/zlib, linking problem (multiple definitions)


#1

I’m linking the Juce library with another library (FreeImage) which comes with its own copy of libPNG, libJPEG and ZLib.
For this reason I get (in Microsoft Visual Studio 2008) the “already defined”/“multiple definitions” linking errors.

I know that juce_Config.h contains some options:

 JUCE_INCLUDE_ZLIB_CODE
 JUCE_INCLUDE_PNGLIB_CODE
 JUCE_INCLUDE_JPEGLIB_CODE 

but in my case I prefer not to have “personal” copy of these libraries: for example I include FreeImage.h and link FreeImage.lib without having to deal with library versions. I was wondering if would be possible to add an option to “pack” Juce libPNG/libJPEG/zlib in a private “namespace”.
For example:

namespace pnglibNamespace {

//I want the symbols to be exported with namespace
//extern “C”
//{

and modify the “pnglib/png.h”

/*
#ifdef __cplusplus
extern “C” {
#endif
/

/

#ifdef __cplusplus
}
#endif
*/

The same would work also for libJPG and zlib.
Thanks,Giorgio.


#2

What version are you using? I changed this recently to improve the namespace isolation.


#3

I was using the latest release from dowload page:

http://sourceforge.net/project/showfiles.php?group_id=137492

I’ve just done a git.
The "extern “C” has been commented for zlb / libpng.
For JPEG I see:

namespace jpeglibNamespace
{
#if JUCE_INCLUDE_JPEGLIB_CODE
#if JUCE_MINGW
typedef unsigned char boolean;
#endif
extern “C”

I suppose this extern “C” implies the standard C export of jpeg methods.
Thanks.


#4

I changed the png and zlib to make sure all their symbols were entirely inside a private namespace… Maybe I didn’t do the same for jpeg… If not, I’ll take a look and see if it’s possible.