Page 1 of 1

Please update PB's C runtime on Windows (e.g.: msvcrt.lib)

Posted: Sun Feb 19, 2023 9:45 am
by IceSoft
see here:
posting.php?mode=quote&p=595813
chi wrote: Tue Feb 14, 2023 9:56 pm
ccode_new wrote: Mon Feb 13, 2023 8:52 pm How to statically build the "raylib" library on Windows with PureBasic compatibility? (.lib / .a)
I'm pretty sure you can't! PB's C runtime on Windows is very old and Raylib needs some of the newer features...

Fortunately, you can do it the other way around. I created a custom msvcrt.lib so you can use UCRT with PB (C backend only). Just rename the original msvcrt.lib (PB64Folder\PureLibraries\Windows\Libraries) to msvcrt_orig.lib and copy msvcrt_v143.lib from the zip file to the same folder. Now make a copy of msvcrt_v143.lib and rename it to msvcrt.lib. (Don't forget to rename msvcrt_orig.lib to msvcrt.lib if you want to go back and use the old CRT and/or the ASM backend)

To create a statically linked raylib.lib, just clone the Github repository and open raylib/projects/VS2022/Raylib.sln with VS and compile Release | x64. Replace your libraylib_win_x64.lib with the one you just created and you should be able to compile all examples statically linked without the need for raylib.dll. I've also included the 4.2 lib in the zip.

ray_msvcrt.7z (4.52MB)

Re: Please update PB's C runtime on Windows (e.g.: msvcrt.lib)

Posted: Sun Feb 19, 2023 9:58 am
by ccode_new
You can't just replace the msvcrt.lib like that.
An extended msvcrt.lib is required that includes all additional dependencies. This is then very large.
MSVCRT vs UCRT These are two variants of the C standard library on Microsoft Windows.

MSVCRT (Microsoft Visual C++ Runtime) is available by default on all Microsoft Windows versions, but due to backwards compatibility issues is stuck in the past, not C99 compatible and is missing some features.

It isn't C99 compatible, for example the printf() function family, but...
mingw-w64 provides replacement functions to make things C99 compatible in many cases
it doesn't support the UTF-8 locale
Binaries linked with MSVCRT should not be mixed with UCRT ones because the internal structures and data types are different. Same rule is applied for MSVC compiled binaries because MSVC uses UCRT by default (if not changed).
Works out of the box on every Microsoft Windows versions.
UCRT (Universal C Runtime) is a newer version which is also used by Microsoft Visual Studio by default. It should work and behave as if the code was compiled with MSVC.

Better compatibility with MSVC, both at build time and at run time.
It only ships by default on Windows 10 and for older versions you have to provide it yourself or depend on the user having it installed.

Microsoft split their CRT into two parts, one which was specific to their compilers (vcruntime), the other generic to all compliers (ucrt). So if you are using a non-Microsoft compiler (like Clang or GCC), you still use ucrt, but not vcruntime; vcruntime is only supposed to be used by Microsoft's compilers.

Re: Please update PB's C runtime on Windows (e.g.: msvcrt.lib)

Posted: Sun Feb 19, 2023 10:14 am
by IceSoft
ccode_new wrote: Sun Feb 19, 2023 9:58 am You can't just replace the msvcrt.lib like that.
An extended msvcrt.lib is required that includes all additional dependencies. This is then very large.
Raylib is not the reason for this Feature Request.
Its the msvcrt.lib coming with the PB (its old and not combatible with newer VS Studios (2022)

Re: Please update PB's C runtime on Windows (e.g.: msvcrt.lib)

Posted: Sun Feb 19, 2023 10:32 am
by ccode_new
But you can also ignore the new msvcrt.lib in the settings and link with an older version.
(If the project does not need newer features.)

This then has a higher compatibility with older Windows versions.

Re: Please update PB's C runtime on Windows (e.g.: msvcrt.lib)

Posted: Sun Feb 19, 2023 8:01 pm
by idle
ccode_new wrote: Sun Feb 19, 2023 10:32 am But you can also ignore the new msvcrt.lib in the settings and link with an older version.
(If the project does not need newer features.)

This then has a higher compatibility with older Windows versions.
the problem is we need the same crt version fred uses but I don't think we can get it without a subscription to ms.
If you know how to get it without a sub write up a tutorial, it will make a lit of us happy.