Need help to compile LibPng into static lib
Re: Need help to compile LibPng into static lib
ok
adding /GS- to both zlib and libpng gets rid of all but two kinker errors
POLINK: error: Unresolved external symbol '__imp___stdio_common_vfprintf'.
POLINK: error: Unresolved external symbol '__imp___acrt_iob_func'.
can anyone advise?
adding /GS- to both zlib and libpng gets rid of all but two kinker errors
POLINK: error: Unresolved external symbol '__imp___stdio_common_vfprintf'.
POLINK: error: Unresolved external symbol '__imp___acrt_iob_func'.
can anyone advise?
Re: Need help to compile LibPng into static lib
Yes ! Salva.Denis wrote:Salut Oliv, (ça va ?)
Anyway ! Did you see this (caution : it is on ASCII flow) ?
Re: Need help to compile LibPng into static lib
Hi jack,jack wrote:hello Denis
the title says "Need help to compile LibPng into static lib" and yet in the first post you say that you built the library
so is your problem building a static libpng or using it in PB?
if you managed to build the static lib, did you use Cmake or some other way?
I managed to build a static libpng x64 using Cmake but it was a learning experience, and I don't know if I could clearly give the steps needed.
My problem is to compile correctly LibPng into static lib using VS and after that to use it with PB.
Using it with PB is not really problematic (hope so
I use VS to compile libpng (standard compilation build or rebuild solution, using batch build from VS menu give the same result but i don't know if VS batch build uses Cmake).
As i said, I discoverd VS 2 weeks ago and i'm not à C coder at all.
Tomorrow, i'll take a look to the way you explain.
@Olliv
I dont' really clearly understand the procedure Undec(Name.S), may be I'm tired...
A+
Denis
Denis
Re: Need help to compile LibPng into static lib
compiling the library is no problem, the problem is that PB uses an old version of visual studio and is not compatible with newer versions, at least that's what I gather from this post viewtopic.php?f=5&t=41247
Re: Need help to compile LibPng into static lib
Yeah, not clear.jack wrote:compiling the library is no problem, the problem is that PB uses an old version of visual studio and is not compatible with newer versions, at least that's what I gather from this post viewtopic.php?f=5&t=41247
in this Fred post (Wed Nov 13, 2019 ) viewtopic.php?f=7&t=74007
I thought I understood that current VS to compile .lib file is VS 2013, that's why i've installed it.
VS 2010 is still avalaible if i remember, so lets go!
Last edited by Denis on Fri Nov 15, 2019 7:34 pm, edited 1 time in total.
A+
Denis
Denis
Re: Need help to compile LibPng into static lib
I am tired too...
PNG library seems to be open source. Maybe I am wrong.
Visual Studio does not seem to be open source.
Undec() calls ms API to undecorate a function name certainly create by Visual Studio.
When you list several function names in a DLL compiled by Visual Studio, the function names seems to have more characters than we need to call them in a source file.
Until here, no problem.
Undec("PrintPATATRA") will return the right syntax we need :
Value.L = Print(String.S, [Color.L] )
That is good : I give you my DLL containing beautiful functions as Print(), Input(), etc...
And with Undec() you get the right syntax.
But, imagine me to compile you my beautiful functions, instead of just using Visual Studio (MS, I suppose), I call others non-ms functions from non-ms compiler, I am not sure, name decorating symbols will be used.
Undec() will undecorate function names compiled by ms compilers (with right switch options too). But it could be possible a function call non-ms functions built by non-ms compilers.
In this way, 3 kinds of work :
1) find a linux equivalent function as Microsoft API UndecorateName() used by Undec()
2) Search in the source headers the right syntaxes and copy them manually (converting CPP declarings to PureBasic declarings)
3) find a application which copies right syntax (what I think it is available now on this subject) whatever the OS of the compiler which made libraries and sub-libraries.
Concerning decorating version, I give up... (and let you read all the other explaining to that...)
PNG library seems to be open source. Maybe I am wrong.
Visual Studio does not seem to be open source.
Undec() calls ms API to undecorate a function name certainly create by Visual Studio.
When you list several function names in a DLL compiled by Visual Studio, the function names seems to have more characters than we need to call them in a source file.
Until here, no problem.
Undec("PrintPATATRA") will return the right syntax we need :
Value.L = Print(String.S, [Color.L] )
That is good : I give you my DLL containing beautiful functions as Print(), Input(), etc...
And with Undec() you get the right syntax.
But, imagine me to compile you my beautiful functions, instead of just using Visual Studio (MS, I suppose), I call others non-ms functions from non-ms compiler, I am not sure, name decorating symbols will be used.
Undec() will undecorate function names compiled by ms compilers (with right switch options too). But it could be possible a function call non-ms functions built by non-ms compilers.
In this way, 3 kinds of work :
1) find a linux equivalent function as Microsoft API UndecorateName() used by Undec()
2) Search in the source headers the right syntaxes and copy them manually (converting CPP declarings to PureBasic declarings)
3) find a application which copies right syntax (what I think it is available now on this subject) whatever the OS of the compiler which made libraries and sub-libraries.
Concerning decorating version, I give up... (and let you read all the other explaining to that...)
Re: Need help to compile LibPng into static lib
You're right, it's open source.Olliv wrote:I am tired too...
PNG library seems to be open source. Maybe I am wrong.
It's MS 'tool'Olliv wrote:Visual Studio does not seem to be open source.
Just wonder how PB will interpret this changes.Olliv wrote:Undec() calls ms API to undecorate a function name certainly create by Visual Studio.
When you list several function names in a DLL compiled by Visual Studio, the function names seems to have more characters than we need to call them in a source file.
May be it's OK if you've done this
A+
Denis
Denis
Re: Need help to compile LibPng into static lib
I just needed to call DLLs compiled by MS, not static LIB.
Re: Need help to compile LibPng into static lib
@Denis
compiling with visual 2008 using the /GS- switch makes it work with PB
as does with vs2013
compiling with visual 2008 using the /GS- switch makes it work with PB
as does with vs2013
-
Everything
- Enthusiast

- Posts: 225
- Joined: Sat Jul 07, 2018 6:50 pm
Re: Need help to compile LibPng into static lib
I had to do this for almost every studio .lib (and sometimes we have to add some other dependencies libs from WinSDK)jack wrote:using the /GS- switch
Re: Need help to compile LibPng into static lib
Hi jack,jack wrote:@Denis
compiling with visual 2008 using the /GS- switch makes it work with PB
as does with vs2013
excellent but for me it doesn't work with 2013
/GS was enabled for all except zlib. I changed it but no difference.
After that i disabled this switch to all but without succes.
Here is the content from libpng.log and zlib.log.
can you tell me the differences with yours if any or post here your result?
Thank you for your help.
With following i now get "unable to find symbol _CRC32" witch comes from Zlib config i I think.
zlib.logBuild started 16/11/2019 08:48:28.
1>Project "C:\Users\user\source\repos\lpng1637\projects\vstudio\libpng\libpng.vcxproj" on node 2 (Rebuild target(s)).
1>ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /IC:\Users\user\source\repos\zlib /Zi /nologo /Wall /WX- /Ox /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _WINDOWS /D _UNICODE /D UNICODE /GF /Gm- /EHsc /MT /GS /Gy /fp:precise /fp:except- /Zc:wchar_t- /Zc:forScope /Yc"pngpriv.h" /Fp"libpng16.pch" /Fd"vc120.pdb" /FR /Gd /TC /wd4255 /wd4668 /wd4710 /wd4711 /wd4746 /wd4820 /wd4996 /analyze- /errorReport:prompt ..\..\..\png.c
png.c
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /IC:\Users\user\source\repos\zlib /Zi /nologo /Wall /WX- /Ox /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _WINDOWS /D _UNICODE /D UNICODE /GF /Gm- /EHsc /MT /GS /Gy /fp:precise /fp:except- /Zc:wchar_t- /Zc:forScope /Yu"pngpriv.h" /Fp"libpng16.pch" /Fd"vc120.pdb" /FR /Gd /TC /wd4255 /wd4668 /wd4710 /wd4711 /wd4746 /wd4820 /wd4996 /analyze- /errorReport:prompt ..\..\..\pngerror.c ..\..\..\pngget.c ..\..\..\pngmem.c ..\..\..\pngpread.c ..\..\..\pngread.c ..\..\..\pngrio.c ..\..\..\pngrtran.c ..\..\..\pngrutil.c ..\..\..\pngset.c ..\..\..\pngtrans.c ..\..\..\pngwio.c ..\..\..\pngwrite.c ..\..\..\pngwtran.c ..\..\..\pngwutil.c
pngerror.c
pngget.c
pngmem.c
pngpread.c
pngread.c
pngrio.c
pngrtran.c
pngrutil.c
pngset.c
pngtrans.c
pngwio.c
pngwrite.c
pngwtran.c
pngwutil.c
Lib:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\Lib.exe /OUT:"C:\Users\user\source\repos\lpng1637\projects\vstudio\Release Library\libpng16.lib" "C:\Users\user\source\repos\lpng1637\projects\vstudio\Release Library\zlib.lib" /NOLOGO /MACHINE:X86 /LTCG png.obj
pngerror.obj
pngget.obj
pngmem.obj
pngpread.obj
pngread.obj
pngrio.obj
pngrtran.obj
pngrutil.obj
pngset.obj
pngtrans.obj
pngwio.obj
pngwrite.obj
pngwtran.obj
pngwutil.obj
libpng.vcxproj -> C:\Users\user\source\repos\lpng1637\projects\vstudio\Release Library\libpng16.lib
BscMake:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\bscmake.exe /nologo /o"C:\Users\user\source\repos\lpng1637\projects\vstudio\Release Library\libpng16.bsc" png.sbr pngerror.sbr pngget.sbr pngmem.sbr pngpread.sbr pngread.sbr pngrio.sbr pngrtran.sbr pngrutil.sbr pngset.sbr pngtrans.sbr pngwio.sbr pngwrite.sbr pngwtran.sbr pngwutil.sbr
1>Done Building Project "C:\Users\user\source\repos\lpng1637\projects\vstudio\libpng\libpng.vcxproj" (Rebuild target(s)).
Build succeeded.
Time Elapsed 00:00:03.12
Edit :Build started 16/11/2019 08:48:28.
1>Project "C:\Users\user\source\repos\lpng1637\projects\vstudio\zlib\zlib.vcxproj" on node 2 (Rebuild target(s)).
1>ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /Zi /nologo /Wall /WX- /Ox /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _WINDOWS /D Z_SOLO /D _UNICODE /D UNICODE /GF /Gm- /EHsc /MT /GS /Gy /fp:precise /fp:except- /Zc:wchar_t /Zc:forScope /Fo"Release Library\\" /Fd"Release Library\vc120.pdb" /FR"Release Library\\" /Gd /TC /wd4255 /wd4668 /wd4710 /wd4711 /wd4746 /wd4820 /wd4996 /wd4127 /wd4131 /wd4242 /wd4244 /analyze- /errorReport:prompt C:\Users\user\source\repos\zlib\adler32.c C:\Users\user\source\repos\zlib\compress.c C:\Users\user\source\repos\zlib\crc32.c C:\Users\user\source\repos\zlib\deflate.c C:\Users\user\source\repos\zlib\infback.c C:\Users\user\source\repos\zlib\inffast.c C:\Users\user\source\repos\zlib\inflate.c C:\Users\user\source\repos\zlib\inftrees.c C:\Users\user\source\repos\zlib\trees.c C:\Users\user\source\repos\zlib\uncompr.c C:\Users\user\source\repos\zlib\zutil.c
adler32.c
compress.c
crc32.c
deflate.c
infback.c
inffast.c
inflate.c
inftrees.c
trees.c
uncompr.c
zutil.c
Lib:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\Lib.exe /OUT:"C:\Users\user\source\repos\lpng1637\projects\vstudio\Release Library\zlib.lib" /NOLOGO /MACHINE:X86 /LTCG "Release Library\adler32.obj"
"Release Library\compress.obj"
"Release Library\crc32.obj"
"Release Library\deflate.obj"
"Release Library\infback.obj"
"Release Library\inffast.obj"
"Release Library\inflate.obj"
"Release Library\inftrees.obj"
"Release Library\trees.obj"
"Release Library\uncompr.obj"
"Release Library\zutil.obj"
zlib.vcxproj -> C:\Users\user\source\repos\lpng1637\projects\vstudio\Release Library\zlib.lib
BscMake:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\bscmake.exe /nologo /o"C:\Users\user\source\repos\lpng1637\projects\vstudio\Release Library\zlib.bsc" "Release Library\adler32.sbr" "Release Library\compress.sbr" "Release Library\crc32.sbr" "Release Library\deflate.sbr" "Release Library\infback.sbr" "Release Library\inffast.sbr" "Release Library\inflate.sbr" "Release Library\inftrees.sbr" "Release Library\trees.sbr" "Release Library\uncompr.sbr" "Release Library\zutil.sbr"
1>Done Building Project "C:\Users\user\source\repos\lpng1637\projects\vstudio\zlib\zlib.vcxproj" (Rebuild target(s)).
Build succeeded.
Time Elapsed 00:00:00.61
jack, did u use the way you explain to compile, i not, i only use VS to set libpng/zlib up.
A+
Denis
Denis
Re: Need help to compile LibPng into static lib
I used vs2013 to compile the solution(not the method jack described) with all projects with the /GS- the builds succeeds as always but i get the exact same error as before when i import the lib in pb.
jack, when you say it works do you mean you are able to import the lib in PB as a static lib included in the pb exe?
jack, when you say it works do you mean you are able to import the lib in PB as a static lib included in the pb exe?
Re: Need help to compile LibPng into static lib
If you're getting unresolved c functions you will be using a different version of VS to that of PB
so you will have to add references to the crt libs for your build by explicitly adding them as dependencies.
libcrt.lib or libucrt.lib, libcmt.lib, libvcruntime.lib and use the /MT switch
so you will have to add references to the crt libs for your build by explicitly adding them as dependencies.
libcrt.lib or libucrt.lib, libcmt.lib, libvcruntime.lib and use the /MT switch
Windows 11, Manjaro, Raspberry Pi OS


Re: Need help to compile LibPng into static lib
@Denis
it's /GS- not /GS
it's /GS- not /GS
Re: Need help to compile LibPng into static lib
@justin
you need to add GS- to zlib also, just edit the Makefile.msc file and add -GS- to CFLAGS
also, in the cmake-gui steps to correct the zlib paths you can add the /GS- option in the CFLAGS - you will see it near the top of the list
I am not familiar with using the libpng library so my example is the following
not sure if it should be ImportC or Import but you need to import the zlib as in my example
you need to add GS- to zlib also, just edit the Makefile.msc file and add -GS- to CFLAGS
also, in the cmake-gui steps to correct the zlib paths you can add the /GS- option in the CFLAGS - you will see it near the top of the list
I am not familiar with using the libpng library so my example is the following
Code: Select all
Import "zlib.lib"
EndImport
Import "libpng16_static.lib"
png_access_version_number()
EndImport
Debug png_access_version_number()
Last edited by jack on Sun Nov 17, 2019 5:49 am, edited 1 time in total.

