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

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

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

Post 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)
Et cetera is my worst enemy
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

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

Post 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
"Daddy, I'll run faster, then it is not so far..."
Fred
Administrator
Administrator
Posts: 16616
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

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

Post by Fred »

It's probably only using the MS linker, not VC++.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

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

Post 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...
Et cetera is my worst enemy
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

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

Post 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).
Et cetera is my worst enemy
Fred
Administrator
Administrator
Posts: 16616
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

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

Post by Fred »

Nice !
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

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

Post 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)
Et cetera is my worst enemy
gltianya
New User
New User
Posts: 6
Joined: Wed Jul 07, 2021 12:02 pm

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

Post by gltianya »

Thank you for your hard work and sharing the results with everyone.
User avatar
idle
Always Here
Always Here
Posts: 5038
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

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

Post by idle »

Thanks chi
Is it really that simple to replace the crt. Should be able to so same with mingw.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

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

Post 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.
Et cetera is my worst enemy
Post Reply