[Solved] Update msvcrt.lib for x86 and x64 Windows
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
[Solved] Update msvcrt.lib for x86 and x64 Windows
Hi all,
As many of you probably know, the msvcrt.lib in the PureBasic libraries collection is quite outdated in order to support older Windows versions, however I need a most recent version of the crt. I am trying to use several libraries in static form in my project, however the linker complains about missing symbols due to the fact these don't exist in the msvcrt library version that comes with PureBasic.
My question; who here can tell me how to update the crt library in PureBasic (using PB 5.51). I have tried using my msvcrt.lib from my VS 2017 and VS 2015 installations, however I am not sure which one of the msvcrt.lib files to pick and what other files I might need.
It's quite frustrating, the old CRT, I keep bumping into this problem on a very regular basis and I personally don't care for older versions of Windows anymore. I bet that others here have the same frustration and managed to update it.
Cheers,
Bas
As many of you probably know, the msvcrt.lib in the PureBasic libraries collection is quite outdated in order to support older Windows versions, however I need a most recent version of the crt. I am trying to use several libraries in static form in my project, however the linker complains about missing symbols due to the fact these don't exist in the msvcrt library version that comes with PureBasic.
My question; who here can tell me how to update the crt library in PureBasic (using PB 5.51). I have tried using my msvcrt.lib from my VS 2017 and VS 2015 installations, however I am not sure which one of the msvcrt.lib files to pick and what other files I might need.
It's quite frustrating, the old CRT, I keep bumping into this problem on a very regular basis and I personally don't care for older versions of Windows anymore. I bet that others here have the same frustration and managed to update it.
Cheers,
Bas
Last edited by Crusiatus Black on Mon Feb 12, 2018 11:37 am, edited 1 time in total.
- Zebuddi123
- Enthusiast
- Posts: 794
- Joined: Wed Feb 01, 2012 3:30 pm
- Location: Nottinghamshire UK
- Contact:
Re: Update msvcrt.lib for x86 and x64 Windows
Hi Crusiatus Black I always, well 90% of the time get something out of the questions people pose that intrigue me and I have been playing around with code since "Aristotle" well it seems that long and that does not mean I understand the majority of it So was quite pleased to discover .Lib and I should have guessed is it just another archived file like .apk Dohhhhh.
So the moto is just in case for the future . "If not sure chuck it into 7zip or some other archiver and see what happens lol
Just rooting through msvcrt.lib to see whats in it.
Zebuddi.
So the moto is just in case for the future . "If not sure chuck it into 7zip or some other archiver and see what happens lol
Just rooting through msvcrt.lib to see whats in it.
Zebuddi.
malleo, caput, bang. Ego, comprehendunt in tempore
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: Update msvcrt.lib for x86 and x64 Windows
.lib is an archive format for code my friend, this means that .lib files contain functions a linker can link against your own code. msvcrt.lib is the Microsoft CRT library, for standard functions used in C/C++ compilations.
Additional info
I'm trying to compile a static library with MinGW (x64 and x86, using MSYS). The compilation works fine, the resulting library contains all the code however the one thing MinGW does is injecting __chkstk_ms calls in a lot of functions. __chkstk_ms is not available in the PB shipped msvcrt.lib
Also; I made an attempt at writing a cimple chkstk.cpp file containing one:
I compiled this with the MSVCC compiler including the /GS- and /Gs1000000 options to prevent MSVCC from injecting their own __chkstk_ms calls.
This resolves the unresolved symbol: ___chkstk_ms error by Polink, however now Polink crashes completely.
I'm lost here, why is it so hard to link static libraries in PureBasic?
Additional info
I'm trying to compile a static library with MinGW (x64 and x86, using MSYS). The compilation works fine, the resulting library contains all the code however the one thing MinGW does is injecting __chkstk_ms calls in a lot of functions. __chkstk_ms is not available in the PB shipped msvcrt.lib
Also; I made an attempt at writing a cimple chkstk.cpp file containing one:
Code: Select all
void __chkstk_ms(void){
return;
}
This resolves the unresolved symbol: ___chkstk_ms error by Polink, however now Polink crashes completely.
I'm lost here, why is it so hard to link static libraries in PureBasic?
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: Update msvcrt.lib for x86 and x64 Windows
Another update
I compiled the static library in MinGW with the following flags
and for x86
This removed the __chkstk_ms calls, however now polink crashes completely when I compile my PureBasic project, so
I updated Polink,exe to the latest version.
This (thankfully) works for x64 PureBasic and my project runs, YAY! However, in x86 PureBasic I now get the following
linker error:
Note that I didn't update mscvrt.lib yet, because I don't know which one I need and where to find it. This feels to me like the last step in the process. These unresolved symbols are not referenced in my static library, and were not unresolved with the old polink version. I'm assuming I need to update one more thing, however I need input from the PureBasic experts here. I've been at this for a week and I want to solve it finally.
Thanks,
Bas
I compiled the static library in MinGW with the following flags
Code: Select all
../configure CFLAGS='-static -m64 -mno-stack-arg-probe -fno-stack-check -fno-stack-protector'; make
Code: Select all
../configure CFLAGS='-static -m32 -mno-stack-arg-probe -fno-stack-check -fno-stack-protector'; make
I updated Polink,exe to the latest version.
This (thankfully) works for x64 PureBasic and my project runs, YAY! However, in x86 PureBasic I now get the following
linker error:
Code: Select all
---------------------------
PureBasic - Linker error
---------------------------
POLINK: warning: Unrecognized option 'FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0'; ignored.
POLINK: error: Unresolved external symbol '_SYS_FreeThreadObjectCallback@4'.
POLINK: error: Unresolved external symbol '_SYS_InitThreadObjectCallback@4'.
POLINK: error: Unresolved external symbol '__imp__CharLowerW@4'.
POLINK: error: Unresolved external symbol '__imp__InitCommonControlsEx@4'.
POLINK: error: Unresolved external symbol '__imp__CoInitialize@4'.
POLINK: error: Unresolved external symbol '__imp__MessageBoxW@16'.
...
POLINK: fatal error: 38 unresolved external(s).
---------------------------
OK
---------------------------
Thanks,
Bas
Re: Update msvcrt.lib for x86 and x64 Windows
Did you try importing from an explicit path?
Code: Select all
ImportC "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\msvcrt.lib"
c_qsort(*arBaseIndex, nPts.i, SizeOfStruc.i, *CompareFn) As "qsort"
EndImport
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: Update msvcrt.lib for x86 and x64 Windows
Yes, and I also tried placing that version of the msvcrt.lib in the PureLibrary/Windows/Libraries directory, however that yielded even more polink warnings.skywalk wrote:Did you try importing from an explicit path?Code: Select all
ImportC "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\msvcrt.lib" c_qsort(*arBaseIndex, nPts.i, SizeOfStruc.i, *CompareFn) As "qsort" EndImport
I updated PB's polink.exe to version 8, which fixed all issues for me in my x64 builds, however nothing builds in x86 anymore (PureBasic 5.51)
Here's the compiler error when compiling an MessageRequester("test", "test") project with polink 8, instead of the shipped version 5:
With debugger
Code: Select all
---------------------------
PureBasic - Linker error
---------------------------
POLINK: error: Unresolved external symbol '_SYS_FreeThreadObjectCallback@4'.
POLINK: error: Unresolved external symbol '_SYS_InitThreadObjectCallback@4'.
POLINK: error: Unresolved external symbol '__imp__closesocket@4'.
POLINK: error: Unresolved external symbol '__imp__WSACleanup@0'.
POLINK: error: Unresolved external symbol '__imp__WSAStartup@8'.
POLINK: error: Unresolved external symbol '__imp__PostThreadMessageA@16'.
POLINK: error: Unresolved external symbol '__imp__inet_addr@4'.
...
POLINK: fatal error: 26 unresolved external(s).
---------------------------
OK
---------------------------
Code: Select all
---------------------------
PureBasic - Linker error
---------------------------
POLINK: error: Unresolved external symbol '__imp__InitCommonControlsEx@4'.
POLINK: error: Unresolved external symbol '__imp__CoInitialize@4'.
POLINK: error: Unresolved external symbol '__imp__MessageBoxW@16'.
POLINK: error: Unresolved external symbol '__imp__GetForegroundWindow@0'.
POLINK: error: Unresolved external symbol '__imp__GetWindowThreadProcessId@8'.
POLINK: error: Unresolved external symbol '__imp__IsWindowVisible@4'.
POLINK: error: Unresolved external symbol '__imp__GetWindowLongW@8'.
...
POLINK: fatal error: 11 unresolved external(s).
---------------------------
OK
---------------------------
Re: Update msvcrt.lib for x86 and x64 Windows
Have you tried to import also the winsock.lib ?
Because these functions are all in this lib.
Because these functions are all in this lib.
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: Update msvcrt.lib for x86 and x64 Windows
Hi infratec,
Yes, believe it or not, I've imported it and the linker errors do not go away. The weird thing is that my project doesn't use any network commands anywhere, and it compiles fine with Polink 8 in the toolchain in 64-bit. It's only the 32-bit compiler that is complaining, even with empty projects.
I'm completely lost here, I don't understand anything about this. Another thing I tried was to install the latest version of PureBasic, immediately update polink to version 8 (I tried polink 7 as well) and I get those same errors in the 32-bit compiler, but not in the 64-bit compiler.
Maybe @Fred can shed some light on this? I am confused.
Yes, believe it or not, I've imported it and the linker errors do not go away. The weird thing is that my project doesn't use any network commands anywhere, and it compiles fine with Polink 8 in the toolchain in 64-bit. It's only the 32-bit compiler that is complaining, even with empty projects.
I'm completely lost here, I don't understand anything about this. Another thing I tried was to install the latest version of PureBasic, immediately update polink to version 8 (I tried polink 7 as well) and I get those same errors in the 32-bit compiler, but not in the 64-bit compiler.
Maybe @Fred can shed some light on this? I am confused.
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: Update msvcrt.lib for x86 and x64 Windows
Additionally, an empty project with only a MessageBox shows those unresolved symbols, my project shows:infratec wrote:Have you tried to import also the winsock.lib ?
Because these functions are all in this lib.
Code: Select all
---------------------------
PureBasic - Linker error
---------------------------
POLINK: warning: Unrecognized option 'FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0'; ignored.
POLINK: error: Unresolved external symbol '_SYS_FreeThreadObjectCallback@4'.
POLINK: error: Unresolved external symbol '_SYS_InitThreadObjectCallback@4'.
POLINK: error: Unresolved external symbol '__imp__CharLowerW@4'.
POLINK: error: Unresolved external symbol '__imp__InitCommonControlsEx@4'.
POLINK: error: Unresolved external symbol '__imp__CoInitialize@4'.
POLINK: error: Unresolved external symbol '__imp__MessageBoxW@16'.
...
POLINK: fatal error: 38 unresolved external(s).
---------------------------
OK
---------------------------
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: Update msvcrt.lib for x86 and x64 Windows
Here's the list of parameters polink.exe receives when PureBasic is compiling an empty source-code in x86:
It seems to contain a full list of all libraries, and yet it complains about unresolved symbols.
Code: Select all
Parameters: 37
/FORCE:MULTIPLE
/OUT:C:\Users\Bas Groothedde\AppData\Local\Temp\PureBasic_Compilation1.exe
/ENTRY:PureBasicStart
/SUBSYSTEM:Windows
/NODEFAULTLIB
/LIBPATH:C:\Program Files (x86)\PureBasic 551\Compilers
/LIBPATH:C:\Program Files (x86)\PureBasic 551\PureLibraries\Windows\Libraries
PureBasic.obj
SystemBase.lib
StringUtility.lib
UnicodeFunctions.lib
MSVCRT.lib
KERNEL32.lib
USER32.lib
GDI32.lib
COMDLG32.lib
ADVAPI32.lib
COMCTL32.lib
OLEAUT32.lib
String.lib
Network.lib
System.lib
Memory.lib
Map.lib
Date.lib
CipherMD5.lib
Cipher.lib
C:\Program Files (x86)\PureBasic 551\compilers/objectmanager.lib
SimpleList.lib
Array.lib
C:\Program Files (x86)\PureBasic 551\compilers/stringmanager.lib
Debugger.lib
WSOCK32.LIB
SHELL32.LIB
WINMM.LIB
kernel32.lib
PureBasic.res
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: Update msvcrt.lib for x86 and x64 Windows
For the polink issue I refer to: http://www.purebasic.fr/english/viewtop ... 13&t=70191 - as it is a different subject than my original question of updating msvcrt.lib
Re: Update msvcrt.lib for x86 and x64 Windows
Seems like you selected exactly the two libraries that don't work with PBCrusiatus Black wrote:I have tried using my msvcrt.lib from my VS 2017 and VS 2015 installations, however...
tested with PB 6.52 (x86/x64)
Code: Select all
Visual Studio 2017 - not working
Visual Studio 2015 - not working
Visual Studio 2013 - works, needs msvcr120.dll
Visual Studio 2012 - works, needs msvcr110.dll (not tested)
Visual Studio 2010 - works, needs msvcr100.dll
Visual Studio 2008 - works, needs msvcr90.dll
Et cetera is my worst enemy
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: Update msvcrt.lib for x86 and x64 Windows
Thank you Chi, that information is very valuable to me. I now can update msvcrt.lib, however I'm still having Polink issues.
I updated polink to veresion 8 for PB 5.51 x64, which works great. The polink 8 binary in PB 5.51 x86 doesn't seem to work though, I keep getting unresolved symbols even with empty projects; do you perhaps know if polink can actually be updated for PureBasic x86 compilers?
I updated polink to veresion 8 for PB 5.51 x64, which works great. The polink 8 binary in PB 5.51 x86 doesn't seem to work though, I keep getting unresolved symbols even with empty projects; do you perhaps know if polink can actually be updated for PureBasic x86 compilers?