https://github.com/microsoft/vscode-cpptools/issues/5415

 

1. Install the following packages via apt

sudo apt install clang-10 llvm-10-dev liblldb-10-dev

 

2. Create soft links for executable files so things can work as expected

sudo ln -s /usr/bin/clang-10 /usr/bin/clang
sudo ln -s /usr/bin/clang++-10 /usr/bin/clang++
sudo ln -s /usr/bin/lldb-10 /usr/bin/lldb
# This one is a bit strange but VSCode only looks for the name `lldb-server-10.0.0` but not `lldb-server-10`
sudo ln -s /usr/bin/lldb-server-10 /usr/bin/lldb-server-10.0.0

 

3. Build the lldb-mi executable from source

git clone https://github.com/lldb-tools/lldb-mi.git
cd lldb-mi
cmake .
cmake --build .
sudo cp src/lldb-mi /usr/bin/

 

These should be it. And here's my launch.json. Basically just the default one from clang++ preset and changed nothing if I remember it correctly.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "clang-10 - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/hello-world",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "miDebuggerPath": "/usr/bin/lldb-mi"
        }
    ]
}

 

 

https://blog.csdn.net/tanmx219/article/details/86681167

 

cmake_minimum_required( VERSION 2.6.3 )
set(CMAKE_SYSTEM_NAME Linux )
set(CMAKE_BUILD_TYPE DEBUG)

SET (CMAKE_C_COMPILER             "/usr/bin/clang")
SET (CMAKE_C_FLAGS                "-Wall -std=c99")
SET (CMAKE_C_FLAGS_DEBUG          "-O0 -g")
SET (CMAKE_C_FLAGS_MINSIZEREL     "-Os -DNDEBUG")
SET (CMAKE_C_FLAGS_RELEASE        "-O3 -DNDEBUG")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
 
SET (CMAKE_CXX_COMPILER             "/usr/bin/clang++")
SET (CMAKE_CXX_FLAGS                "-Wall")
SET (CMAKE_CXX_FLAGS_DEBUG          "-O0 -g")
SET (CMAKE_CXX_FLAGS_MINSIZEREL     "-Os -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELEASE        "-O3 -DNDEBUG")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
 
SET (CMAKE_AR      "/usr/bin/llvm-ar-10")
SET (CMAKE_LINKER  "/usr/bin/llvm-ld-10")
SET (CMAKE_NM      "/usr/bin/llvm-nm-10")
SET (CMAKE_OBJDUMP "/usr/bin/llvm-objdump-10")
SET (CMAKE_RANLIB  "/usr/bin/llvm-ranlib-10")

 

cmake_minimum_required(VERSION 3.7.1)
 
project(hello-world)
 
find_package(LLVM REQUIRED CONFIG)
 
set(SOURCE_FILES main.c)
 
message(STATUS "This is BINARY dir " ${PROJECT_BINARY_DIR})
message(STATUS "This is SOURCE dir " ${PROJECT_SOURCE_DIR})
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
 
# Set your project compile flags.
# E.g. if using the C++ header files
# you will need to enable C++11 support
# for your compiler.
 
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
 
# Now build our tools
add_executable(hello-world ${SOURCE_FILES})
 
 
# Find the libraries that correspond to the LLVM components
# that we wish to use
llvm_map_components_to_libnames(llvm_libs support core irreader)
 
# Link against LLVM libraries
target_link_libraries(hello-world ${llvm_libs})

 

cmake  -DCMAKE_TOOLCHAIN_FILE=./linux.toolchain.cmake -Bbuild -GNinja
ninja -Cbuild -v

 

相关文章:

  • 2022-12-23
  • 2021-08-05
  • 2022-01-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-27
  • 2022-01-19
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
相关资源
相似解决方案