FindODBC: Test fails with Clang/LLVM-MinGW toolchain
The Clang/LLVM-MinGW toolchain fails on Windows with FindODBC
module from 3.16.0rc4 in two ways:
- The module searches for
sql.h
, and finds it inc:\llvm-mingw\include
which ends up as being asODBC_INCLUDE_DIR
. The problems is that this is theMinGW
toolchain path, which ends up having-system
and it comes before Clang include paths.
c:\llvm-mingw\include
contains math.h
which causes problems if it's included before the Clang counterpart.
-
find_library
forodbc32
will returnc:\windows\system32\odbc32.dll
, which is not supported by Clang'slld
.
CMake's Tests/FindODBC
fails with:
Internal cmake changing into directory: C:/Projects/cmake/test-odbc/FindODBC/Test
======== CMake output ======
The C compiler identification is Clang 9.0.0
Check for working C compiler: C:/llvm-mingw/bin/cc.exe
Check for working C compiler: C:/llvm-mingw/bin/cc.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Found ODBC: C:/Windows/System32/odbc32.dll
Configuring done
Generating done
Build files have been written to: C:/Projects/cmake/test-odbc/FindODBC/Test
======== End CMake output ======
Change Dir: C:/Projects/cmake/test-odbc/FindODBC/Test
Run Clean Command:c:/Tools/Ninja/ninja.exe clean
[1/1 79.4/sec]Cleaning all built files...
Cleaning... 0 files.
Run Build Command(s):c:/Tools/Ninja/ninja.exe && [1/4 1.5/sec]Building C object CMakeFiles/test_odbc_tgt.dir/main.c.obj
[2/4 2.7/sec]Building C object CMakeFiles/test_odbc_var.dir/main.c.obj
[3/4 3.8/sec]Linking C executable test_odbc_tgt.exe
FAILED: test_odbc_tgt.exe
cmd.exe /C "cd . && C:\llvm-mingw\bin\cc.exe -O3 -DNDEBUG CMakeFiles/test_odbc_tgt.dir/main.c.obj -o test_odbc_tgt.exe -Wl,--out-implib,libtest_odbc_tgt.dll.a -Wl,--major-image-version,0,--minor-image-version,0 C:/Windows/System32/odbc32.dll C:/Windows/System32/odbccp32.dll -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
lld-link: error: C:/Windows/System32/odbc32.dll: bad file type. Did you specify a DLL instead of an import library?
lld-link: error: C:/Windows/System32/odbccp32.dll: bad file type. Did you specify a DLL instead of an import library?
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
[4/4 4.8/sec]Linking C executable test_odbc_var.exe
FAILED: test_odbc_var.exe
cmd.exe /C "cd . && C:\llvm-mingw\bin\cc.exe -O3 -DNDEBUG CMakeFiles/test_odbc_var.dir/main.c.obj -o test_odbc_var.exe -Wl,--out-implib,libtest_odbc_var.dll.a -Wl,--major-image-version,0,--minor-image-version,0 C:/Windows/System32/odbc32.dll C:/Windows/System32/odbccp32.dll -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
lld-link: error: C:/Windows/System32/odbc32.dll: bad file type. Did you specify a DLL instead of an import library?
lld-link: error: C:/Windows/System32/odbccp32.dll: bad file type. Did you specify a DLL instead of an import library?
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Qt6 uses for it's odbc plugin find_package(ODBC)
which makes the build fail with Clang/LLVM-MinGW toolchain.
One workaround is to provide a custom FindODBC.cmake
or fix this upstream.