TarsCloud / TarsCpp

C++ language framework rpc source code implementation
BSD 3-Clause "New" or "Revised" License
520 stars 254 forks source link

[MSVC] Failed to build due to error C1083: Cannot open include file: 'unistd.h': No such file or directory on Windows #311

Closed Zhaojun-Liu closed 1 month ago

Zhaojun-Liu commented 1 month ago

Hi: 我使用MSVC在Windows上构建最新的TarsCpp(commit: 5efade0),出现以下错误,请问能否看下这个问题该怎么解决呢?非常感谢。 C:\gitP\TarsCloud\TarsCpp\util\include\util\tc_serialport.h(10,10): error C1083: Cannot open include file: 'unistd.h': No such file or directory (C:\repos\msvc\src\vctools\Compiler\CxxFE\sl\p1\c\p0prepro.c:2080) [C:\gitP\TarsCloud\TarsCpp\build_amd64\util\src\tarsutil.vcxproj]

我发现这个问题是从这个commit(970a383f15467f16c2075bf1c233f0639a1a6760)开始出现的,我看了咱们仓库基于Windows的CI, 也存在这个问题。

重现步骤:

  1. Open VS2022 x64 Native Tools command.
  2. git clone https://github.com/TarsCloud/TarsCpp C:\gitP\TarsCloud
  3. mkdir C:\gitP\TarsCloud\TarsCpp\build_amd64 & cd C:\gitP\TarsCloud\TarsCpp\build_amd64
  4. cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.22621.0 ..
  5. msbuild /m /p:Platform=x64 /p:Configuration=Release tars-cpp.sln /t:Rebuild

期望结果:构建通过。 实际结果: C:\gitP\TarsCloud\TarsCpp\util\include\util\tc_serialport.h(10,10): error C1083: Cannot open include file: 'unistd.h': No such file or directory (C:\repos\msvc\src\vctools\Compiler\CxxFE\sl\p1\c\p0prepro.c:2080) [C:\gitP\TarsCloud\TarsCpp\build_amd64\util\src\tarsutil.vcxproj]

ruanshudong commented 1 month ago

fix , 再试一试

Zhaojun-Liu commented 1 month ago

fix , 再试一试

试了,构建通过。谢谢 😃 ~~~