Need help to compile LibPng into static lib

Everything else that doesn't fall into one of the other PB categories.
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Re: Need help to compile LibPng into static lib

Post by jack »

in case you want the project solutions here they are, the binaries are also included
libpng32.7z
libpng64.7z
if you want to rebuild the projects, I suggest that you extract the archives to C:\
not sure it would work in other locations due to the absolute paths to zlib
[edit]
only the 64-bit version works at the moment
Last edited by jack on Sun Nov 17, 2019 6:18 am, edited 2 times in total.
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Re: Need help to compile LibPng into static lib

Post by jack »

Denis wrote:
With following i now get "unable to find symbol _CRC32" witch comes from Zlib config i I think.
Denis, you need to import zlib as well, something like

Code: Select all

import "zlib.lib"
endimport
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Re: Need help to compile LibPng into static lib

Post by jack »

the 64-bit version work ok, but the 32-bit version gives

POLINK: error: Unresolved external symbol '__imp___gmtime64'.

I have searched the web for hours, with no luck
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Need help to compile LibPng into static lib

Post by Danilo »

jack wrote:I have searched the web for hours, with no luck
Google gives many results when searching for "__imp_ gmtime64" (there is a space between the words!): https://www.google.com/search?q=__imp_+ ... _+gmtime64

I checked the first 4 answers and found some things you could try, for example use /NODEFAULTLIBS or /NODEFAULTLIB:MSVCRT compiler switch.
"__imp" is a label for a DLL import. One answer said you could fake it by writing a function with the name "__imp_gmtime64()".
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Re: Need help to compile LibPng into static lib

Post by jack »

thanks Danilo, I will try your suggestions, in the meantime I have solved the problem by another way, the function in question is in the ucrtbase.dll, I tried to make an importlib with the 32-bit version of polib but it would give some kind of error, but the 64-bit version of polib produced the lib with no problems, and PB 32-bit finally compiles and runs the libpng example

Code: Select all

Import "ucrtbase.lib"
EndImport
Importc "zlib.lib"
EndImport
Importc "libpng16_static.lib"
  png_access_version_number()
EndImport

Debug png_access_version_number()
I had to compile libpng with "No Enhanced Instructions (/arch:IA32)" so I will re-upload the 32-bit version
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Re: Need help to compile LibPng into static lib

Post by jack »

I tried passing the suggested compiler switches to VS but it reported 'ignoring unrecognized compiler switch' (paraphrasing)
lack of sleep is impeding clear thinking, but one would think that there should be a way to link-in that dependency into libpng
I re-uploaded the 32-bit solution, but you now have to make an importlib of ucrtbase.dll
polib ucrtbase.dll /machine:x86 /out:ucrtbase.lib
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: Need help to compile LibPng into static lib

Post by Denis »

jack,
i will try until I succeed.
At the same time, I will start using libpng from your files.

Thanks again for your help!
I hope that other coders can try with other imports to extend the scope of PB possibilities.
jack wrote: if you want to rebuild the projects, I suggest that you extract the archives to C:\
not sure it would work in other locations due to the absolute paths to zlib
Ok.

You can try to set up zlib.props from file readme.txt
between tag <ZLibSrcDir></ZLibSrcDir> to give libpng zlib folder
Initial preparations
--------------------
You must enter some information in zlib.props before attempting to
build with this 'solution'. Please read and edit zlib.props first.
You will probably not be familiar with the contents of zlib.props -
do not worry, it is mostly harmless.

This is all you need to do to build the 'release' and 'release library'
configurations.
A+
Denis
Justin
Addict
Addict
Posts: 830
Joined: Sat Apr 26, 2003 2:49 pm

Re: Need help to compile LibPng into static lib

Post by Justin »

Hi jack it works, thanks for your enormous help.
I'll try to learn from this and try another libs.
Denis
Enthusiast
Enthusiast
Posts: 704
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: Need help to compile LibPng into static lib

Post by Denis »

jack wrote:the 64-bit version work ok, but the 32-bit version gives

POLINK: error: Unresolved external symbol '__imp___gmtime64'.

I have searched the web for hours, with no luck
jack,
I don't know if it will rocks, msvcrt.lib (..\PureLibraries\Windows\Libraries) has this function gmtime64.
(a look with notepad++ to find file)
You can try to link it (... i'm note a C coder at all nor a specialist of VS :mrgreen: ).
A+
Denis
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Re: Need help to compile LibPng into static lib

Post by jack »

Denis wrote: jack,
I don't know if it will rocks, msvcrt.lib (..\PureLibraries\Windows\Libraries) has this function gmtime64.
the msvcrt.lib in the 64-bit version of PB does have the symbol gmtime64 but not the one in PBx86, perhaps there's a reason for the omission, only Fred knows, msvcrt.dll does have gmtime64 but I would not replace the msvcrt.lib that's distributed with PBx86, perhaps add it with a different name.
Post Reply