Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

A link error in windows #778

Closed
DWin233 opened this issue Apr 5, 2024 · 1 comment
Closed

A link error in windows #778

DWin233 opened this issue Apr 5, 2024 · 1 comment
Labels
build system Build system and script changes

Comments

@DWin233
Copy link

DWin233 commented Apr 5, 2024

I'm getting a link error when using it in windows. I installed this library in vcpkg, and minizip-ng.lib was linked, but libminizip-ng.lib was actually generated.
Here is the error output:

(base) PS D:\Code\Mycode\test_code_cpp> xmake f -cvD
checking for platform ... windows
checking for architecture ... x64
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2022
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(nim.exe --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim.exe --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(unzip.exe -v), No such file or directory
checking for unzip ... no
checking for 7z ... C:\dev\xmake\winenv\bin\7z
checking for git ... ok
checkinfo: cannot runv(gzip.exe --version), No such file or directory
checking for gzip ... no
finding minizip-ng from vcpkg ..
checking for pkg-config ... ok
checking for vcpkg::minizip-ng ... minizip-ng 4.0.5
checking for link.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\link.exe
checking for the linker (ld) ... link.exe
configure
{
    ndk_stdcxx = true
    plat = windows
    buildir = build
    ccache = true
    clean = true
    vs = 2022
    arch = x64
    mode = release
    host = windows
    kind = static
}
(base) PS D:\Code\Mycode\test_code_cpp> xmake -rvD  
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\cl.exe ... ok
checking for flags (-O2 -fp:fast) ... ok
> cl.exe "-O2" "-fp:fast" "-nologo"
checking for flags (cl_external_includedir) ... ok
> cl.exe "-external:W0" "-external:IC:\dev\vcpkg\installed\x64-windows\include\minizip-ng" "-nologo"
checking for flags (/utf-8) ... ok
> cl.exe "/utf-8" "-nologo"
checking for flags (/bigobj) ... ok
> cl.exe "/bigobj" "-nologo"
checking for flags (-DNDEBUG) ... ok
> cl.exe "-DNDEBUG" "-nologo"
[ 50%]: compiling.release src\main.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX64\\x64\\cl.exe" -c -nologo -O2 -fp:fast -std:c++17 -MD -ID:\Code\Mycode\test_code_cpp -DFMT_HEADER_ONLY /EHsc -external:W0 -external:IC:\dev\vcpkg\installed\x64-windows\include\minizip-ng -external:W0 -external:IC:\dev\vcpkg\installed\x64-windows\include /utf-8 /bigobj -DNDEBUG -Fobuild\.objs\test\windows\x64\release\src\main.cpp.obj src\main.cpp
checking for flags (cl_sourceDependencies) ... ok
> cl.exe "/sourceDependencies" "C:\Users\XJTU\AppData\Local\Temp\.xmake\240405\_7EDB858C80414B108C2D2812175C4480.json" "-nologo"
bcrypt
[ 75%]: linking.release test.exe
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX64\\x64\\link.exe" -nologo -dynamicbase -nxcompat -machine:x64 -libpath:C:\dev\vcpkg\installed\x64-windows\lib /opt:ref /opt:icf bcrypt.lib minizip-ng.lib bz2.lib lzma.lib zstd.lib zlib.lib -out:build\windows\x64\release\test.exe build\.objs\test\windows\x64\release\src\main.cpp.obj
create ok!
compile_commands.json updated!
error: @programdir\core\main.lua:329: @programdir\actions\build\main.lua:148: @programdir\modules\async\runjobs.lua:338: @programdir\actions\build\kinds\binary.lua:74: @programdir\modules\core\tools\link.lua:175: LINK : fatal error LNK1181: 无法打开输入文件“minizip-ng.lib”

I think this issue is due to the generating difference between the .lib file and the .pc file.

set_target_properties(${MINIZIP_TARGET} PROPERTIES OUTPUT_NAME lib${MINIZIP_TARGET})

Libs: -L${libdir} -L${sharedlibdir} -l@MINIZIP_TARGET@

@nmoinvaz nmoinvaz added the build system Build system and script changes label Jun 8, 2024
@nmoinvaz
Copy link
Member

nmoinvaz commented Jun 8, 2024

I have made a slight modification which should fix the issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
build system Build system and script changes
Projects
None yet
Development

No branches or pull requests

2 participants