Page 1 of 1

[IDE Tool] RuntimeSwitcher (Windows only, Experimental!)

Posted: Wed Mar 22, 2023 12:31 pm
by chi
Image
The main purpose of 'RuntimeSwitcher' is to easily switch between PB's C Runtime (CRT) and the newer Universal C Runtime (UCRT). In addition you can also build your own UCRT (+STL +CLR) using Visual Studio 2015 or later, allowing you to use more recent libraries directly in your PureBasic projects.

Notes:
  • The UCRT only works with the C backend, the ASM backend is not supported.
  • With /MD, you must provide Microsoft's Visual C++ Redistributable for OSs prior to Windows 10.
  • With /MD, you have to add some linker directives to your code (.exe) that aren't automatically picked up by polink. Press the small button above /MD to copy directives to the clipboard.
  • With /MT, applications created with 'Executable Format: Console' crash when using the PB Debugger.
  • PB uses setjmp/longjmp with libpng and libjpeg which have issues with the UCRT. To fix this I included both libraries built with VS 2022, but it needs special handling if you create a .dll that uses png/jpg. Toggle the small button above /MT.
  • The libraries included with RTS are all built with VS 2022, UCRT 10.0.22621.0, VCTools 14.35.32215; libpng.lib 1.6.39; libjpeg.lib 9e;
  • I haven't tried CLR (Common Language Runtime aka .Net) yet, maybe someone can do some testing? The STL (C++ Standard Template Library) seems to work fine.
  • At the moment you can only drag & drop 'Native Tools Command Prompt for VS' lnk's (VS 2015+) onto the RTS window.
  • If you have UAC enabled you need to run the PB IDE as Administrator, so that 'RuntimeSwitcher' can build and copy the libraries.

Download: RuntimeSwitcher1.0.7z (24.2MB)

Re: [IDE Tool] RuntimeSwitcher (Windows only, Experimental!)

Posted: Thu Mar 23, 2023 9:18 am
by dige
I'm not sure if I understand this correctly: with the RuntimeSwitcher I can compile PB programmes with Visual Studio?
And thus possibly use newer modern UI elements? :shock: :D

Re: [IDE Tool] RuntimeSwitcher (Windows only, Experimental!)

Posted: Thu Mar 23, 2023 2:27 pm
by Fred
It's probably only using the MS linker, not VC++.

Re: [IDE Tool] RuntimeSwitcher (Windows only, Experimental!)

Posted: Thu Mar 23, 2023 2:43 pm
by chi
dige wrote: Thu Mar 23, 2023 9:18 am I'm not sure if I understand this correctly: with the RuntimeSwitcher I can compile PB programmes with Visual Studio?
And thus possibly use newer modern UI elements? :shock: :D
With RuntimeSwitcher you can use static libraries created with VS 2015+ in PB. The idea was born here (raylib).

But even without static libraries, switching to UCRT will most likely bring a boost in performance due to better memory management...

Re: [IDE Tool] RuntimeSwitcher (Windows only, Experimental!)

Posted: Thu Mar 23, 2023 3:03 pm
by chi
Fred wrote: Thu Mar 23, 2023 2:27 pm It's probably only using the MS linker, not VC++.
No, I'm just replacing the original msvcrt.lib (PB\PureLibraries\Windows\Libraries) with a custom one (e.g. VS 2022 libcmt.lib+libvcruntime.lib+libucrt.lib = _MT_17_msvcrt.lib).

Re: [IDE Tool] RuntimeSwitcher (Windows only, Experimental!)

Posted: Thu Mar 23, 2023 3:40 pm
by Fred
Nice !

Re: [IDE Tool] RuntimeSwitcher (Windows only, Experimental!)

Posted: Fri Mar 24, 2023 7:47 am
by chi
Fred wrote: Thu Mar 23, 2023 3:40 pmNice !
Thanks! (and thanks for pointing out the possible setjmp/longjmp problem in your PM)

Re: [IDE Tool] RuntimeSwitcher (Windows only, Experimental!)

Posted: Fri Apr 14, 2023 4:24 am
by gltianya
Thank you for your hard work and sharing the results with everyone.

Re: [IDE Tool] RuntimeSwitcher (Windows only, Experimental!)

Posted: Wed Apr 19, 2023 8:03 am
by idle
Thanks chi
Is it really that simple to replace the crt. Should be able to so same with mingw.

Re: [IDE Tool] RuntimeSwitcher (Windows only, Experimental!)

Posted: Wed Apr 19, 2023 8:22 pm
by chi
gltianya wrote: Fri Apr 14, 2023 4:24 am Thank you for your hard work and sharing the results with everyone.
You're welcome, happy coding! :)
idle wrote: Wed Apr 19, 2023 8:03 am Thanks chi
Is it really that simple to replace the crt. Should be able to so same with mingw.
I think it should be that simple for MinGW as well. But who knows for sure without trying... ;) Let me know if you need help.