conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.08k stars 959 forks source link

[question] How to cross-build from Linux to Windows using clang? #15655

Open Todiq opened 6 months ago

Todiq commented 6 months ago

What is your question?

Hello,

I would like to create CI jobs that run exclusively on linux runners. Since people in my company use Visual Studio extensively, I have to make my jobs able to create a 1:1 executable that the developers would get when compiling locally on their Windows machines.

I decided to go for clang for that purpose. I had to exclude any mingw-related compilers since (from what I understood), it would only target x86_64-pc-windows-gnu, while I need to target x86_64-pc-windows-msvc.

To test just that, I installed the Windows SDK 10.0.22621 on a docker container and created the following test.cpp:

#include <iostream>

int main()
{
        std::cout << "Hello World!" << std::endl;
        return 0;
}

And indeed, running this command clang++-16 -v -fcolor-diagnostics -target x86_64-pc-windows-msvc -L/opt/win-sdk/10.0.22621/crt/lib/x86_64 -L/opt/win-sdk/10.0.22621/sdk/lib/ucrt/x86_64 -L/opt/win-sdk/10.0.22621/sdk/lib/um/x86_64 -I/opt/win-sdk/10.0.22621/crt/include -I/opt/win-sdk/10.0.22621/sdk/include/cppwinrt/ -I/opt/win-sdk/10.0.22621/sdk/include/shared/ -I/opt/win-sdk/10.0.22621/sdk/include/ucrt/ -I/opt/win-sdk/10.0.22621/sdk/include/um/ -I/opt/win-sdk/10.0.22621/sdk/include/winrt/ -flto -march=x86-64-v3 -fuse-ld=lld test.cpp generates the following output and properly creates the executable:

Log ```bash clang++-16 -v -fcolor-diagnostics -target x86_64-pc-windows-msvc -L/opt/win-sdk/10.0.22621/crt/lib/x86_64 -L/opt/win-sdk/10.0.22621/sdk/lib/ucrt/x86_64 -L/opt/win-sdk/10.0.22621/sdk/lib/um/x86_64 -I/opt/win-sdk/10.0.22621/crt/include -I/opt/win-sdk/10.0.22621/sdk/include/cppwinrt/ -I/opt/win-sdk/10.0.22621/sdk/include/shared/ -I/opt/win-sdk/10.0.22621/sdk/include/ucrt/ -I/opt/win-sdk/10.0.22621/sdk/include/um/ -I/opt/win-sdk/10.0.22621/sdk/include/winrt/ -flto -march=x86-64-v3 -fuse-ld=lld test.cpp Debian clang version 16.0.6 (15~deb12u1) Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: /usr/bin "/usr/lib/llvm-16/bin/clang" -cc1 -triple x86_64-pc-windows-msvc19.20.0 -emit-llvm-bc -flto=full -flto-unit -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64-v3 -mllvm -treat-scalable-fixed-error-as-warning -v -fcoverage-compilation-dir=/workspace -resource-dir /usr/lib/llvm-16/lib/clang/16 -I /opt/win-sdk/10.0.22621/crt/include -I /opt/win-sdk/10.0.22621/sdk/include/cppwinrt/ -I /opt/win-sdk/10.0.22621/sdk/include/shared/ -I /opt/win-sdk/10.0.22621/sdk/include/ucrt/ -I /opt/win-sdk/10.0.22621/sdk/include/um/ -I /opt/win-sdk/10.0.22621/sdk/include/winrt/ -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -fdeprecated-macro -fdebug-compilation-dir=/workspace -ferror-limit 19 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.20 -std=c++14 -fdelayed-template-parsing -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o /tmp/test-ad3003.o -x c++ test.cpp clang -cc1 version 16.0.6 based upon LLVM 16.0.6 default target x86_64-pc-linux-gnu #include "..." search starts here: #include <...> search starts here: /opt/win-sdk/10.0.22621/crt/include /opt/win-sdk/10.0.22621/sdk/include/cppwinrt /opt/win-sdk/10.0.22621/sdk/include/shared /opt/win-sdk/10.0.22621/sdk/include/ucrt /opt/win-sdk/10.0.22621/sdk/include/um /opt/win-sdk/10.0.22621/sdk/include/winrt /usr/lib/llvm-16/lib/clang/16/include End of search list. In file included from test.cpp:1: In file included from /opt/win-sdk/10.0.22621/crt/include/iostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/istream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ios:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xlocnum:12: In file included from /opt/win-sdk/10.0.22621/crt/include/cstdio:11: In file included from /opt/win-sdk/10.0.22621/sdk/include/ucrt/stdio.h:12: /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt_wstdio.h:1486:1: warning: attribute declaration must precede definition [-Wignored-attributes] __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt.h:1788:13: note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX' _CRT_INSECURE_DEPRECATE(_FuncName##_s) _DeclSpec _ReturnType _CC _FuncName(_SalAttributeDst _DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, ...); \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:355:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE' #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:345:47: note: expanded from macro '_CRT_DEPRECATE_TEXT' #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text)) ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt_wstdio.h:1403:33: note: previous definition is here _CRT_STDIO_INLINE int __CRTDECL __swprintf_l( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt_wstdio.h:1486:1: warning: attribute declaration must precede definition [-Wignored-attributes] __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt.h:1789:13: note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX' _CRT_INSECURE_DEPRECATE(_SecureVFuncName) _DeclSpec _ReturnType _CC _VFuncName(_SalAttributeDst _DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _Args); ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:355:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE' #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:345:47: note: expanded from macro '_CRT_DEPRECATE_TEXT' #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text)) ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt_wstdio.h:1205:33: note: previous definition is here _CRT_STDIO_INLINE int __CRTDECL __vswprintf_l( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt_wstdio.h:1495:1: warning: attribute declaration must precede definition [-Wignored-attributes] __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt.h:1784:13: note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX' _CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType _CC _FuncName(_SalAttributeDst _DstType *_Dst, _TType1 _TArg1, ...); \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:355:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE' #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:345:47: note: expanded from macro '_CRT_DEPRECATE_TEXT' #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text)) ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt_wstdio.h:1444:33: note: previous definition is here _CRT_STDIO_INLINE int __CRTDECL _swprintf( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt_wstdio.h:1495:1: warning: attribute declaration must precede definition [-Wignored-attributes] __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt.h:1785:13: note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX' _CRT_INSECURE_DEPRECATE(_SecureVFuncName) _DeclSpec _ReturnType _CC _VFuncName(_SalAttributeDst _DstType *_Dst, _TType1 _TArg1, va_list _Args); ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:355:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE' #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:345:47: note: expanded from macro '_CRT_DEPRECATE_TEXT' #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text)) ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt_wstdio.h:1221:33: note: previous definition is here _CRT_STDIO_INLINE int __CRTDECL _vswprintf( ^ In file included from test.cpp:1: In file included from /opt/win-sdk/10.0.22621/crt/include/iostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/istream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ios:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xlocnum:12: In file included from /opt/win-sdk/10.0.22621/crt/include/cstdio:11: /opt/win-sdk/10.0.22621/sdk/include/ucrt/stdio.h:1793:1: warning: attribute declaration must precede definition [-Wignored-attributes] __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt.h:703:5: note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST' __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _CC, _FuncName, _FuncName##_s, _VFuncName, _VFuncName##_s, _SalAttributeDst, _DstType, _Dst, _TType1, _TArg1) ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt.h:1784:13: note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX' _CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType _CC _FuncName(_SalAttributeDst _DstType *_Dst, _TType1 _TArg1, ...); \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:355:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE' #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:345:47: note: expanded from macro '_CRT_DEPRECATE_TEXT' #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text)) ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/stdio.h:1769:33: note: previous definition is here _CRT_STDIO_INLINE int __CRTDECL sprintf( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/stdio.h:1971:1: warning: attribute declaration must precede definition [-Wignored-attributes] __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt.h:1830:13: note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX' _CRT_INSECURE_DEPRECATE(_FuncName##_s) _DeclSpec _ReturnType _CC _FuncName(_SalAttributeDst _DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, ...); \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:355:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE' #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:345:47: note: expanded from macro '_CRT_DEPRECATE_TEXT' #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text)) ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/stdio.h:1952:33: note: previous definition is here _CRT_STDIO_INLINE int __CRTDECL _snprintf( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/stdio.h:1971:1: warning: attribute declaration must precede definition [-Wignored-attributes] __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX( ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/corecrt.h:1831:13: note: expanded from macro '__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX' _CRT_INSECURE_DEPRECATE(_VFuncName##_s) _DeclSpec _ReturnType _CC _VFuncName(_SalAttributeDst _DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _Args); ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:355:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE' #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \ ^ /opt/win-sdk/10.0.22621/crt/include/vcruntime.h:345:47: note: expanded from macro '_CRT_DEPRECATE_TEXT' #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text)) ^ /opt/win-sdk/10.0.22621/sdk/include/ucrt/stdio.h:1396:33: note: previous definition is here _CRT_STDIO_INLINE int __CRTDECL _vsnprintf( ^ In file included from test.cpp:1: In file included from /opt/win-sdk/10.0.22621/crt/include/iostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/istream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ios:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xlocnum:15: In file included from /opt/win-sdk/10.0.22621/crt/include/streambuf:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xiosbase:11: In file included from /opt/win-sdk/10.0.22621/crt/include/system_error:13: In file included from /opt/win-sdk/10.0.22621/crt/include/stdexcept:11: In file included from /opt/win-sdk/10.0.22621/crt/include/xstring:14: In file included from /opt/win-sdk/10.0.22621/crt/include/xmemory:12: In file included from /opt/win-sdk/10.0.22621/crt/include/limits:15: In file included from /opt/win-sdk/10.0.22621/crt/include/intrin.h:35: In file included from /opt/win-sdk/10.0.22621/crt/include/immintrin.h:30: In file included from /opt/win-sdk/10.0.22621/crt/include/wmmintrin.h:31: In file included from /opt/win-sdk/10.0.22621/crt/include/nmmintrin.h:32: In file included from /opt/win-sdk/10.0.22621/crt/include/smmintrin.h:32: In file included from /opt/win-sdk/10.0.22621/crt/include/tmmintrin.h:25: In file included from /opt/win-sdk/10.0.22621/crt/include/pmmintrin.h:34: In file included from /opt/win-sdk/10.0.22621/crt/include/emmintrin.h:38: In file included from /opt/win-sdk/10.0.22621/crt/include/xmmintrin.h:46: /opt/win-sdk/10.0.22621/crt/include/mmintrin.h:34:26: warning: __declspec attribute 'intrin_type' is not supported [-Wignored-attributes] typedef union __declspec(intrin_type) __declspec(align(8)) __m64 ^~~~~~~~~~~ In file included from test.cpp:1: In file included from /opt/win-sdk/10.0.22621/crt/include/iostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/istream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ios:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xlocnum:15: In file included from /opt/win-sdk/10.0.22621/crt/include/streambuf:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xiosbase:11: In file included from /opt/win-sdk/10.0.22621/crt/include/system_error:13: In file included from /opt/win-sdk/10.0.22621/crt/include/stdexcept:11: In file included from /opt/win-sdk/10.0.22621/crt/include/xstring:14: In file included from /opt/win-sdk/10.0.22621/crt/include/xmemory:12: In file included from /opt/win-sdk/10.0.22621/crt/include/limits:15: In file included from /opt/win-sdk/10.0.22621/crt/include/intrin.h:35: In file included from /opt/win-sdk/10.0.22621/crt/include/immintrin.h:30: In file included from /opt/win-sdk/10.0.22621/crt/include/wmmintrin.h:31: In file included from /opt/win-sdk/10.0.22621/crt/include/nmmintrin.h:32: In file included from /opt/win-sdk/10.0.22621/crt/include/smmintrin.h:32: In file included from /opt/win-sdk/10.0.22621/crt/include/tmmintrin.h:25: In file included from /opt/win-sdk/10.0.22621/crt/include/pmmintrin.h:34: In file included from /opt/win-sdk/10.0.22621/crt/include/emmintrin.h:38: /opt/win-sdk/10.0.22621/crt/include/xmmintrin.h:65:26: warning: __declspec attribute 'intrin_type' is not supported [-Wignored-attributes] typedef union __declspec(intrin_type) __declspec(align(16)) __m128 { ^~~~~~~~~~~ In file included from test.cpp:1: In file included from /opt/win-sdk/10.0.22621/crt/include/iostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/istream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ios:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xlocnum:15: In file included from /opt/win-sdk/10.0.22621/crt/include/streambuf:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xiosbase:11: In file included from /opt/win-sdk/10.0.22621/crt/include/system_error:13: In file included from /opt/win-sdk/10.0.22621/crt/include/stdexcept:11: In file included from /opt/win-sdk/10.0.22621/crt/include/xstring:14: In file included from /opt/win-sdk/10.0.22621/crt/include/xmemory:12: In file included from /opt/win-sdk/10.0.22621/crt/include/limits:15: In file included from /opt/win-sdk/10.0.22621/crt/include/intrin.h:35: In file included from /opt/win-sdk/10.0.22621/crt/include/immintrin.h:30: In file included from /opt/win-sdk/10.0.22621/crt/include/wmmintrin.h:31: In file included from /opt/win-sdk/10.0.22621/crt/include/nmmintrin.h:32: In file included from /opt/win-sdk/10.0.22621/crt/include/smmintrin.h:32: In file included from /opt/win-sdk/10.0.22621/crt/include/tmmintrin.h:25: In file included from /opt/win-sdk/10.0.22621/crt/include/pmmintrin.h:34: /opt/win-sdk/10.0.22621/crt/include/emmintrin.h:40:26: warning: __declspec attribute 'intrin_type' is not supported [-Wignored-attributes] typedef union __declspec(intrin_type) __declspec(align(16)) __m128i { ^~~~~~~~~~~ /opt/win-sdk/10.0.22621/crt/include/emmintrin.h:51:27: warning: __declspec attribute 'intrin_type' is not supported [-Wignored-attributes] typedef struct __declspec(intrin_type) __declspec(align(16)) __m128d { ^~~~~~~~~~~ In file included from test.cpp:1: In file included from /opt/win-sdk/10.0.22621/crt/include/iostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/istream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ios:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xlocnum:15: In file included from /opt/win-sdk/10.0.22621/crt/include/streambuf:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xiosbase:11: In file included from /opt/win-sdk/10.0.22621/crt/include/system_error:13: In file included from /opt/win-sdk/10.0.22621/crt/include/stdexcept:11: In file included from /opt/win-sdk/10.0.22621/crt/include/xstring:14: In file included from /opt/win-sdk/10.0.22621/crt/include/xmemory:12: In file included from /opt/win-sdk/10.0.22621/crt/include/limits:15: In file included from /opt/win-sdk/10.0.22621/crt/include/intrin.h:35: /opt/win-sdk/10.0.22621/crt/include/immintrin.h:39:26: warning: __declspec attribute 'intrin_type' is not supported [-Wignored-attributes] typedef union __declspec(intrin_type) __declspec(align(32)) __m256 { ^~~~~~~~~~~ /opt/win-sdk/10.0.22621/crt/include/immintrin.h:43:27: warning: __declspec attribute 'intrin_type' is not supported [-Wignored-attributes] typedef struct __declspec(intrin_type) __declspec(align(32)) __m256d { ^~~~~~~~~~~ /opt/win-sdk/10.0.22621/crt/include/immintrin.h:47:27: warning: __declspec attribute 'intrin_type' is not supported [-Wignored-attributes] typedef union __declspec(intrin_type) __declspec(align(32)) __m256i { ^~~~~~~~~~~ In file included from test.cpp:1: In file included from /opt/win-sdk/10.0.22621/crt/include/iostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/istream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ostream:10: In file included from /opt/win-sdk/10.0.22621/crt/include/ios:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xlocnum:15: In file included from /opt/win-sdk/10.0.22621/crt/include/streambuf:10: In file included from /opt/win-sdk/10.0.22621/crt/include/xiosbase:11: In file included from /opt/win-sdk/10.0.22621/crt/include/system_error:13: In file included from /opt/win-sdk/10.0.22621/crt/include/stdexcept:11: In file included from /opt/win-sdk/10.0.22621/crt/include/xstring:14: In file included from /opt/win-sdk/10.0.22621/crt/include/xmemory:12: In file included from /opt/win-sdk/10.0.22621/crt/include/limits:15: In file included from /opt/win-sdk/10.0.22621/crt/include/intrin.h:35: In file included from /opt/win-sdk/10.0.22621/crt/include/immintrin.h:2467: /opt/win-sdk/10.0.22621/crt/include/zmmintrin.h:47:26: warning: __declspec attribute 'intrin_type' is not supported [-Wignored-attributes] typedef union __declspec(intrin_type) __declspec(align(64)) __m512 { ^~~~~~~~~~~ /opt/win-sdk/10.0.22621/crt/include/zmmintrin.h:51:27: warning: __declspec attribute 'intrin_type' is not supported [-Wignored-attributes] typedef struct __declspec(intrin_type) __declspec(align(64)) __m512d { ^~~~~~~~~~~ /opt/win-sdk/10.0.22621/crt/include/zmmintrin.h:55:27: warning: __declspec attribute 'intrin_type' is not supported [-Wignored-attributes] typedef union __declspec(intrin_type) __declspec(align(64)) __m512i { ^~~~~~~~~~~ 17 warnings generated. "/usr/lib/llvm-16/bin/lld-link" -out:a.exe -defaultlib:libcmt -defaultlib:oldnames -libpath:lib/amd64 -libpath:atlmfc/lib/amd64 -libpath:/opt/win-sdk/10.0.22621/crt/lib/x86_64 -libpath:/opt/win-sdk/10.0.22621/sdk/lib/ucrt/x86_64 -libpath:/opt/win-sdk/10.0.22621/sdk/lib/um/x86_64 -nologo /tmp/test-ad3003.o ```

For some reason, I get a lot more warnings than I do with clang on Windows, but it still compiles. However, I am unable to reproduce the same with conan. There must be a mistake with my profiles. conan build core -pr windows-x86_64 -pr:b clang-x86_64 --build=missing returns:

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.runtime_version=v143
compiler.version=16
os=Windows
[conf]
tools.build:compiler_executables={'c': 'clang-16', 'cpp': 'clang++-16'}
tools.build:cxxflags=['-v -fcolor-diagnostics', '-target x86_64-pc-windows-msvc', '-L/opt/win-sdk/10.0.22621/crt/lib/x86_64 -L/opt/win-sdk/10.0.22621/sdk/lib/ucrt/x86_64 -L/opt/win-sdk/10.0.22621/sdk/lib/um/x86_64', '-I/opt/win-sdk/10.0.22621/crt/include -I/opt/win-sdk/10.0.22621/sdk/include/cppwinrt/ -I/opt/win-sdk/10.0.22621/sdk/include/shared/ -I/opt/win-sdk/10.0.22621/sdk/include/ucrt/ -I/opt/win-sdk/10.0.22621/sdk/include/um/ -I/opt/win-sdk/10.0.22621/sdk/include/winrt/', '-flto -march=x86-64-v3']
tools.build:exelinkflags=['-fuse-ld=lld']
tools.build:sharedlinkflags=['-fuse-ld=lld']
tools.cmake.cmaketoolchain:generator=Ninja
tools.microsoft.msbuild:installation_path="/opt/win-sdk/10.0.22621"
tools.microsoft.msbuild:vs_version=17

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=16
os=Linux
[conf]
tools.build:compiler_executables={'c': 'clang-16', 'cpp': 'clang++-16'}
tools.build:exelinkflags=['-fuse-ld=lld']
tools.build:sharedlinkflags=['-fuse-ld=lld']
tools.cmake.cmaketoolchain:generator=Ninja

======== Computing dependency graph ========
Graph root
    conanfile.py (castcore/1.1): /workspace/core/conanfile.py

======== Computing necessary packages ========

======== Installing packages ========

======== Installing packages ========

======== Finalizing install (deploy, generators) ========
conanfile.py (castcore/1.1): Calling generate()
conanfile.py (castcore/1.1): Generators folder: /workspace/core/build/windows-clang-16-x86_64/Release/generators
conanfile.py (castcore/1.1): CMakeToolchain generated: conan_toolchain.cmake
ERROR: conanfile.py (castcore/1.1): Error in generate() method, line 84
        ct.generate()
        ConanException: VS non-existing installation: Visual Studio 17. If using a non-default toolset from a VS IDE version consider specifying it with the 'tools.microsoft.msbuild:vs_version' conf

Could you please indicate me what is wrong? Thanks in advance!

Have you read the CONTRIBUTING guide?

memsharded commented 6 months ago

Hi @Todiq

Thanks for your question.

The truth is that this cross-compilation is not that thoroughly investigated and tested. I know from some users that they have been able to cross-build from Linux to Windows, but if I recall correctly, they were mostly using mingw based toolchains.

I have no clear idea of what is the gap, I'll try someone in the team to have a look. But I think I'd start with:

tools.microsoft.msbuild:installation_path="/opt/win-sdk/10.0.22621"
tools.microsoft.msbuild:vs_version=17

These are very intended for Windows based VS installations. These probably don't work at all in Linux. I'd try to remove them and write a clang_linux_win_toolchain.cmake that I'd pass to tools.cmake.cmaketoolchain:user_toolchain to add or to tools.cmake.cmaketoolchain:toolchain_file to replace the standard one if necessary.

sykhro commented 6 months ago

tools.build:cxxflags=['-v -fcolor-diagnostics', '-target x86_64-pc-windows-msvc', '-L/opt/win-sdk/10.0.22621/crt/lib/x86_64 -L/opt/win-sdk/10.0.22621/sdk/lib/ucrt/x86_64 -L/opt/win-sdk/10.0.22621/sdk/lib/um/x86_64', '-I/opt/win-sdk/10.0.22621/crt/include -I/opt/win-sdk/10.0.22621/sdk/include/cppwinrt/ -I/opt/win-sdk/10.0.22621/sdk/include/shared/ -I/opt/win-sdk/10.0.22621/sdk/include/ucrt/ -I/opt/win-sdk/10.0.22621/sdk/include/um/ -I/opt/win-sdk/10.0.22621/sdk/include/winrt/', '-flto -march=x86-64-v3'] tools.build:exelinkflags=['-fuse-ld=lld'] tools.build:sharedlinkflags=['-fuse-ld=lld'] tools.cmake.cmaketoolchain:generator=Ninja tools.microsoft.msbuild:installation_path="/opt/win-sdk/10.0.22621" tools.microsoft.msbuild:vs_version=17

The easiest (and most common?) way to do this is via clang-cl (which has the additional advantage of appearing as MSVC, increasing compatibility with projects that don't do their clang checks properly):

clang-cl \
    --target=x86_64-pc-windows-msvc \
    -fuse-ld=lld \
    /winsdkdir <path_to_winsdk_root> \
    /vctoolsdir <path_to_crt_root> \
    /diasdkdir <path_to_the_diasdk_root>

I've used this in the past with Conan with no issues.

Todiq commented 6 months ago

Hello @sykhro,

Thanks for the info. How does one install clang-cl under Linux? In fact, I make sure of using the default package manager, since I want to create docker images for both amd64 & arm64 but don't want to have both compilers versions on both the architectures

sykhro commented 6 months ago

Hello @sykhro,

Thanks for the info. How does one install clang-cl under Linux? In fact, I make sure of using the default package manager, since I want to create docker images for both amd64 & arm64 but don't want to have both compilers versions on both the architectures

It should come bundled with clang, it might depend on your distribution. The most "default" clang build you can get is installing it using llvm.sh from llvm.org

sykhro commented 5 months ago

Point RC to llvm-rc. Then point CMAKE_MT to llvm-mt, or compile with /MANIFEST:NO

On 26 Feb 2024, at 17:48, Todiq @.***> wrote:

Hey @sykhro https://github.com/sykhro,

The llvm script ends up giving a heavy docker image, so I installed clang-cl through the apt package clang-tools-16 for now. Hopefully, I could work around it later with layers. I edited my host profile, but still cannot make it work:

@.***:/workspace# conan build core/ --profile:host windows-x86_64 --profile:build linux-x86_64

======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows [conf] tools.build:compiler_executables={'c': 'clang-cl-16', 'cpp': 'clang-cl-16'} tools.build:cxxflags=['-v -fcolor-diagnostics', '-target x86_64-pc-windows-msvc', '-L/opt/win-sdk/10.0.22621/crt/lib/x86_64 -L/opt/win-sdk/10.0.22621/sdk/lib/ucrt/x86_64 -L/opt/win-sdk/10.0.22621/sdk/lib/um/x86_64', '-I/opt/win-sdk/10.0.22621/crt/include -I/opt/win-sdk/10.0.22621/sdk/include/cppwinrt/ -I/opt/win-sdk/10.0.22621/sdk/include/shared/ -I/opt/win-sdk/10.0.22621/sdk/include/ucrt/ -I/opt/win-sdk/10.0.22621/sdk/include/um/ -I/opt/win-sdk/10.0.22621/sdk/include/winrt/', '-flto -march=x86-64-v3'] tools.build:exelinkflags=['-fuse-ld=lld'] tools.build:sharedlinkflags=['-fuse-ld=lld'] tools.cmake.cmaketoolchain:generator=Ninja Multi-Config

Profile build: [settings] arch=x86_64 build_type=Release compiler=clang compiler.cppstd=17 compiler.libcxx=libstdc++11 compiler.version=16 os=Linux [conf] tools.build:compiler_executables={'c': 'clang-16', 'cpp': 'clang++-16'} tools.build:cxxflags=['-fcolor-diagnostics'] tools.build:exelinkflags=['-fuse-ld=lld'] tools.build:sharedlinkflags=['-fuse-ld=lld'] tools.cmake.cmaketoolchain:generator=Ninja

======== Computing dependency graph ======== Graph root conanfile.py (castcore/1.1): /workspace/core/conanfile.py Requirements boost/1.81.0#21f2c671219d474104b5e55e09cd40ff - Cache icu/72.1#d24b2d30acae3dcb788e139112bcd7c6 - Cache libiconv/1.17#73fefc1b696e069df90fd1d18aa63edd - Cache libxml2/2.11.6#41c14895baba105865cb22ecaf948115 - Cache libxslt/1.1.34#2bdc1f5fe5db1df40f8465e485a19ee4 - Cache pugixml/1.13#f615c1fcec55122b2e177d17061276e7 - Cache xerces-c/3.2.4#c52d1d1bb36d1377471ec1e551a6598a - Cache Test requirements gtest/1.13.0#8a0bc5b3e159ed45de97260c2bff65b5 - Cache Build requirements b2/4.10.1#a41eecb267963ddf518e3c177eae60e1 - Cache cmake/3.28.1#92f79424d7b65b12a84a2180866c3a78 - Cache icu/72.1#d24b2d30acae3dcb788e139112bcd7c6 - Cache ninja/1.11.1#77587f8c8318662ac8e5a7867eb4be21 - Cache

======== Computing necessary packages ======== icu/72.1: Checking 11 compatible configurations icu/72.1: Compatible configurations not found in cache, checking servers icu/72.1: 'f4608c27d2d424b8c296ba6b9e60e99db4773e60': compiler.cppstd=98 icu/72.1: 'e05540f1fd257df0b84749f1c7ba0d3b177f1844': compiler.cppstd=gnu98 icu/72.1: 'e301a5a0eeb69b188ed1ad4ce246ca6745bb28d6': compiler.cppstd=11 icu/72.1: '9cd3656687e1d6e8a3f9756ed104fe6f948e1552': compiler.cppstd=gnu11 icu/72.1: 'af65f570cf50a0f849452bfe925a59b1f586d0f0': compiler.cppstd=14 icu/72.1: '6f00251d82d3c86732e8189344f0efbf9c4f8a5c': compiler.cppstd=gnu14 icu/72.1: '0d519caeef63d9b00cddf18f7715896bb5e5629d': compiler.cppstd=gnu17 icu/72.1: 'd216c88985f6580c212fd69cad493fe4e6074935': compiler.cppstd=20 icu/72.1: '9e96c6b675bc7ad6a99566b18763382a6abd3a17': compiler.cppstd=gnu20 icu/72.1: 'a2cfacb413a21cf4e55c655fef62c6ed8885de7f': compiler.cppstd=23 icu/72.1: '576a9202edb171ec9db75c81373692d5a1aec42d': compiler.cppstd=gnu23 Requirements boost/1.81.0#21f2c671219d474104b5e55e09cd40ff:e03785e977988d57a84487e4306a26c9018cabf0#a7170f9bc309d3e8c2697d2c10fef28d - Cache icu/72.1#d24b2d30acae3dcb788e139112bcd7c6:9f8165f8d74e26bf104abb2a5005a80d1101b198#3cb5da99fe9d01c55d1c5dbf13f35112 - Cache libiconv/1.17#73fefc1b696e069df90fd1d18aa63edd:7bfde258ff4f62f75668d0896dbddedaa7480a0f#9ef92719f5c05dca2f0dbb46f50d3f8d - Cache libxml2/2.11.6#41c14895baba105865cb22ecaf948115:a6cdd368afb04c4d9e5918696d661f8f5249a029#d4a7bc8cb16ca7e7411db8804a765032 - Cache libxslt/1.1.34#2bdc1f5fe5db1df40f8465e485a19ee4:4e7168dde525f5dbaf65a8b8f6b3280b6a7e87d7#a632a2a87954026a2d962070cbad7aa6 - Cache pugixml/1.13#f615c1fcec55122b2e177d17061276e7:da39a3ee5e6b4b0d3255bfef95601890afd80709#ae530054ed7ac99330514c13a5bfde3a - Cache xerces-c/3.2.4#c52d1d1bb36d1377471ec1e551a6598a:41c4e6767851fe7db56310649912b6259451a38f#0831576b3c913f5e3d1294aa2f05ee41 - Cache Test requirements gtest/1.13.0#8a0bc5b3e159ed45de97260c2bff65b5:9940e217936a0f218f90473d62bf1d4db55efaa7#f44bf478a18701d76b310497997d7b3b - Cache Build requirements cmake/3.28.1#92f79424d7b65b12a84a2180866c3a78:63fead0844576fc02943e16909f08fcdddd6f44b#501f62ef1d3711dd838dc1d91a2d866e - Cache ninja/1.11.1#77587f8c8318662ac8e5a7867eb4be21:3593751651824fb813502c69c971267624ced41a#60e6fc0f973babfbed66a66af22a4f02 - Cache Skipped binaries b2/4.10.1, icu/72.1

======== Installing packages ========

======== Installing packages ======== cmake/3.28.1: Already installed! (1 of 10) cmake/3.28.1: Appending PATH environment variable: /opt/conan/p/cmakecf6b18ccaa9f5/p/bin gtest/1.13.0: Already installed! (2 of 10) libiconv/1.17: Already installed! (3 of 10) ninja/1.11.1: Already installed! (4 of 10) pugixml/1.13: Already installed! (5 of 10) xerces-c/3.2.4: Already installed! (6 of 10) boost/1.81.0: Already installed! (7 of 10) boost/1.81.0: Disabled magic autolinking (smart and magic decisions) icu/72.1: Already installed! (8 of 10) libxml2/2.11.6: Already installed! (9 of 10) libxml2/2.11.6: Appending PATH environment variable: /opt/conan/p/libxm07501da66e843/p/bin libxslt/1.1.34: Already installed! (10 of 10) WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X: WARN: deprecated: 'env_info' used in: libxslt/1.1.34, icu/72.1, cmake/3.28.1, libiconv/1.17, libxml2/2.11.6, boost/1.81.0 WARN: deprecated: 'cpp_info.names' used in: libxslt/1.1.34, gtest/1.13.0, icu/72.1, libxml2/2.11.6, libiconv/1.17, boost/1.81.0 WARN: deprecated: 'cpp_info.filenames' used in: boost/1.81.0, libxml2/2.11.6 WARN: deprecated: 'user_info' used in: boost/1.81.0 WARN: deprecated: 'cpp_info.build_modules' used in: libxml2/2.11.6

======== Finalizing install (deploy, generators) ======== conanfile.py (castcore/1.1): Calling generate() conanfile.py (castcore/1.1): Generators folder: /workspace/core/build/windows-msvc-193-x86_64/generators conanfile.py (castcore/1.1): CMakeToolchain generated: conan_toolchain.cmake conanfile.py (castcore/1.1): Preset 'conan-windows-msvc-193-x86_64' added to CMakePresets.json. Invoke it manually using 'cmake --preset conan-windows-msvc-193-x86_64' if using CMake>=3.23 conanfile.py (castcore/1.1): If your CMake version is not compatible with CMakePresets (<3.23) call cmake like: 'cmake -G "Ninja Multi-Config" -DCMAKE_TOOLCHAIN_FILE=/workspace/core/build/windows-msvc-193-x86_64/generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW' conanfile.py (castcore/1.1): CMakeToolchain generated: CMakePresets.json conanfile.py (castcore/1.1): CMakeToolchain generated: ../../../CMakeUserPresets.json conanfile.py (castcore/1.1): CMakeDeps necessary find_package() and targets for your CMakeLists.txt find_package(Boost) find_package(ICU) find_package(LibXslt) find_package(libxml2) find_package(pugixml) find_package(XercesC) find_package(GTest) target_link_libraries(... boost::boost icu::icu libxslt::libxslt LibXml2::LibXml2 pugixml::pugixml XercesC::XercesC gtest::gtest) conanfile.py (castcore/1.1): Generating aggregated env files conanfile.py (castcore/1.1): Generated aggregated env files: ['conanbuild.sh', 'conanrun.bat']

======== Calling build() ======== conanfile.py (castcore/1.1): Calling build() conanfile.py (castcore/1.1): Running CMake.configure() conanfile.py (castcore/1.1): RUN: cmake -G "Ninja Multi-Config" -DCMAKE_TOOLCHAIN_FILE="/workspace/core/build/windows-msvc-193-x86_64/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/workspace/core" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "/workspace/core" -- Using Conan toolchain: /workspace/core/build/windows-msvc-193-x86_64/generators/conan_toolchain.cmake -- Conan toolchain: C++ Standard 14 with extensions OFF -- Conan toolchain: Setting BUILD_SHARED_LIBS = ON -- The CXX compiler identification is Clang 16.0.6 with MSVC-like command-line -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - failed -- Check for working CXX compiler: /usr/bin/clang-cl-16 -- Check for working CXX compiler: /usr/bin/clang-cl-16 - broken CMake Error at /opt/conan/p/cmakecf6b18ccaa9f5/p/share/cmake-3.28/Modules/CMakeTestCXXCompiler.cmake:60 (message): The C++ compiler

"/usr/bin/clang-cl-16"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: '/workspace/core/build/windows-msvc-193-x86_64/CMakeFiles/CMakeScratch/TryCompile-VhCB9K'

Run Build Command(s): /opt/conan/p/ninja6fed3c8400c5b/p/bin/ninja -v cmTC_26ded
[1/2] /usr/bin/clang-cl-16  /nologo -TP -DCMAKE_INTDIR=\"Debug\"  /DWIN32 /D_WINDOWS /EHsc  /Zi /Ob0 /Od /RTC1 -std:c++14 /showIncludes /FoCMakeFiles/cmTC_26ded.dir/Debug/testCXXCompiler.cxx.obj /FdCMakeFiles/cmTC_26ded.dir/Debug/ -c -- /workspace/core/build/windows-msvc-193-x86_64/CMakeFiles/CMakeScratch/TryCompile-VhCB9K/testCXXCompiler.cxx
[2/2] : && /opt/conan/p/cmakecf6b18ccaa9f5/p/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_26ded.dir/Debug --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- /usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_26ded.dir/Debug/testCXXCompiler.cxx.obj  /out:Debug/cmTC_26ded.exe /implib:Debug/cmTC_26ded.lib /pdb:Debug/cmTC_26ded.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && :
FAILED: Debug/cmTC_26ded.exe
: && /opt/conan/p/cmakecf6b18ccaa9f5/p/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_26ded.dir/Debug --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests  -- /usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_26ded.dir/Debug/testCXXCompiler.cxx.obj  /out:Debug/cmTC_26ded.exe /implib:Debug/cmTC_26ded.lib /pdb:Debug/cmTC_26ded.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && :
RC Pass 1: command "rc /fo CMakeFiles/cmTC_26ded.dir/Debug/manifest.res CMakeFiles/cmTC_26ded.dir/Debug/manifest.rc" failed (exit code 0) with the following output:
no such file or directory
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:3 (project)

-- Configuring incomplete, errors occurred!

ERROR: conanfile.py (castcore/1.1): Error in build() method, line 97 cmake.configure() ConanException: Error 1 while executing I tried with both Ninja & Ninja Multi-Config, but neither worked. Do you have any ideas? Thanks!

— Reply to this email directly, view it on GitHub https://github.com/conan-io/conan/issues/15655#issuecomment-1964626846, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAZDCCRT2KA2BBPZCH7XRLYVS4FJAVCNFSM6AAAAABDF7ZXBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRUGYZDMOBUGY. You are receiving this because you were mentioned.

Todiq commented 5 months ago

Thank. I added RC to the env through the profile and /MANIFEST:NO to the link options in the cmakelists. However, I now get this:

LINK Pass 1: command "/usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_16054.dir/testCXXCompiler.cxx.obj /out:cmTC_16054.exe /implib:cmTC_16054.lib /pdb:cmTC_16054.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles/cmTC_16054.dir/intermediate.manifest CMakeFiles/cmTC_16054.dir/manifest.res" failed (exit code 1) with the following output:
    lld-link-16: error: could not open 'kernel32.lib': No such file or directory
    lld-link-16: error: could not open 'user32.lib': No such file or directory
    lld-link-16: error: could not open 'gdi32.lib': No such file or directory
    lld-link-16: error: could not open 'winspool.lib': No such file or directory
    lld-link-16: error: could not open 'shell32.lib': No such file or directory
    lld-link-16: error: could not open 'ole32.lib': No such file or directory
    lld-link-16: error: could not open 'oleaut32.lib': No such file or directory
    lld-link-16: error: could not open 'uuid.lib': No such file or directory
    lld-link-16: error: could not open 'comdlg32.lib': No such file or directory
    lld-link-16: error: could not open 'advapi32.lib': No such file or directory
    lld-link-16: error: could not open 'libcmt.lib': No such file or directory
    lld-link-16: error: could not open 'oldnames.lib': No such file or directory
    ninja: build stopped: subcommand failed.

Even if all of them are installed under the /winsdkdir passed as an argument to clang-cl. Adding the same argument to lld only results in errors

sykhro commented 5 months ago

Thank. I added RC to the env through the profile and /MANIFEST:NO to the link options in the cmakelists. However, I now get this:


LINK Pass 1: command "/usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_16054.dir/testCXXCompiler.cxx.obj /out:cmTC_16054.exe /implib:cmTC_16054.lib /pdb:cmTC_16054.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles/cmTC_16054.dir/intermediate.manifest CMakeFiles/cmTC_16054.dir/manifest.res" failed (exit code 1) with the following output:

    lld-link-16: error: could not open 'kernel32.lib': No such file or directory

    lld-link-16: error: could not open 'user32.lib': No such file or directory

    lld-link-16: error: could not open 'gdi32.lib': No such file or directory

    lld-link-16: error: could not open 'winspool.lib': No such file or directory

    lld-link-16: error: could not open 'shell32.lib': No such file or directory

    lld-link-16: error: could not open 'ole32.lib': No such file or directory

    lld-link-16: error: could not open 'oleaut32.lib': No such file or directory

    lld-link-16: error: could not open 'uuid.lib': No such file or directory

    lld-link-16: error: could not open 'comdlg32.lib': No such file or directory

    lld-link-16: error: could not open 'advapi32.lib': No such file or directory

    lld-link-16: error: could not open 'libcmt.lib': No such file or directory

    lld-link-16: error: could not open 'oldnames.lib': No such file or directory

    ninja: build stopped: subcommand failed.

Even if all of them are installed under the /winsdkdir passed as an argument to clang-cl. Adding the same argument to lld only results in errors

/winsdkdir is for the Windows SDK. Those libraries in your error come from the CRT, which is a different archive entirely. If you don't know where to get that, use the xwin tool. Be sure to pass the right arguments to it for symlink creation and for using the Microsoft architecture names

Todiq commented 5 months ago

Hello @sykhro,

Thanks a lot for your time. I downloaded both the sdk and crt with xwin in the first place. By default, the symlinks are created. I currently have the following folders: /opt/win-sdk/10.0.22621/crt & /opt/win-sdk/10.0.22621/sdk.

The previously mentionned libs are locatied in the sdk, not the crt. Is that a mistake from xwin?

Should I also point /vctoolsdir to the subfolder containing them that is located in the sdk folder? That does not seem right.

I also tried directly using /winsysroot and point it to /opt/win-sdk/10.0.22621/, but I am still getting the same issue

sykhro commented 5 months ago

I currently have the following folders: /opt/win-sdk/10.0.22621/crt & /opt/win-sdk/10.0.22621/sdk.

Perfect. You need/vctoolsdir /opt/win-sdk/10.0.22621/crt /winsdkdir /opt/win-sdk/10.0.22621/sdk.

using /winsysroot and point it to /opt/win-sdk/10.0.22621/

won't work, needs a different directory structure.

This is the xwin command I use, for reference:

xwin \
 --accept-license \ # Accepts the Microsoft VS EULA
 --variant desktop \  # Just grab the desktop libs, we don't need UWP
 --arch x86_64 \ # Only include the specified architecture
 --include-atl \ # Also add the Active Template Library
 splat \ # download+unpack
 --preserve-ms-arch-notation \ # Use Microsoft's architecture names instead of LLVM's for clang-cl and MSVC compatibility
 --output redist \ # Output folder
Todiq commented 5 months ago

@sykhro

I downloaded the sdk again with the command you provided, to be sure nothing was missing.

However, I am still unable to compile anything. It will be simpler with the log:

======== Calling build() ========
conanfile.py (castcore/1.1): Calling build()
conanfile.py (castcore/1.1): Running CMake.configure()
conanfile.py (castcore/1.1): RUN: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="/workspace/core/build/windows-msvc-193-x86_64/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/workspace/core" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/workspace/core"
-- Using Conan toolchain: /workspace/core/build/windows-msvc-193-x86_64/Release/generators/conan_toolchain.cmake
-- Conan toolchain: C++ Standard 17 with extensions OFF
-- Conan toolchain: Setting BUILD_SHARED_LIBS = ON
-- The CXX compiler identification is Clang 16.0.6 with MSVC-like command-line
CMake Error at /opt/conan/p/cmakecf6b18ccaa9f5/p/share/cmake-3.28/Modules/CMakeDetermineCXXCompiler.cmake:232 (configure_file):
  Operation not permitted
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /usr/bin/clang-cl-16
-- Check for working CXX compiler: /usr/bin/clang-cl-16 - broken
CMake Error at /opt/conan/p/cmakecf6b18ccaa9f5/p/share/cmake-3.28/Modules/CMakeTestCXXCompiler.cmake:60 (message):
  The C++ compiler

    "/usr/bin/clang-cl-16"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/workspace/core/build/windows-msvc-193-x86_64/Release/CMakeFiles/CMakeScratch/TryCompile-I9GmPU'

    Run Build Command(s): /opt/conan/p/ninja6fed3c8400c5b/p/bin/ninja -v cmTC_57596
    [1/2] /usr/bin/clang-cl-16  /nologo -TP   -v -fcolor-diagnostics -target x86_64-pc-windows-msvc /winsdkdir /opt/win-sdk/10.0.22621/sdk /vctoolsdir /opt/win-sdk/10.0.22621/crt -flto -march=x86-64-v3 /DWIN32 /D_WINDOWS /EHsc  /Zi /Ob0 /Od /RTC1 -std:c++17 /showIncludes /FoCMakeFiles/cmTC_57596.dir/testCXXCompiler.cxx.obj /FdCMakeFiles/cmTC_57596.dir/ -c -- /workspace/core/build/windows-msvc-193-x86_64/Release/CMakeFiles/CMakeScratch/TryCompile-I9GmPU/testCXXCompiler.cxx
    Debian clang version 16.0.6 (15~deb12u1)
    Target: x86_64-pc-windows-msvc
    Thread model: posix
    InstalledDir: /usr/bin
     (in-process)
    clang -cc1 version 16.0.6 based upon LLVM 16.0.6 default target x86_64-pc-linux-gnu
    ignoring nonexistent directory "/opt/win-sdk/10.0.22621/crt/atlmfc/include"
    #include "..." search starts here:
    #include <...> search starts here:
     /usr/lib/llvm-16/lib/clang/16/include
     /opt/win-sdk/10.0.22621/crt/include
     /opt/win-sdk/10.0.22621/sdk/Include/10.0.22621/ucrt
     /opt/win-sdk/10.0.22621/sdk/Include/10.0.22621/shared
     /opt/win-sdk/10.0.22621/sdk/Include/10.0.22621/um
     /opt/win-sdk/10.0.22621/sdk/Include/10.0.22621/winrt
     /opt/win-sdk/10.0.22621/sdk/Include/10.0.22621/cppwinrt
    End of search list.
    [2/2] : && /opt/conan/p/cmakecf6b18ccaa9f5/p/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_57596.dir --rc=llvm-rc-16 --mt=/usr/bin/llvm-mt-16 --manifests  -- /usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_57596.dir/testCXXCompiler.cxx.obj  /out:cmTC_57596.exe /implib:cmTC_57596.lib /pdb:cmTC_57596.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && :
    FAILED: cmTC_57596.exe
    : && /opt/conan/p/cmakecf6b18ccaa9f5/p/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_57596.dir --rc=llvm-rc-16 --mt=/usr/bin/llvm-mt-16 --manifests  -- /usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_57596.dir/testCXXCompiler.cxx.obj  /out:cmTC_57596.exe /implib:cmTC_57596.lib /pdb:cmTC_57596.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && :
    LINK Pass 1: command "/usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_57596.dir/testCXXCompiler.cxx.obj /out:cmTC_57596.exe /implib:cmTC_57596.lib /pdb:cmTC_57596.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles/cmTC_57596.dir/intermediate.manifest CMakeFiles/cmTC_57596.dir/manifest.res" failed (exit code 1) with the following output:
    lld-link-16: error: could not open 'kernel32.lib': No such file or directory
    lld-link-16: error: could not open 'user32.lib': No such file or directory
    lld-link-16: error: could not open 'gdi32.lib': No such file or directory
    lld-link-16: error: could not open 'winspool.lib': No such file or directory
    lld-link-16: error: could not open 'shell32.lib': No such file or directory
    lld-link-16: error: could not open 'ole32.lib': No such file or directory
    lld-link-16: error: could not open 'oleaut32.lib': No such file or directory
    lld-link-16: error: could not open 'uuid.lib': No such file or directory
    lld-link-16: error: could not open 'comdlg32.lib': No such file or directory
    lld-link-16: error: could not open 'advapi32.lib': No such file or directory
    lld-link-16: error: could not open 'libcmt.lib': No such file or directory
    lld-link-16: error: could not open 'oldnames.lib': No such file or directory
    ninja: build stopped: subcommand failed.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

-- Configuring incomplete, errors occurred!

ERROR: conanfile.py (castcore/1.1): Error in build() method, line 98
        cmake.configure()
        ConanException: Error 1 while executing
sykhro commented 5 months ago
-- The CXX compiler identification is Clang 16.0.6 with MSVC-like command-line
CMake Error at /opt/conan/p/cmakecf6b18ccaa9f5/p/share/cmake-3.28/Modules/CMakeDetermineCXXCompiler.cmake:232 (configure_file):
  Operation not permitted
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)

this is suspicious, perhaps you're missing a chmod +x?

Todiq commented 4 months ago

Hello @sykhro,

Although the cmake issue is fixed, it still won't work. I tried removing the arm64 subfolders I also had to be sure it wasn't conflicting with the x64 folders, but that didn't fix it.

Log ```bash root@docker-desktop:/tmp# conan build core/ --profile:host windows-x86_64 --profile:build linux-x86_64 Using lockfile: '/tmp/core/conan.lock' ======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows cast*/*:build_type=Release cast*/*:compiler.cppstd=17 [conf] tools.build:compiler_executables={'c': 'clang-cl-16', 'cpp': 'clang-cl-16', 'rc': 'llvm-rc-16'} tools.build:cxxflags=['-v -fcolor-diagnostics', '-target x86_64-pc-windows-msvc', '/winsdkdir /opt/win-sdk/sdk /vctoolsdir /opt/win-sdk/crt'] tools.cmake.cmaketoolchain:generator=Ninja Profile build: [settings] arch=x86_64 build_type=Release compiler=clang compiler.cppstd=17 compiler.libcxx=libstdc++11 compiler.version=16 os=Linux [conf] tools.build:compiler_executables={'c': 'clang-16', 'cpp': 'clang++-16'} tools.build:cxxflags=['-fcolor-diagnostics'] tools.build:exelinkflags=['-fuse-ld=lld'] tools.build:sharedlinkflags=['-fuse-ld=lld'] tools.cmake.cmaketoolchain:generator=Ninja ======== Computing dependency graph ======== Graph root conanfile.py (castcore/1.1): /tmp/core/conanfile.py Requirements boost/1.81.0#753df9d4f149a5551335f47abe21de0b - Cache icu/72.1#d24b2d30acae3dcb788e139112bcd7c6 - Cache libiconv/1.17#73fefc1b696e069df90fd1d18aa63edd - Cache libxml2/2.11.6#41c14895baba105865cb22ecaf948115 - Cache libxslt/1.1.34#2bdc1f5fe5db1df40f8465e485a19ee4 - Cache pugixml/1.13#f615c1fcec55122b2e177d17061276e7 - Cache xerces-c/3.2.4#c52d1d1bb36d1377471ec1e551a6598a - Cache Test requirements gtest/1.13.0#8a0bc5b3e159ed45de97260c2bff65b5 - Cache Build requirements b2/4.10.1#a41eecb267963ddf518e3c177eae60e1 - Cache cmake/3.29.0#a055de871f63a7904aa3dcb9f3c61242 - Cache icu/72.1#d24b2d30acae3dcb788e139112bcd7c6 - Cache ninja/1.11.1#77587f8c8318662ac8e5a7867eb4be21 - Cache ======== Computing necessary packages ======== icu/72.1: Checking 11 compatible configurations icu/72.1: Compatible configurations not found in cache, checking servers icu/72.1: 'f4608c27d2d424b8c296ba6b9e60e99db4773e60': compiler.cppstd=98 icu/72.1: 'e05540f1fd257df0b84749f1c7ba0d3b177f1844': compiler.cppstd=gnu98 icu/72.1: 'e301a5a0eeb69b188ed1ad4ce246ca6745bb28d6': compiler.cppstd=11 icu/72.1: '9cd3656687e1d6e8a3f9756ed104fe6f948e1552': compiler.cppstd=gnu11 icu/72.1: 'af65f570cf50a0f849452bfe925a59b1f586d0f0': compiler.cppstd=14 icu/72.1: '6f00251d82d3c86732e8189344f0efbf9c4f8a5c': compiler.cppstd=gnu14 icu/72.1: '0d519caeef63d9b00cddf18f7715896bb5e5629d': compiler.cppstd=gnu17 icu/72.1: 'd216c88985f6580c212fd69cad493fe4e6074935': compiler.cppstd=20 icu/72.1: '9e96c6b675bc7ad6a99566b18763382a6abd3a17': compiler.cppstd=gnu20 icu/72.1: 'a2cfacb413a21cf4e55c655fef62c6ed8885de7f': compiler.cppstd=23 icu/72.1: '576a9202edb171ec9db75c81373692d5a1aec42d': compiler.cppstd=gnu23 Requirements boost/1.81.0#753df9d4f149a5551335f47abe21de0b:e03785e977988d57a84487e4306a26c9018cabf0#f65d418cddf6cc771a803fde82e12dd9 - Cache icu/72.1#d24b2d30acae3dcb788e139112bcd7c6:9f8165f8d74e26bf104abb2a5005a80d1101b198#3cb5da99fe9d01c55d1c5dbf13f35112 - Cache libiconv/1.17#73fefc1b696e069df90fd1d18aa63edd:7bfde258ff4f62f75668d0896dbddedaa7480a0f#9ef92719f5c05dca2f0dbb46f50d3f8d - Cache libxml2/2.11.6#41c14895baba105865cb22ecaf948115:a6cdd368afb04c4d9e5918696d661f8f5249a029#d4a7bc8cb16ca7e7411db8804a765032 - Cache libxslt/1.1.34#2bdc1f5fe5db1df40f8465e485a19ee4:4e7168dde525f5dbaf65a8b8f6b3280b6a7e87d7#a632a2a87954026a2d962070cbad7aa6 - Cache pugixml/1.13#f615c1fcec55122b2e177d17061276e7:da39a3ee5e6b4b0d3255bfef95601890afd80709#ae530054ed7ac99330514c13a5bfde3a - Cache xerces-c/3.2.4#c52d1d1bb36d1377471ec1e551a6598a:41c4e6767851fe7db56310649912b6259451a38f#0831576b3c913f5e3d1294aa2f05ee41 - Cache Test requirements gtest/1.13.0#8a0bc5b3e159ed45de97260c2bff65b5:9940e217936a0f218f90473d62bf1d4db55efaa7#f44bf478a18701d76b310497997d7b3b - Cache Build requirements cmake/3.29.0#a055de871f63a7904aa3dcb9f3c61242:63fead0844576fc02943e16909f08fcdddd6f44b#360d58b97919da259380ac10247a9024 - Cache ninja/1.11.1#77587f8c8318662ac8e5a7867eb4be21:3593751651824fb813502c69c971267624ced41a#60e6fc0f973babfbed66a66af22a4f02 - Cache Skipped binaries b2/4.10.1, icu/72.1 ======== Installing packages ======== ======== Installing packages ======== cmake/3.29.0: Already installed! (1 of 10) cmake/3.29.0: Appending PATH environment variable: /opt/conan/p/cmakee300763ec076c/p/bin gtest/1.13.0: Already installed! (2 of 10) libiconv/1.17: Already installed! (3 of 10) ninja/1.11.1: Already installed! (4 of 10) pugixml/1.13: Already installed! (5 of 10) xerces-c/3.2.4: Already installed! (6 of 10) boost/1.81.0: Already installed! (7 of 10) boost/1.81.0: Disabled magic autolinking (smart and magic decisions) icu/72.1: Already installed! (8 of 10) libxml2/2.11.6: Already installed! (9 of 10) libxml2/2.11.6: Appending PATH environment variable: /opt/conan/p/libxm07501da66e843/p/bin libxslt/1.1.34: Already installed! (10 of 10) WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X: WARN: deprecated: 'env_info' used in: icu/72.1, boost/1.81.0, libxslt/1.1.34, libiconv/1.17, libxml2/2.11.6, cmake/3.29.0 WARN: deprecated: 'cpp_info.names' used in: icu/72.1, boost/1.81.0, libxslt/1.1.34, libiconv/1.17, libxml2/2.11.6, gtest/1.13.0 WARN: deprecated: 'cpp_info.filenames' used in: libxml2/2.11.6, boost/1.81.0 WARN: deprecated: 'user_info' used in: boost/1.81.0 WARN: deprecated: 'cpp_info.build_modules' used in: libxml2/2.11.6 ======== Finalizing install (deploy, generators) ======== conanfile.py (castcore/1.1): Calling generate() conanfile.py (castcore/1.1): Generators folder: /tmp/core/build/windows-msvc-193-x86_64/Release/generators conanfile.py (castcore/1.1): CMakeToolchain generated: conan_toolchain.cmake conanfile.py (castcore/1.1): Preset 'conan-windows-msvc-193-x86_64-release' added to CMakePresets.json. Invoke it manually using 'cmake --preset conan-windows-msvc-193-x86_64-release' if using CMake>=3.23 conanfile.py (castcore/1.1): If your CMake version is not compatible with CMakePresets (<3.23) call cmake like: 'cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=/tmp/core/build/windows-msvc-193-x86_64/Release/generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release' conanfile.py (castcore/1.1): CMakeToolchain generated: CMakePresets.json conanfile.py (castcore/1.1): CMakeToolchain generated: ../../../../CMakeUserPresets.json conanfile.py (castcore/1.1): CMakeDeps necessary find_package() and targets for your CMakeLists.txt find_package(Boost) find_package(ICU) find_package(LibXslt) find_package(libxml2) find_package(pugixml) find_package(XercesC) find_package(GTest) target_link_libraries(... boost::boost icu::icu libxslt::libxslt LibXml2::LibXml2 pugixml::pugixml XercesC::XercesC gtest::gtest) conanfile.py (castcore/1.1): Generating aggregated env files conanfile.py (castcore/1.1): Generated aggregated env files: ['conanbuild.sh', 'conanrun.bat'] ======== Calling build() ======== conanfile.py (castcore/1.1): Calling build() conanfile.py (castcore/1.1): Running CMake.configure() conanfile.py (castcore/1.1): RUN: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="/tmp/core/build/windows-msvc-193-x86_64/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/tmp/core" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/tmp/core" -- Using Conan toolchain: /tmp/core/build/windows-msvc-193-x86_64/Release/generators/conan_toolchain.cmake -- Conan toolchain: C++ Standard 17 with extensions OFF -- Conan toolchain: Setting BUILD_SHARED_LIBS = ON -- The CXX compiler identification is Clang 16.0.6 with MSVC-like command-line -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - failed -- Check for working CXX compiler: /usr/bin/clang-cl-16 -- Check for working CXX compiler: /usr/bin/clang-cl-16 - broken CMake Error at /opt/conan/p/cmakee300763ec076c/p/share/cmake-3.29/Modules/CMakeTestCXXCompiler.cmake:60 (message): The C++ compiler "/usr/bin/clang-cl-16" is not able to compile a simple test program. It fails with the following output: Change Dir: '/tmp/core/build/windows-msvc-193-x86_64/Release/CMakeFiles/CMakeScratch/TryCompile-ltbOOX' Run Build Command(s): /opt/conan/p/ninja6fed3c8400c5b/p/bin/ninja -v cmTC_55118 [1/2] /usr/bin/clang-cl-16 /nologo -TP -v -fcolor-diagnostics -target x86_64-pc-windows-msvc /winsdkdir /opt/win-sdk/sdk /vctoolsdir /opt/win-sdk/crt /DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 /showIncludes /FoCMakeFiles/cmTC_55118.dir/testCXXCompiler.cxx.obj /FdCMakeFiles/cmTC_55118.dir/ -c -- /tmp/core/build/windows-msvc-193-x86_64/Release/CMakeFiles/CMakeScratch/TryCompile-ltbOOX/testCXXCompiler.cxx Debian clang version 16.0.6 (15~deb12u1) Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: /usr/bin (in-process) clang -cc1 version 16.0.6 based upon LLVM 16.0.6 default target x86_64-pc-linux-gnu ignoring nonexistent directory "/opt/win-sdk/crt/atlmfc/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/llvm-16/lib/clang/16/include /opt/win-sdk/crt/include /opt/win-sdk/sdk/Include/10.0.22621/ucrt /opt/win-sdk/sdk/Include/10.0.22621/shared /opt/win-sdk/sdk/Include/10.0.22621/um /opt/win-sdk/sdk/Include/10.0.22621/winrt /opt/win-sdk/sdk/Include/10.0.22621/cppwinrt End of search list. [2/2] : && /opt/conan/p/cmakee300763ec076c/p/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_55118.dir --rc=llvm-rc-16 --mt=/usr/bin/llvm-mt-16 --manifests -- /usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_55118.dir/testCXXCompiler.cxx.obj /out:cmTC_55118.exe /implib:cmTC_55118.lib /pdb:cmTC_55118.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && : FAILED: cmTC_55118.exe : && /opt/conan/p/cmakee300763ec076c/p/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_55118.dir --rc=llvm-rc-16 --mt=/usr/bin/llvm-mt-16 --manifests -- /usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_55118.dir/testCXXCompiler.cxx.obj /out:cmTC_55118.exe /implib:cmTC_55118.lib /pdb:cmTC_55118.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && : LINK Pass 1: command "/usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_55118.dir/testCXXCompiler.cxx.obj /out:cmTC_55118.exe /implib:cmTC_55118.lib /pdb:cmTC_55118.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles/cmTC_55118.dir/intermediate.manifest CMakeFiles/cmTC_55118.dir/manifest.res" failed (exit code 1) with the following output: lld-link-16: error: could not open 'kernel32.lib': No such file or directory lld-link-16: error: could not open 'user32.lib': No such file or directory lld-link-16: error: could not open 'gdi32.lib': No such file or directory lld-link-16: error: could not open 'winspool.lib': No such file or directory lld-link-16: error: could not open 'shell32.lib': No such file or directory lld-link-16: error: could not open 'ole32.lib': No such file or directory lld-link-16: error: could not open 'oleaut32.lib': No such file or directory lld-link-16: error: could not open 'uuid.lib': No such file or directory lld-link-16: error: could not open 'comdlg32.lib': No such file or directory lld-link-16: error: could not open 'advapi32.lib': No such file or directory lld-link-16: error: could not open 'libcmt.lib': No such file or directory lld-link-16: error: could not open 'oldnames.lib': No such file or directory ninja: build stopped: subcommand failed. CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:3 (project) -- Configuring incomplete, errors occurred! ERROR: conanfile.py (castcore/1.1): Error in build() method, line 98 cmake.configure() ConanException: Error 1 while executing ```

The weird part is that I am able to cross-compile a simple test.cpp:

#include <iostream>

int main()
{
    std::cout << "Hello" << std::endl;
    return 0;
}

Using this command: clang-cl-16 -fuse-ld=lld /winsdkdir /opt/win-sdk/sdk /vctoolsdir /opt/win-sdk/crt test.cpp

May the issue come from my profiles?

Here is the build one (Linux):

[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=16
os=Linux

[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.build:compiler_executables = {"c": "clang-16", "cpp": "clang++-16"}
tools.build:cxxflags=["-fcolor-diagnostics"]
tools.build:exelinkflags=["-fuse-ld=lld"]
tools.build:sharedlinkflags=["-fuse-ld=lld"]

And here is the host one (Windows):

[settings]
arch={{detect_api.detect_arch()}}
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.version=193
os=Windows

cast*/*:build_type=Release
cast*/*:compiler.cppstd=17

[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.build:cxxflags=["-v -fcolor-diagnostics"]
tools.build:cxxflags+=["-fuse-ld=lld"]
tools.build:cxxflags+=["-target x86_64-pc-windows-msvc"]
tools.build:cxxflags+=["/winsdkdir /opt/win-sdk/sdk /vctoolsdir /opt/win-sdk/crt"]
tools.build:cxxflags+=["-flto -march=x86-64-v3"]
tools.build:compiler_executables={"c": "clang-cl-16", "cpp": "clang-cl-16", "rc": "llvm-rc-16"}
sykhro commented 4 months ago

try this in the host profile:

[settings]
arch={{detect_api.detect_arch()}}
os=Windows
build_type=Release
compiler=clang
compiler.version=16
compiler.cppstd=14
compiler.runtime_type=Release
compiler.runtime_version=v143 # has to match what's coming from xwin, 2022 is v143
compiler.libcxx=shared
compiler.runtime=dynamic
Todiq commented 4 months ago

Tried, but did not work either. Are we sure to have the same tree?

root@docker-desktop:/tmp# tree --filelimit 5 /opt/win-sdk/
/opt/win-sdk/
├── crt
│   ├── include  [332 entries exceeds filelimit, not opening dir]
│   └── lib
│       ├── arm64  [48 entries exceeds filelimit, not opening dir]
│       └── x64  [45 entries exceeds filelimit, not opening dir]
└── sdk
    ├── Include -> include
    ├── Lib -> lib
    ├── include  [6 entries exceeds filelimit, not opening dir]
    └── lib
        ├── 10.0.22621 -> .
        ├── ucrt
        │   ├── arm64
        │   │   ├── libucrt.lib
        │   │   └── ucrt.lib
        │   └── x64
        │       ├── libucrt.lib
        │       └── ucrt.lib
        └── um
            ├── arm64  [1082 entries exceeds filelimit, not opening dir]
            └── x64  [1119 entries exceeds filelimit, not opening dir]

18 directories, 4 files
sykhro commented 4 months ago

I see! You're missing the debug ones. I have

crt
├── include  [330 entries exceeds filelimit, not opening dir]
└── lib
    └── x64  [78 entries exceeds filelimit, not opening dir]

and

sdk
├── include  [6 entries exceeds filelimit, not opening dir]
└── lib
    ├── 10.0.22621 -> .
    ├── ucrt
    │   └── x64
    │       ├── libucrt.lib
    │       ├── libucrtd.lib
    │       ├── ucrt.lib
    │       └── ucrtd.lib
    └── um
        └── x64  [483 entries exceeds filelimit, not opening dir]

from a while ago (VS 17.7.4)

sykhro commented 4 months ago

You need to pass --include-debug-libs to xwin

Todiq commented 4 months ago

Still no luck. Although the flags are passed in the conan profile through tools.build:cxxflags+=["/winsdkdir /opt/win-sdk/sdk /vctoolsdir /opt/win-sdk/crt"], I am wondering if they are properly propagated to the linker, hence leading to the issue

In fact, lld-link also takes /winsdkdir as an argument, but I can't find it in the log. Only clang-cl seems to be using it:

[2/2] : && /opt/conan/p/cmakee300763ec076c/p/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_42d80.dir --rc=llvm-rc-16 --mt=/usr/bin/llvm-mt-16 --manifests  -- /usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_42d80.dir/testCXXCompiler.cxx.obj  /out:cmTC_42d80.exe /implib:cmTC_42d80.lib /pdb:cmTC_42d80.pdb /version:0.0 -m64 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && :
    FAILED: cmTC_42d80.exe
    : && /opt/conan/p/cmakee300763ec076c/p/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_42d80.dir --rc=llvm-rc-16 --mt=/usr/bin/llvm-mt-16 --manifests  -- /usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_42d80.dir/testCXXCompiler.cxx.obj  /out:cmTC_42d80.exe /implib:cmTC_42d80.lib /pdb:cmTC_42d80.pdb /version:0.0 -m64 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && :
    LINK Pass 1: command "/usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_42d80.dir/testCXXCompiler.cxx.obj /out:cmTC_42d80.exe /implib:cmTC_42d80.lib /pdb:cmTC_42d80.pdb /version:0.0 -m64 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles/cmTC_42d80.dir/intermediate.manifest CMakeFiles/cmTC_42d80.dir/manifest.res" failed (exit code 1) with the following output:
    lld-link-16: warning: ignoring unknown argument '-m64'
    lld-link-16: error: could not open 'kernel32.lib': No such file or directory
mgavin commented 3 months ago

tools.build:cxxflags+=["/winsdkdir /opt/win-sdk/sdk /vctoolsdir /opt/win-sdk/crt"], I am wondering if they are properly propagated to the linker, hence leading to the issue

they aren't since

LINK Pass 1: command "/usr/bin/lld-link-16 /nologo CMakeFiles/cmTC_42d80.dir/testCXXCompiler.cxx.obj /out:cmTC_42d80.exe /implib:cmTC_42d80.lib /pdb:cmTC_42d80.pdb /version:0.0 -m64 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles/cmTC_42d80.dir/intermediate.manifest CMakeFiles/cmTC_42d80.dir/manifest.res" failed (exit code 1) with the following output:

doesn't indicate the path's inclusions. I've gotten around this by including "LDFLAGS": "/LIBPATH:/opt/msvc/vc/tools/msvc/14.39.33519/lib/x64 /LIBPATH:/opt/msvc/kits/10/lib/10.0.22621.0/ucrt/x64 /LIBPATH:/opt/msvc/kits/10/lib/10.0.22621.0/um/x64 /LIBPATH:/opt/msvc/kits/10/lib/10.0.22621.0/km/x64" as an environment variable (in an "environment" section of a preset definition in a CMakePresets.json file), so they would get picked up during this step. My paths are obviously different from yours, but hopefully they provide insight for whomever comes across this thread. After setting LDFLAGS in my preset, my output looked like: /usr/bin/lld-link /nologo @CMakeFiles/cmTC_80cef.dir/objects1.rsp /out:cmTC_80cef.exe /implib:cmTC_80cef.lib /pdb:(my cmake project build folder)/CMakeFiles/CMakeScratch/TryCompile-Po73Kh/cmTC_80cef.pdb /version:0.0 /machine:x64 /LIBPATH:/opt/msvc/vc/tools/msvc/14.39.33519/lib/x64 /LIBPATH:/opt/msvc/kits/10/lib/10.0.22621.0/ucrt/x64 /LIBPATH:/opt/msvc/kits/10/lib/10.0.22621.0/um/x64 /LIBPATH:/opt/msvc/kits/10/lib/10.0.22621.0/km/x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles/cmTC_80cef.dir/intermediate.manifest CMakeFiles/cmTC_80cef.dir/manifest.res which was successful, as it was followed by MT: after.

I am unfamiliar with cmake (annoyingly so because learning resources are awful), so if this is some "hacky" way of doing it, I simply don't care, since I have tremendous difficulty finding why/where/how to address this/these issue(s). Just sharing what worked for me to hopefully help others move past this step. To anyone else, try duckduckgo-ing "clang-cl cmake linux" or something like that. Hopefully it leads you to something fruitful.

sykhro commented 3 months ago

The proper CMake way of doing this is using a toolchain file. Here is an example of how LLVM are using clang-cl it to (cross-)compile LLVM itself.