[ITK-dev] Static link "error LNK2005: png_get_uint_31 already defined in png.lib", missing #define in itk_png_mangle.h?

Niels Dekker niels-xtk at xs4all.nl
Thu Apr 13 05:30:47 EDT 2017


For the record,

Our proposed fix, submitted by Floris, is at 
http://review.source.kitware.com/#/c/22282/

Kind regards, Niels

Francois Budin schreef op 2017-04-11 17:53:
> Thanks Niels. Let us know if you are running into any problem during
> that process.
> 
> Francois
> 
> On Tue, Apr 11, 2017 at 11:49 AM, Niels Dekker <niels-xtk at xs4all.nl>
> wrote:
> 
>> Thank you for your supportive replies, Matt and Francois. My
>> colleague Floris Berendsen and I will try to submit a patch for this
>> issue later this week.
>> 
>> Kind regards, Niels
>> 
>> Francois Budin wrote op 2017-04-11 15:35:
>> Hello Niels,
>> 
>> Thank you for reporting this issue. I looked into itk_png_mangle.h
>> and
>> indeed it looks like the function 'png_get_uint_31' should be
>> renamed
>> and is not.
>> Using this command [1], updated to your ITK version, you should be
>> able to see the the functions that are missing and need to be added
>> to
>> itk_png_mangle.h .
>> It would be great if you commit submit a patch to ITK to correct
>> this
>> issue.
>> You can find step by step instructions about how to contribute here
>> [2]. Feel free to reach out if you have any problem during this
>> process.
>> 
>> Thank you so much for your help,
>> Francois
>> 
>> [1] 
>> https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/ThirdParty/PNG/src/itkpng/itk_png_mangle.h#L13-L15
>> [2] https://itk.org/Wiki/ITK/Git/Develop
>> 
>> On Tue, Apr 11, 2017 at 9:11 AM, Niels Dekker wrote:
>> 
>> When trying build our project, which links statically to both ITK
>> and the Niftyreg library, my colleague Floris Berendsen and I
>> encountered the following link error:
>> 
>> itkpng-4.10.lib(pngrutil.obj) : error LNK2005: png_get_uint_31
>> already defined in png.lib(pngrutil.obj)
>> [...\SuperElastix-build\Testing\Unit\selxAnyFileIOTest.vcxproj]
>> ...\SuperElastix-build\bin\Debug\selxAnyFileIOTest.exe : fatal
>> error LNK1169: one or more multiply defined symbols found
>> [...\SuperElastix-build\Testing\Unit\selxAnyFileIOTest.vcxproj]
>> 
>> It appears that ITK and Niftyreg link to different versions of
>> libpng. Fortunately, ITK has done name mangling for most of the
>> libpng API functions, to avoid such linking errors, as we can see at
>> Modules/ThirdParty/PNG/src/itkpng/itk_png_mangle.h  Now it appears
>> that the function "png_get_uint_31" is also exported by libpng, but
>> that function is not mangled by ITK! We could locally fix our link
>> error by adding an extra #define to "itk_png_mangle.h":
>> 
>> #define png_get_uint_31 itk_png_get_uint_31
>> 
>> Do you guys agree that that would be an appropriate fix? Could such
>> a fix be added to the ITK code base?
>> 
>> Kind regards, Niels
>> 
>> PS Our project, SuperElastix, can be found at
>> https://github.com/SuperElastix/SuperElastix [3]  (We tried to build
>> the SuperBuild from the development branch.) The Nifty Reg library
>> is from https://cmiclab.cs.ucl.ac.uk/mmodat/niftyreg [4]


-- 
Niels Dekker
Scientific programmer
LKEB, Leiden University Medical Center, Netherlands


More information about the Insight-developers mailing list