Script fail in Windows
thiagola92 opened this issue · comments
Setup
- Installed Visual Studio Community 2022
- Installed with Visual Studio Installer:
- workload Desktop development with C++
- C++ CMake tools for Windows
git clone https://github.com/zerotier/libzt.git
cd libzt/
git submodule update --init
- Open
libzt
folder with Visual Studio . .\build.ps1; Build-Host -BuildType "Release" -Arch "x64"
Operating System: Windows 11 Pro
Error
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
CMake Error at CMakeLists.txt:2 (project):
Generator
Visual Studio 16 2019
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
CMake Error:
Generator
Visual Studio 16 2019
could not find any instance of Visual Studio.
Test project C:/Users/thiag/Downloads/libzt/cache/win-x64-host-release
No tests were found!!!
cp : Cannot find path 'C:\Users\thiag\Downloads\libzt\cache\win-x64-host-release\lib\Release\zt.lib' because it does not exist.
At C:\Users\thiag\Downloads\libzt\build.ps1:20 char:2
+ cp $env:BuildDir\lib\$BuildType\zt.lib $env:OutputDir\lib\libzt.l ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\thiag\...\Release\zt.lib:String) [Copy-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
cp : Cannot find path 'C:\Users\thiag\Downloads\libzt\cache\win-x64-host-release\bin\Release' because it does not exist.
At C:\Users\thiag\Downloads\libzt\build.ps1:21 char:2
+ cp $env:BuildDir\bin\$BuildType\*.exe $env:OutputDir\bin
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\thiag\...ase\bin\Release:String) [Copy-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
cp : Cannot find path 'C:\Users\thiag\Downloads\libzt\cache\win-x64-host-release\lib\Release\zt-shared.dll' because it does not exist.
At C:\Users\thiag\Downloads\libzt\build.ps1:22 char:2
+ cp $env:BuildDir\lib\$BuildType\zt-shared.dll $env:OutputDir\lib\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\thiag\...e\zt-shared.dll:String) [Copy-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
Folder PATH listing
Volume serial number is 92D5-A751
C:\USERS\THIAG\DOWNLOADS\LIBZT\DIST\WIN-X64-HOST-RELEASE
├───bin
└───lib
Note
CMake Error at CMakeLists.txt:2 (project):
Generator
Visual Studio 16 2019
could not find any instance of Visual Studio.
- In
build.ps1
changed two places that hadVisual Studio 16 2019
toVisual Studio 17 2022
- Deleted
cache
folder (created in the last run) - Retried
. .\build.ps1; Build-Host -BuildType "Release" -Arch "x64"
- Error
Error
Many times mentioning missing nlohmann/json.hpp
.
C:\Users\thiag\Downloads\libzt\ext\ZeroTierOne\osdep\OSUtils.hpp(46,10): error C1083: Cannot open include file: 'nlohmann/json.hpp': No such file or directory [C:\Users\thiag\Downloads\libzt\cache\win-x64-host-release\
zto_obj.vcxproj]
(compiling source file '../../ext/ZeroTierOne/node/Bond.cpp')
Note
@jbatnozic mention how to fix nlohmann/json
error in #263.
- Added
include_directories(${ZTO_SRC_DIR}/ext/)
inCMakeLists.txt
- Retried
. .\build.ps1; Build-Host -BuildType "Release" -Arch "x64"
- Script finished
Error
When using it.
link /nologo /OUT:main.exe /LIBPATH:lib libzt.lib main.obj
main.obj : error LNK2019: unresolved external symbol __imp_zts_addr_get_str referenced in function main
main.obj : error LNK2019: unresolved external symbol __imp_zts_net_join referenced in function main
main.obj : error LNK2019: unresolved external symbol __imp_zts_net_transport_is_ready referenced in function main
main.obj : error LNK2019: unresolved external symbol __imp_zts_node_start referenced in function main
main.obj : error LNK2019: unresolved external symbol __imp_zts_node_is_online referenced in function main
main.obj : error LNK2019: unresolved external symbol __imp_zts_node_get_id referenced in function main
main.obj : error LNK2019: unresolved external symbol __imp_zts_node_stop referenced in function main
main.obj : error LNK2019: unresolved external symbol __imp_zts_util_delay referenced in function main
Note
It's copying the wrong .lib
in line 20.
Creating static library in windows will generate .lib
.
Creating shared library in windows will generate .dll
and .lib
(not the same as static .lib
).
Lines 20 to 23 in 2f0f25a
- Changed line 20 to
cp $env:BuildDir\lib\$BuildType\zt-shared.lib $env:OutputDir\lib\libzt.lib
- Retried
. .\build.ps1; Build-Host -BuildType "Release" -Arch "x64"
- Script finished
- Executed code to test
- Error
Error
When using it through terminal nothing happens.
PS C:\Users\thiag\Downloads\testing_libzt> ./main.exe
PS C:\Users\thiag\Downloads\testing_libzt>
Code
#include "zerotier/ZeroTierSockets.h"
#include <stdio.h>
int main(void) {
printf("---Start\n"); // This is never printed
long long net_id = 0x0cccb752f7bdf645;
zts_node_start();
}
Note
- Renamed to
zt-shared.dll
(lazy way to solve) - Moved to same folder as
main.exe
- Executed code to test
- Success
Thank you for this. Was a huge help!