Skip to content

Commit

Permalink
Windows build with CUDA: prepend compiler lib path
Browse files Browse the repository at this point in the history
Prepend compiler default lib path (usually something like
`-LC:/tools/msys64/clang64/bin/../lib`) to avoid erors like:

    Linking bin/uv.exe...
    ld.lld: error: duplicate symbol: atexit
    >>> defined at C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:336
    >>>            C:/msys64/clang64/lib/crt2.o
    >>> defined at msvcrt.lib(utility.obj)
    c++: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [Makefile:241: bin/uv.exe] Error 1

(reproducible with `./configure --disable-all --enable-cuda`; the
problem is superseded if libavcodec is present, which already does it)

The problem was caused by the fact that MSVC library path is added to
add libmsvcprt.a and libOLDNAMES.a needed by MS C++ STL library that is
needed for CUDA (see the commit b6a45bd from 2024-03-27) to support C++
code in CUDA sources (currently lavc cuda convs). As we compile with MinGW
toolkit, the MinGW lib wrappers need to be used. The error w/o MS STL
library is:

    Linking bin/uv.exe...
    ld.lld: error: could not open 'libmsvcprt.a': No such file or directory
    ld.lld: error: could not open 'libOLDNAMES.a': No such file or directory
    c++: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [Makefile:241: bin/uv.exe] Error 1
  • Loading branch information
MartinPulec committed Jul 29, 2024
1 parent 06afd55 commit a17b9cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,10 @@ then
# MSVS 14.0 has it otherwhere
cl_lib_path=$(realpath "$(dirname "$(command -v "$CL")")"/../lib)
fi
CUDA_LIB="${CUDA_LIB+$CUDA_LIB }-L\"$cl_lib_path\""
DEFAULT_LIB_P=$($LINKER --verbose 2>&1 | awk \
'BEGIN { ORS="" } /InstalledDir: / { print $2 }')/../lib
CUDA_LIB="${CUDA_LIB+$CUDA_LIB }-L$DEFAULT_LIB_P"
CUDA_LIB="$CUDA_LIB -L\"$cl_lib_path\""
FOUND_CUDA=yes
fi
else
Expand Down

0 comments on commit a17b9cb

Please sign in to comment.