MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.73k stars 254 forks source link

[HELP Request] Failed to build CCLS, need explanations #891

Closed Xelbayria closed 2 years ago

Xelbayria commented 2 years ago

Observed behavior

I was trying to build ccls via here using Windows. I already succesfully built Clang & LLVM. but CCLS not so successfully. it failed the "Simple Test" using clang-cl

here's the error logs:

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/Program Scoop/apps/llvm/current/bin/clang-cl.exe 
Build flags: 
Id flags:  

The output was:
1120
LINK : error LNK2001: unresolved external symbol mainCRTStartup
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\lib\x86\libcmt.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
CMakeCXXCompilerId.exe : fatal error LNK1120: 1 unresolved externals
clang-cl: error: linker command failed with exit code 1120 (use -v to see invocation)

Detecting CXX compiler ABI info failed to compile with the following output:
Change Dir: C:/ccls/Release/CMakeFiles/CMakeTmp

Run Build Command(s):C:/PROGRA~4/shims/ninja.exe cmTC_2d42d && [1/2] Building CXX object CMakeFiles\cmTC_2d42d.dir\CMakeCXXCompilerABI.cpp.obj

[2/2] Linking CXX executable cmTC_2d42d.exe

FAILED: cmTC_2d42d.exe 

cmd.exe /C "cd . && "C:\Program Scoop\apps\cmake\3.23.2\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_2d42d.dir --rc=C:\PROGRA~2\WINDOW~4\10\bin\100190~1.0\x86\rc.exe --mt=C:\PROGRA~2\WINDOW~4\10\bin\100190~1.0\x86\mt.exe --manifests  -- C:\PROGRA~4\apps\llvm\current\bin\lld-link.exe /nologo CMakeFiles\cmTC_2d42d.dir\CMakeCXXCompilerABI.cpp.obj  /out:cmTC_2d42d.exe /implib:cmTC_2d42d.lib /pdb:cmTC_2d42d.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console   && cd ."
LINK Pass 1: command "C:\PROGRA~4\apps\llvm\current\bin\lld-link.exe /nologo CMakeFiles\cmTC_2d42d.dir\CMakeCXXCompilerABI.cpp.obj /out:cmTC_2d42d.exe /implib:cmTC_2d42d.lib /pdb:cmTC_2d42d.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_2d42d.dir/intermediate.manifest CMakeFiles\cmTC_2d42d.dir/manifest.res" failed (exit code 1) with the following output:

lld-link: error: <root>: undefined symbol: mainCRTStartup

ninja: build stopped: subcommand failed.

Determining if the CXX compiler works failed with the following output:
Change Dir: C:/ccls/Release/CMakeFiles/CMakeTmp

Run Build Command(s):C:/PROGRA~4/shims/ninja.exe cmTC_02a63 && [1/2] Building CXX object CMakeFiles\cmTC_02a63.dir\testCXXCompiler.cxx.obj

[2/2] Linking CXX executable cmTC_02a63.exe

FAILED: cmTC_02a63.exe 

cmd.exe /C "cd . && "C:\Program Scoop\apps\cmake\3.23.2\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_02a63.dir --rc=C:\PROGRA~2\WINDOW~4\10\bin\100190~1.0\x86\rc.exe --mt=C:\PROGRA~2\WINDOW~4\10\bin\100190~1.0\x86\mt.exe --manifests  -- C:\PROGRA~4\apps\llvm\current\bin\lld-link.exe /nologo CMakeFiles\cmTC_02a63.dir\testCXXCompiler.cxx.obj  /out:cmTC_02a63.exe /implib:cmTC_02a63.lib /pdb:cmTC_02a63.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 && cd ."
LINK Pass 1: command "C:\PROGRA~4\apps\llvm\current\bin\lld-link.exe /nologo CMakeFiles\cmTC_02a63.dir\testCXXCompiler.cxx.obj /out:cmTC_02a63.exe /implib:cmTC_02a63.lib /pdb:cmTC_02a63.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_02a63.dir/intermediate.manifest CMakeFiles\cmTC_02a63.dir/manifest.res" failed (exit code 1) with the following output:

lld-link: error: <root>: undefined symbol: mainCRTStartup

ninja: build stopped: subcommand failed.

Expected behaviour

I expected to see the successful building of CCLS.

Steps to reproduce

I followed the steps below via the link provided above.

# Download ccls
cd ccls
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_PREFIX_PATH="D:/llvm/Release"
ninja -C Release

System information

Xelbayria commented 2 years ago

I got some help from other sources and understood the reason why errors show up. The issue is closed.