Thanks for the added libs, so I gave it another try:
chi wrote: Mon Apr 29, 2024 12:36 am
Code: 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
By removing the 4 libs from the linker libucrt.lib, libvcruntime.lib, libcmt.lib and libcpmt.lib,
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