Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Script fail in Windows #270

Open
thiagola92 opened this issue Feb 16, 2024 · 6 comments
Open

Script fail in Windows #270

thiagola92 opened this issue Feb 16, 2024 · 6 comments

Comments

@thiagola92
Copy link

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
@thiagola92
Copy link
Author

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 had Visual Studio 16 2019 to Visual 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')

@thiagola92
Copy link
Author

thiagola92 commented Feb 16, 2024

Note

@jbatnozic mention how to fix nlohmann/json error in #263.

  • Added include_directories(${ZTO_SRC_DIR}/ext/) in CMakeLists.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

@thiagola92
Copy link
Author

thiagola92 commented Mar 12, 2024

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).

libzt/build.ps1

Lines 20 to 23 in 2f0f25a

cp $env:BuildDir\lib\$BuildType\zt.lib $env:OutputDir\lib\libzt.lib
cp $env:BuildDir\bin\$BuildType\*.exe $env:OutputDir\bin
cp $env:BuildDir\lib\$BuildType\zt-shared.dll $env:OutputDir\lib\libzt.dll
cp $env:BuildDir\lib\$BuildType\zt-shared.pdb $env:OutputDir\lib\libzt.pdb -ErrorAction:'silentlycontinue'

  • 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();
}

When double clicking main.exe
Message "The code execution cannot proceed because zt-shared.dll was not found. Reinstalling th eprogram may fix this problem."

@thiagola92
Copy link
Author

thiagola92 commented Mar 12, 2024

Note

  • Renamed to zt-shared.dll (lazy way to solve)
  • Moved to same folder as main.exe
  • Executed code to test
  • Success

@Decstar77
Copy link

Thank you for this. Was a huge help!

@volga629-1
Copy link

Hello Everyone,
I need some help with build,

I am getting error

PS C:\Users\volga629\Desktop\testing\libzt\libzt> . .\build.ps1; Build-Host -BuildType "Release" -Arch "x64"

    Directory: C:\Users\volga629\Desktop\testing\libzt\libzt\cache

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----            9/9/2024  8:13 PM                win-x64-host-release
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.


-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.41.34120.0
-- The CXX compiler identification is MSVC 19.41.34120.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostarm64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostarm64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
--
-- WS2_32=/WS2_32.Lib
-- ShLwApi=/ShLwApi.Lib
-- liphlpapi=/iphlpapi.Lib
-- Configuring done (14.0s)
CMake Error at CMakeLists.txt:567 (add_library):
  No SOURCES given to target: zto_obj


CMake Error at CMakeLists.txt:576 (add_library):
  No SOURCES given to target: libnatpmp_obj


CMake Error at CMakeLists.txt:580 (add_library):
  No SOURCES given to target: miniupnpc_obj


CMake Error at CMakeLists.txt:599 (add_library):
  No SOURCES given to target: lwip_obj


CMake Error at CMakeLists.txt:610 (add_library):
  No SOURCES given to target: zto_pic


CMake Error at CMakeLists.txt:615 (add_library):
  No SOURCES given to target: natpmp_pic


CMake Error at CMakeLists.txt:620 (add_library):
  No SOURCES given to target: miniupnpc_pic


CMake Error at CMakeLists.txt:638 (add_library):
  No SOURCES given to target: lwip_pic


CMake Error at CMakeLists.txt:653 (add_library):
  No SOURCES given to target: ztcore


CMake Generate step failed.  Build files cannot be regenerated correctly.
CMake is re-running because C:/Users/volga629/Desktop/testing/libzt/libzt/cache/win-x64-host-release/CMakeFiles/generate.stamp dependency file is missing.
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.


-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- 
-- WS2_32=/WS2_32.Lib
-- ShLwApi=/ShLwApi.Lib
-- liphlpapi=/iphlpapi.Lib
-- Configuring done (0.1s)
CMake Error at CMakeLists.txt:567 (add_library):
  No SOURCES given to target: zto_obj


CMake Error at CMakeLists.txt:576 (add_library):
  No SOURCES given to target: libnatpmp_obj


CMake Error at CMakeLists.txt:580 (add_library):
  No SOURCES given to target: miniupnpc_obj


CMake Error at CMakeLists.txt:599 (add_library):
  No SOURCES given to target: lwip_obj


CMake Error at CMakeLists.txt:610 (add_library):
  No SOURCES given to target: zto_pic


CMake Error at CMakeLists.txt:615 (add_library):
  No SOURCES given to target: natpmp_pic


CMake Error at CMakeLists.txt:620 (add_library):
  No SOURCES given to target: miniupnpc_pic


CMake Error at CMakeLists.txt:638 (add_library):
  No SOURCES given to target: lwip_pic


CMake Error at CMakeLists.txt:653 (add_library):
  No SOURCES given to target: ztcore


CMake Generate step failed.  Build files cannot be regenerated correctly.
Test project C:/Users/volga629/Desktop/testing/libzt/libzt/cache/win-x64-host-release
No tests were found!!!
Copy-Item: C:\Users\volga629\Desktop\testing\libzt\libzt\build.ps1:20:2
Line |
  20 |      cp $env:BuildDir\lib\$BuildType\zt.lib $env:OutputDir\lib\libzt.l …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path
     | 'C:\Users\volga629\Desktop\testing\libzt\libzt\cache\win-x64-host-release\lib\Release\zt.lib' because it  
     | does not exist.
Copy-Item: C:\Users\volga629\Desktop\testing\libzt\libzt\build.ps1:21:2
Line |
  21 |      cp $env:BuildDir\bin\$BuildType\*.exe $env:OutputDir\bin
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path 'C:\Users\volga629\Desktop\testing\libzt\libzt\cache\win-x64-host-release\bin\Release'   
     | because it does not exist.
Copy-Item: C:\Users\volga629\Desktop\testing\libzt\libzt\build.ps1:22:2
Line |
  22 |      cp $env:BuildDir\lib\$BuildType\zt-shared.dll $env:OutputDir\lib\ …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path
     | 'C:\Users\volga629\Desktop\testing\libzt\libzt\cache\win-x64-host-release\lib\Release\zt-shared.dll'      
     | because it does not exist.
Folder PATH listing
Volume serial number is 00000157 36A3:8730
C:\USERS\VOLGA629\DESKTOP\TESTING\LIBZT\LIBZT\DIST\WIN-X64-HOST-RELEASE
├───bin
└───lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants