Closed VUT246843 closed 1 month ago
Installed correct LLVM win64 and downloaded clang.exe. Built the source using clang/ninja into a new folder. These commands have explicit paths, env. paths are another way.
cd C:\kfr
cmake -B build-release -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="C:\kfr\install" -DCMAKE_CXX_COMPILER="C:\LLVM\bin\clang++.exe" -DCMAKE_MAKE_PROGRAM="C:\LLVM\ninja-win\ninja.exe"
C:\LLVM\ninja-win\ninja.exe -C build-release install
cmake -B build-debug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="C:\kfr\install" -DCMAKE_CXX_COMPILER="C:\LLVM\bin\clang++.exe" -DCMAKE_MAKE_PROGRAM="C:\LLVM\ninja-win\ninja.exe"
C:\LLVM\ninja-win\ninja.exe -C build-debug install
In cmake I tried many variants of both find_package and add_subdirectory imports, changed compiler to clang. It is either missing base.hpp or stdc++.lib pthread.lib or whatever. Moreover, I tried https://github.com/kfrlib/kfr/issues/114 as
cmake_minimum_required(VERSION 3.17)
project(KFR_Test)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(kfr)
add_executable(KFR_Test main.cpp)
target_link_libraries(KFR_Test kfr kfr_dft)
Which throws fatal error LNK1104: cannot open file 'kfr_dft.lib' again.
Could you attach the logs of cmake invocation?
CMakeCache.txt would be helpful too (it contains build settings and build tools paths)
This is from your CMakeCache.txt
//CXX compiler
CMAKE_CXX_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe
This means that you didn't switch compiler to clang or this was not successful. Please refer to the cmake documentation to learn how to set compiler path correctly.
KFR works with Visual Studio but DFT is not available unless you use clang compiler.
Please attach the logs of the Configure step of cmake. Example from Clion:
Changed to clang-cl in toolchains and it builds now. Will test on my own code. success.txt
Thanks, this saved me a lot of cmake headache. I suggest the two ways in docs be more clearly separated and to add a comment that the pre-build is not required (for the former?) Here is my cmake config with JUCE + KFR for others' reference.
cmake_minimum_required(...)
project(PROJECT_NAME VERSION 0.0.1)
add_subdirectory("C:/JUCE" JUCE)
add_subdirectory(kfr)
juce_add_plugin(TARGET-NAME
...)
target_sources(TARGET-NAME
PRIVATE
PluginEditor.cpp
PluginProcessor.cpp)
target_compile_definitions(TARGET-NAME
...)
target_link_libraries(TARGET-NAME
PRIVATE
juce::juce_audio_utils
juce::juce_dsp
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags
)
target_link_libraries(TARGET-NAME PUBLIC kfr kfr_dsp kfr_dft)
If you don't want to add anything, the issue can be closed.
I will add for those facing the issue with LLVM, clang-cl, ninja: ninja: error: FindFirstFileExA(note: including file... I finally solved it by clearing build files and using NMAKE instead of ninja.
I'm new to cmake and confused. Cloned repo and have the following:
It compiles and I was able to use univectors, but the kfr_dft is causing: LINK : fatal error LNK1104: cannot open file 'kfr_dft.lib' Am I supposed to setup clang and all the tools and prebuild the code like in 'Build and install KFR (recommended)'? windows