Chuyu-Team / VC-LTL5

Shared to msvcrt.dll or ucrtbase.dll and optimize the C/C++ application file size.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

14.35.32215 Self built binaries don't work

BitBlit88 opened this issue · comments

commented

I tried to use my self built vc-ltl5 binaries to compile and link this simple code:

#include <stdio.h>

void main() {
    printf("Hello World\n");
}

But I get a lot of link errors:

...

 libucrt.lib(_file.obj) : error LNK2019: unresolved external symbol __imp__lock referenced in function _lock_file [d:\projects\test3\_projects\test\test.vcxproj]
  libucrt.lib(setlocal_thunks.obj) : error LNK2001: unresolved external symbol __imp__lock [d:\projects\test3\_projects\test\test.vcxproj]
  libucrt.lib(_file.obj) : error LNK2019: unresolved external symbol __imp__unlock referenced in function _unlock_file [d:\projects\test3\_projects\test\test.vcxproj]
  libucrt.lib(setlocal_thunks.obj) : error LNK2001: unresolved external symbol __imp__unlock [d:\projects\test3\_projects\test\test.vcxproj]
  libucrt.lib(_file.obj) : error LNK2019: unresolved external symbol __imp__iob referenced in function __acrt_iob_func [d:\projects\test3\_projects\test\test.vcxproj]
  libucrt.lib(fputwc_thunks.obj) : error LNK2001: unresolved external symbol __imp__iob [d:\projects\test3\_projects\test\test.vcxproj]
  libucrt.lib(sftbuf_thunks.obj) : error LNK2001: unresolved external symbol __imp__iob [d:\projects\test3\_projects\test\test.vcxproj]

...

I built vc-ltl5 like this:

  • Installed Visual Studio Community 2022 - 17.5.0 with following options:
    Windows 10 SDK 10.0.19041.0
    MSVC x64/x86 build tools
    MSVC ARM build tools
    MSVC ARM64/ARM64EC build tools
  • extracted sources from VC-LTL5-5.0.5.zip
  • changed to extracted folder and run: MSBuild.exe -t:Build -m Build.proj

The build succeeded with no errors and all binaries including "*.lib" files can be found in the "TargetPlatform" folder. But when I use these libraries to compile I get the above errors.

When I use the binaries from the Github page from the file "VC-LTL-5.0.5-Binary.7z". I can compile and link my simple test code without any issue.

What could be the problem with my self built binaries?

Please provide more log info.

And you must pull the source code from the repository(https://github.com/Chuyu-Team/VC-LTL5.git).
don't use github's source code zip.

commented

I pulled the source code but the generated lib files don't work either.
I attached the complete build log (file buildog.txt).
The summary prints:
1110 Warning(s)
0 Error(s)

"Project1.log" contains the build log of the simple "Hello World" code.

"targetplatformdir.txt" contains a dump of the targetPlatform folder. The size of the generated lib files are a little bit smaller than the ones from the Github-Release page.

buildlog.txt
Project1.log
targetplatformdir.txt

@BitBlit88 please update code then retry.

ed9dddf

commented

TargetPlatform 10 works, but using targetPlatform 5 or 6 the issue still exists.

buildlog.txt
Project1.log

@BitBlit88 please upload

C:\Users\build\source\repos\VC-LTL5\Tools\6.0.6000.0\x64\ucrtbase.msvcrt.def
C:\Users\build\source\repos\VC-LTL5\ucrtbase.msvcrt\x64\Static\6.0.6000.0\ucrtbase.msvcrt.lib

Thunks.

commented

Attached the files

C:\Users\build\source\repos\VC-LTL5\Tools\6.0.6000.0\x64\ucrtbase.msvcrt.def
C:\Users\build\source\repos\VC-LTL5\ucrtbase.msvcrt\x64\Static\6.0.6000.0\ucrtbase.msvcrt.lib

in the zip archive ucrtbase.zip .

ucrtbase.zip

@BitBlit88 C:\Users\build\source\repos\VC-LTL5\ucrtbase.msvcrt\x64\Static\6.0.6000.0\ucrtbase.msvcrt.lib have some problem. But, I don't know why...

Mabye, this command failed execution. But MS's log not found any error.

lib /def:"C:\Users\build\source\repos\VC-LTL5\Tools\6.0.6000.0\x64\ucrtbase.msvcrt.def" /out:"x64\Static\6.0.6000.0\ucrtbase.msvcrt.lib" /MACHINE:x64

Can you convert the encoding of these files to UTF8, then try again?

C:\Users\build\source\repos\VC-LTL5\Tools\6.0.6000.0\x64\ucrtbase.msvcrt.def
C:\Users\build\source\repos\VC-LTL5\Tools\6.0.6000.0\x64\vcruntime.msvcrt.def
commented

Your guess was absolutely right. It is an encoding problem.
Although the lib command produces no errors with the gb2312 encoded def-files, the resulting lib files are broken.
I had to encode the files "ucrtbase.msvcrt.def" and "vcruntime.msvcrt.def" to UTF-8.
It is important that the UTF-8 files are encoded with a BOM (Byte Order Mark) otherwise the lib command exits with the error: "fatal error LNK1118: syntax error in 'weak' statement"
I attached the two working def files I used to create libs for target platform 6.0. With them I managed to compile and link the test code successfully.
msvcrtdef.zip

Thanks for your help.