问题
I am trying to compile libpng for Windows Mobile 6, but i kep getting the following linker errors:
error LNK2019: unresolved external symbol __imp___iob_func referenced in function png_default_error libpng.lib
error LNK2019: unresolved external symbol __imp_abort referenced in function png_longjmp
Compilation is done with /MD option, same between my main project. zlib and libpng.
When /MT is used instead, there are still errors, but slightly different:
error LNK2019: unresolved external symbol __iob_func referenced in function png_default_error
error LNK2019: unresolved external symbol abort referenced in function png_longjmp
That brings several questions.
- What are
__imp___iob_func
and__imp_abort
? - Where are they implemented at? Alternatively, how can a reference to them be excluded?
My libpng compiler options:
/Od /I "..\lib\zlib-1.2.7" /I "..\lib\lpng1512" /D "_DEBUG" /D "_WIN32_WCE=0x502" /D "UNDER_CE" /D "WIN32_PLATFORM_PSPC" /D "WINCE" /D "DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "LIBPNG_EXPORTS" /D "ARM" /D "_ARM_" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /MDd /fp:fast /GR- /Fo"Windows Mobile 6 Professional SDK (ARMV4I)\Debug/" /Fd"Windows Mobile 6 Professional SDK (ARMV4I)\Debug/vc80.pdb" /W3 /nologo /c /Zi /TC /QMFPE-
librarian options:
/OUT:"Windows Mobile 6 Professional SDK (ARMV4I)\Debug\libpng.lib" /LIBPATH:"C:\Program Files\Windows Mobile 6 SDK\PocketPC\Lib\Armv4i" /NOLOGO /NODEFAULTLIB Coredll.lib /SUBSYSTEM:WINDOWSCE,5.02
My project (libpngStreamWrap) compiler options:
/Od /I "..\lib\lpng1512" /D "_DEBUG" /D "_WIN32_WCE=0x502" /D "UNDER_CE" /D "WIN32_PLATFORM_PSPC" /D "WINCE" /D "DEBUG" /D "_LIB" /D "ARM" /D "_ARM_" /D "_UNICODE" /D "UNICODE" /D "_WINDLL" /Gm /EHsc /MDd /fp:fast /GR- /Yu"stdafx.h" /Fp"Windows Mobile 6 Professional SDK (ARMV4I)\Debug/libpngStreamWrap.pch" /Fo"Windows Mobile 6 Professional SDK (ARMV4I)\Debug/" /Fd"Windows Mobile 6 Professional SDK (ARMV4I)\Debug/vc80.pdb" /W3 /nologo /c /Zi /TP
linker options:
/OUT:"Windows Mobile 6 Professional SDK (ARMV4I)\Debug\libpngStreamWrap.dll" /NOLOGO /DLL /MANIFEST:NO /NODEFAULTLIB:"oldnames.lib" /DYNAMICBASE /NXCOMPAT /ERRORREPORT:PROMPT coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib "..\libpng\windows mobile 6 professional sdk (armv4i)\debug\libpng.lib" "..\zlib\windows mobile 6 professional sdk (armv4i)\debug\zlib.lib" /SUBSYSTEM:WINDOWSCE,5.02 /VERBOSE:lib
回答1:
This has been discussed recently on the png-mng-implement list at sourceforge.net (topic libpng Visual Studio 2010 project):
After several long googling sessions it turned out that the reason was that libpng debug profile "Runtime library" setting is not set to "Multi-threaded Debug DLL" as excepted, but instead to "Multi-threaded DLL", which is the same profile as used in the release build.
This is a bug. It seems to be a result of a bad hand edit to the vcxproj project files - if the RuntimeLibrary element is removed or invalid it gets set to the default, which is /MD for a DLL.
It could be fixed in libpng 1.5, but that would be an API change and would break existing, working, libpng 1.5 projects. Consequently I think the best thing is to add a warning notice (probably in a separate file WARNING) to projects/vstudio pointing out the problem. It's easy for people to change the setting once they know it is potentially wrong.
来源:https://stackoverflow.com/questions/12933309/linker-error-unresolved-external-symbol-imp-iob-func-in-libpng-lib