cmake: LIBCLANG_PATH not found on windows - c++

I am trying to write a simple clang AST cursor traveler.
https://github.com/dyhe83/clang-AST-cursor-traveler
This following cmake code works fine on Linux.
PROJECT(traveler)
FIND_LIBRARY(LIBCLANG_PATH
clang HINTS /usr/local/lib/
)
ADD_EXECUTABLE(traveler
traveler.cpp
)
TARGET_LINK_LIBRARIES(traveler
${LIBCLANG_PATH}
)
I also want to run this example on windows.
My LLVM is build in "C:\Program Files (x86)\LLVM"
But after I changed the FIND_LIBRARY part of CMakeLists.txt.
FIND_LIBRARY(LIBCLANG_PATH
clang HINTS "C:\\Program Files (x86)\\LLVM\\lib"
)
Some error occurs:
D:\WorkSpace\C\clang-AST-cursor-traveler\build>cmake ..
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.16.27025.1
-- The CXX compiler identification is MSVC 19.16.27025.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBCLANG_PATH
linked by target "traveler" in directory D:/WorkSpace/C/clang-AST-cursor-traveler/src
-- Configuring incomplete, errors occurred!
See also "D:/WorkSpace/C/clang-AST-cursor-traveler/build/CMakeFiles/CMakeOutput.log".
And "C:\Program Files (x86)\LLVM\lib" have the libraries.
Does anyone know where is the correct clang library path on windows??

Try to set env virable in windows.
I mean the place where you add/edit PATH env virables
LIBCLANG_PATH=C:\Program Files (x86)\LLVM\lib

Related

Change Compiler VsCode

I am new in c++
The cmakelist.txt file dont give me a Makefile
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22000.
-- The C compiler identification is MSVC 19.29.30140.0
-- The CXX compiler identification is MSVC 19.29.30140.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/JohnSmith/Documents/Hello/build
I dont know how to change the compiler to G++
this is the cmake
cmake_minimum_required(VERSION 3.0)
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
project(HelLo)
add_executable(Hello main.cpp hello.cpp)
I am on windows , Thanks for help
(I can compile with g++ and gcc just cmakefile dont work )
First, make sure you've installed gcc/g++ under Windows (either CygWin or MinGW). Remove the set commands from your CMakelists.txt. Then in a CygWin/MinGW shell use the following command to generate the Makefile:
CC=gcc CXX=c++ cmake ..
cmake -G "Unix Makefiles" ..

CMake can not determine linker language for target - C++

I'm trying to develop an engine for private use, I'm using CMake because I intend to make it multiplatform in the future, but an error started to appear that I never came across before, I tried to change project(IEngine) to project(IEngine CXX) as said in other questions from stack overflow, but the error persists, here's my CMakeLists
cmake_minimum_required(VERSION 3.16.2)
project(IEngine)
find_package(Vulkan REQUIRED)
file(GLOB_RECURSE SRC_RENDERER
"${IEngine_SOURCE_DIR}/src/Renderer/*.cpp"
"${IEngine_SOURCE_DIR}/src/Renderer/*.hpp"
"${IEngine_SOURCE_DIR}/src/Renderer/*.h")
source_group("Renderer" FILES ${SRC_RENDERER})
add_library(IEngine STATIC ${SRC_RENDERER})
if(WIN32)
target_compile_definitions(IEngine PRIVATE VK_USE_PLATFORM_WIN32_KHR)
endif()
target_include_directories(IEngine PRIVATE Vulkan::Vulkan)
target_link_libraries(IEngine Vulkan::Vulkan)
The output:
Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.24.28315.0
The CXX compiler identification is MSVC 19.24.28315.0
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Found Vulkan: A:/VulkanSDK/1.2.131.1/Lib/vulkan-1.lib
Configuring done
CMake Error: CMake can not determine linker language for target: IEngine
Generating done
I've had this error many times :( Add this to your CMakeLists.txt:
set_target_properties(IEngine PROPERTIES LINKER_LANGUAGE CXX)

Error while building a cpp application by linking with PCL

I built PCL on windows using VCPKG(MS Visual studio 2017). I am trying to build a CPP application with PCL using cmake 3.12 with the following CMakelists.txt.
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(compute)
find_package(PCL 1.5 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (compute compute.cpp)
target_link_libraries (compute ${PCL_LIBRARIES})
I also set the following environment variables.
set PCL_INCLUDE_DIRS="C:\vcpkg-pcl\vcpkg-master\installed\x64-windows\include\pcl"
SET PCL_LIBRARY_DIRS="C:\vcpkg-pcl\vcpkg-master\installed\x64-windows\lib"
set PCL_LIBRARIES="pcl_common_release.lib;pcl_features_release.lib;pcl_filters_release.lib;pcl_io_ply_release.lib;pcl_io_release.lib"
I initially got an error saying it is unable to find the file FindPCL.cmake and eventually PCLConfig.cmake or PCL-Config.cmake. I set the environment variable
set PCL_DIR=C:\vcpkg-pcl\vcpkg-master\installed\x64-windows\share\pcl
where the PCLConfig.cmake is installed. It was able to detect the file. However,
it is unable to detect PCL(pcl_report_not_found) with the following error.
c:\PCL-Program>cmake .
-- Building for: Visual Studio 15 2017
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
-- The C compiler identification is MSVC 19.16.27023.1
-- The CXX compiler identification is MSVC 19.16.27023.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find Eigen (missing: EIGEN_INCLUDE_DIR)
CMake Error at C:/vcpkg-pcl/vcpkg-master/installed/x64-windows/share/pcl/PCLConfig.cmake:56 (message):
common is required but eigen was not found
Call Stack (most recent call first):
C:/vcpkg-pcl/vcpkg-master/installed/x64-windows/share/pcl/PCLConfig.cmake:356 (pcl_report_not_found)
C:/vcpkg-pcl/vcpkg-master/installed/x64-windows/share/pcl/PCLConfig.cmake:526 (find_external_library)
CMakeLists.txt:5 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/PCL-Program/CMakeFiles/CMakeOutput.log".
c:\PCL-Program>set EIGEN_INCLUDE_DIR
EIGEN_INCLUDE_DIR=C:\vcpkg-pcl\vcpkg-master\installed\x64-windows\include\Eigen
Even after setting the environment variable for EIGEN_INCLUDE_DIR, I am still getting the same error. Please let me know if I am following the right way.
Thanks!

Building Cryptonote source with Boost on Windows 10

I'm trying to build Cryptonote source from GitHub - https://github.com/cryptonotefoundation/cryptonote
I've already successful complete building on Unix, but on Windows I have some problems with that.
I've install on my Windows 10 x64:
Microsoft Visual Studio 2013
Git
CMake 3.10.1
Python 2.7.9
Then I'm trying build and install
Boost 1.55.0
Downloaded "boost_1_55_0.zip" from here https://sourceforge.net/projects/boost/files/boost/1.55.0/
After unpacking I run from cmd
bootstrap.bat
Next I enter
.\b2
When build is done let's do install
.\b2 --toolset=msvc-12.0 --build-type=complete --prefix=D:\Boost install
Ok next is build Cryptonote sources, going to C:\cryptonote, create dir "build" and enter to "build" dir.
Now I trying to build Cryptonote by entering this
cmake -DBOOST_ROOT:PATHNAME=D:\Boost -g "Visual Studio 2012 Win64" ..
Here is output:
-- Building for: Visual Studio 12 2013
-- The C compiler identification is MSVC 18.0.31101.0
-- The CXX compiler identification is MSVC 18.0.31101.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1928 (message):
Unable to find the requested Boost libraries.
Boost version: 1.55.0
Boost include path: D:/Boost/include/boost-1_55
Could not find the following static Boost libraries:
boost_serialization
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:112 (find_package)
-- Found Git: C:/Program Files/Git/cmd/git.exe
-- Found PythonInterp: C:/Python27/python.exe (found version "2.7.9")
CMake Warning in CMakeLists.txt:
CMAKE_SKIP_INSTALL_RULES was enabled even though installation rules have
been specified
-- Configuring incomplete, errors occurred!
See also "C:/cryptonote/build/CMakeFiles/CMakeOutput.log".
See also "C:/cryptonote/build/CMakeFiles/CMakeError.log".
Where I can find that library? Or what I need to do for complete build? Thank you!

Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed

I'm currently getting this error while trying to configure a project on CMAKE using Visual Studio 15 2017 Win64:
The C compiler identification is MSVC 19.11.25547.0
The CXX compiler identification is MSVC 19.11.25547.0
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Found OpenGL: opengl32
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE
Using Win32 for window creation
Using WGL for context creation
Lib glbinding
Performing Test COMPILER_HAS_DEPRECATED_ATTR
Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed
Performing Test COMPILER_HAS_DEPRECATED
Performing Test COMPILER_HAS_DEPRECATED - Success
Configuring done
I've used this compiler to generate another project and it still works.
Here is the code relevant to the new CMakeLists.txt:
project(ms3d_td3)
cmake_minimum_required(VERSION 3.2.0)
add_subdirectory(ext/glfw)
add_subdirectory(ext/glbinding)
include_directories(ext/glfw/include)
include_directories(ext/glbinding/include)
include_directories(ext/eigen3)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
set(SRC_FILES
src/main.cpp
src/viewer.cpp
src/viewer.h
src/shader.cpp
src/shader.h
src/opengl.h)
add_definitions(-DDATA_DIR="${PROJECT_SOURCE_DIR}/data")
add_executable(ms3d_td3 ${SRC_FILES})
target_link_libraries(ms3d_td3 glfw ${GLFW_LIBRARIES} glbinding)
Under Visual Studio 2017 I get a CMAKE_C_COMPILER not set after EnableLanguage. I tried to set it manually to the VisualStudio 2017 compiler but no success. Any ideas?
Another person had a similar problem and solved it by upgrading Visual Studio a while ago so I'm guessing this is coming from somewhere else... :
Compiler failing on C++11 instructions in a Visual Studio project configured with cmake
Thanks!
To require compiler support for the [[decprecated]] attribute, use target_compile_features and specify the cxx_attribute_deprecated feature. For example:
add_executable(foo foo.cpp)
target_compile_features(foo PRIVATE cxx_attribute_deprecated)
If you need to conditionally test for this so that you can configure a header file, use check_cxx_source_compiles.