1

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" folder

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. LibClang

Does anyone know where is the correct clang library path on windows??

someone
  • 122
  • 2
  • 9
  • Is it not supposed to be `clang HINTS "C:/Program\ Files\ (x86)/LLVM/lib"` ? – super Jan 31 '19 at 07:45
  • 1
    @super: in CMake no needs to escape spaces with `"\ "` - within double quotes the spaces are just spaces. But you are right that within CMake code "universal" path separator (`/`) is preferred. – Tsyvarev Jan 31 '19 at 08:15
  • I had tried ```clang HINTS "C:/Program\ Files\ (x86)/LLVM/lib" ```, but still don't work :( – someone Jan 31 '19 at 12:08

1 Answers1

1

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

Stanislav Sagan
  • 362
  • 2
  • 3