It makes sense, in Fryquez's libs downloader, I'm missing msvcprt.lib
and if I comment on Import "msvcprt.lib" and keep libcpmt.lib in link parameters, I get error LNK2001: unresolved external symbol WinMainCRTStartup,...
I didn't go any further yet.
It's interesting, I hope Fred will add an option for dynamic ucrt in future.
In any case, the MS visual studio linker has been adopted by me, it really helps with exe size.
Visual Studio linker download
Re: Visual Studio linker download
If I think on how many place I used NODEFAULTLIB:libname
Update lib download for msvcrt.lib and msvcprt.lib.

Update lib download for msvcrt.lib and msvcprt.lib.
Re: Visual Studio linker download
Thanks for the added libs, so I gave it another try:
I have a mismatch error detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in pbscintilla.LIB
It seems to work if I remove libucrt.lib, libvcruntime.lib and libcmt.lib
And for libcpmt.lib, move it, just before the imported msvcprt.lib. Don't know why but the order is important here!
Seems to work, in debug also, with the 4 imported static libs and using this fake linker for compiling:
By removing the 4 libs from the linker libucrt.lib, libvcruntime.lib, libcmt.lib and libcpmt.lib,chi wrote: Mon Apr 29, 2024 12:36 amCode: Select all
Import "ucrt.lib" : EndImport ;; libucrt.lib The Universal CRT (UCRT) contains the functions and globals exported by the standard C99 CRT library. Import "vcruntime.lib" : EndImport ;; libvcruntime.lib The vcruntime library contains Visual C++ CRT implementation-specific code: exception handling and debugging support, runtime checks and type information, implementation details, and certain extended library functions. Import "msvcrt.lib" : EndImport ;; libcmt.lib This code handles CRT startup, internal per-thread data initialization, and termination. Import "msvcprt.lib" : EndImport ;; libcpmt.lib C++ standard library (STL) .lib files
I have a mismatch error detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in pbscintilla.LIB
It seems to work if I remove libucrt.lib, libvcruntime.lib and libcmt.lib
And for libcpmt.lib, move it, just before the imported msvcprt.lib. Don't know why but the order is important here!
Seems to work, in debug also, with the 4 imported static libs and using this fake linker for compiling:
Code: Select all
; -----------------------------------------------------------------------------
; Link.pb - Test only: remove libucrt.lib
; Get Compilation via a fake Link.exe:
; -----------------------------------------------------------------------------
; Compile it as Link.exe
; Then In PureBasic_6.10_x64\Compilers\vc, rename Link.exe to Link_real.exe and copy your Fake Link.exe in PureBasic_6.10_x64\Compilers\vc
; Do not forget to restore Link_real.exe to Link.exe when you no longer need this hack
; -----------------------------------------------------------------------------
; To be used with with souces containing:
; Import "ucrt.lib" : EndImport ;; libucrt.lib The Universal CRT (UCRT) contains the functions and globals exported by the standard C99 CRT library.
; Import "vcruntime.lib" : EndImport ;; libvcruntime.lib The vcruntime library contains Visual C++ CRT implementation-specific code: exception handling and debugging support, runtime checks and type information, implementation details, and certain extended library functions.
; Import "msvcrt.lib" : EndImport ;; libcmt.lib This code handles CRT startup, internal per-thread data initialization, and termination.
; Import "msvcprt.lib" : EndImport ;; libcpmt.lib C++ standard library (STL) .lib files
; -----------------------------------------------------------------------------
EnableExplicit
Define CountParam, ProgramParam$, linkParam$, I
Define Link, ExitCode
Define CompilerPath$ = GetPathPart(ProgramFilename())
If FileSize(CompilerPath$ + "link_real.exe") > 0
CountParam = CountProgramParameters()
For I=0 To CountParam-1
linkParam$ + ProgramParameter(I) + " "
Next
; Remove libucrt.lib, libvcruntime.lib and libcmt.lib and use the imported dynamic library instead: ucrt.lib, libvcruntime.lib, libcmt.lib
; Remove libcpmt.lib from its place and add it just before msvcprt.lib. Don't know why order is important here.
; With msvcprt.lib only, there is a linker error: mismatch detected For 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in pbscintilla.LIB
If FindString(linkParam$, " ucrt.lib")
linkParam$ = ReplaceString(linkParam$, " libucrt.lib", "")
EndIf
If FindString(linkParam$, " vcruntime.lib")
linkParam$ = ReplaceString(linkParam$, " libvcruntime.lib", "")
EndIf
If FindString(linkParam$, " msvcrt.lib")
linkParam$ = ReplaceString(linkParam$, " libcmt.lib", "")
EndIf
If FindString(linkParam$, " msvcprt.lib")
linkParam$ = ReplaceString(linkParam$, " libcpmt.lib", "")
linkParam$ = ReplaceString(linkParam$, " msvcprt.lib", " libcpmt.lib msvcprt.lib")
EndIf
Link = RunProgram(CompilerPath$ + "link_real.exe", linkParam$, GetCurrentDirectory(), #PB_Program_Open | #PB_Program_Hide | #PB_Program_Connect | #PB_Program_Error)
If WaitProgram(Link)
ExitCode = ProgramExitCode(Link)
If ExitCode
; gcc -O0 no optimization | -O2 generated code optimized to level 2 - https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Define gccParam$ = "-O0 -g -fsigned-char -Wno-discarded-qualifiers -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-conversion -c -o PureBasic.obj purebasic.c "
;Define gccParam$ = "-O2 -fno-tree-vrp -freorder-blocks-algorithm=simple -fno-schedule-insns -fno-schedule-insns2 -fno-strict-aliasing -fsigned-char -Wno-discarded-qualifiers -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-conversion -c -o PureBasic.obj purebasic.c"
CompilerPath$ = Left(CompilerPath$, Len(CompilerPath$)- 3)
SetClipboardText("Cd /D " + GetCurrentDirectory() +#CRLF$+
"PATH=%PATH%;" + CompilerPath$ + ";" + CompilerPath$ + "gcc\" + ";" + CompilerPath$ + "vc\" +#CRLF$+
"gcc.exe " + gccParam$ +#CRLF$+
"link_real.exe " + linkParam$ +#CRLF$+ "")
MessageRequester("Compilation Error", "Link_real.exe exitcode = " + Str(ExitCode) +#CRLF$+#CRLF$+
"Compilation cmdlines copied to the clipboard for testing." +#CRLF$+
"To be used in cmd.exe before closing this window", #PB_MessageRequester_Ok | #PB_MessageRequester_Error)
EndIf
End ExitCode
EndIf
Else
MessageRequester("Compilation Error", "Visual studio linker, Link_real.exe, not found!", #PB_MessageRequester_Ok | #PB_MessageRequester_Error)
EndIf
Re: Visual Studio linker download
There are probably more libs in PB with similar problems that we don't know about yet. That's why it's up to Fred to sort these things out before we have to fiddle around

Et cetera is my worst enemy
Re: Visual Studio linker download
Yes, you're right, I wanted to see the result for myself and to learn as well, but I'll be patient and let Fred implement it. It should close the exe's size debate with 6.10 and up.
Re: Visual Studio linker download
Can this be documented somewhere? I wasn't aware that placing the VC folder in Compilers was an option. Only matters for asm compiler I guess?
Re: Visual Studio linker download
There is no need for documentation, the linker will change with one of the next beta version anyway.Rinzwind wrote: Mon May 20, 2024 6:04 am Can this be documented somewhere? I wasn't aware that placing the VC folder in Compilers was an option. Only matters for asm compiler I guess?
The Pelles linker is not suited anymore.