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

Build on Windows fixed (dynamic linking of stdc++) #365

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

luav
Copy link

@luav luav commented Jul 10, 2023

stdc++ linking is fixed for Windows native builds.

The original build produced the following error, which has been resolved:

>------ Build started: Project: CMakeLists, Configuration: Release ------
  [1/9] Building C object src\CMakeFiles\ggml.dir\ggml.c.obj
ggml\out\build\x64-Release-CUDA-Ninja_x64_x64\cl : Command line warning D9002: ignoring unknown option '-mfma'
ggml\out\build\x64-Release-CUDA-Ninja_x64_x64\cl : Command line warning D9002: ignoring unknown option '-mf16c'
ggml\out\build\x64-Release-CUDA-Ninja_x64_x64\cl : Command line warning D9002: ignoring unknown option '-mavx'
ggml\out\build\x64-Release-CUDA-Ninja_x64_x64\cl : Command line warning D9002: ignoring unknown option '-mavx2'
  [2/9] Building CXX object examples\CMakeFiles\common-ggml.dir\common-ggml.cpp.obj
  [3/9] Building CXX object examples\mpt\CMakeFiles\mpt.dir\main.cpp.obj
  [4/9] Building CXX object examples\CMakeFiles\common.dir\common.cpp.obj
  [5/9] Linking CXX static library examples\common.lib
  [6/9] Building CUDA object src\CMakeFiles\ggml.dir\ggml-cuda.cu.obj
  ggml-cuda.cu
  
  tmpxft_00009f6c_00000000-10_ggml-cuda.cudafe1.cpp
  
  [7/9] Linking CUDA static library src\ggml.lib
  [8/9] Linking CXX static library examples\common-ggml.lib
  [9/9] Linking CXX executable bin\mpt.exe
  FAILED: bin/mpt.exe 
  cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=examples\mpt\CMakeFiles\mpt.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100203~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100203~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\MICROS~2\2022\Preview\VC\Tools\MSVC\1437~1.327\bin\Hostx64\x64\link.exe /nologo examples\mpt\CMakeFiles\mpt.dir\main.cpp.obj  /out:bin\mpt.exe /implib:examples\mpt\mpt.lib /pdb:bin\mpt.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console  src\ggml.lib  examples\common.lib  examples\common-ggml.lib  src\ggml.lib  "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\lib\x64\cudart.lib"  "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\lib\x64\cublas.lib"  "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\lib\x64\cublasLt.lib"  stdc++.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
  LINK: command "C:\PROGRA~1\MICROS~2\2022\Preview\VC\Tools\MSVC\1437~1.327\bin\Hostx64\x64\link.exe /nologo examples\mpt\CMakeFiles\mpt.dir\main.cpp.obj /out:bin\mpt.exe /implib:examples\mpt\mpt.lib /pdb:bin\mpt.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console src\ggml.lib examples\common.lib examples\common-ggml.lib src\ggml.lib C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\lib\x64\cudart.lib C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\lib\x64\cublas.lib C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\lib\x64\cublasLt.lib stdc++.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:bin\mpt.exe.manifest" failed (exit code 1181) with the following output:
ggml\out\build\x64-Release-CUDA-Ninja_x64_x64\LINK : fatal error LNK1181: cannot open input file 'stdc++.lib'
  
  ninja: build stopped: subcommand failed.

Build failed.

Comment on lines +60 to +63
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
# Note: it must be performed before the Threads package finding (CMAKE_HAVE_LIBC_PTHREAD testing)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
endif()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this needed for? I've never had problems with -pthread

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

Successfully merging this pull request may close these issues.

None yet

2 participants