-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't find the C++ standard library #1419
Comments
It's weird, seems g++ and gcc can be indexed both... |
Maybe this will help you: #370 |
You can install latest
|
Hi @llzzzzoo! My bad for jumpin in late, but can u try compiling this file ( #include <any>
#include <list>
int main() { std::any any{std::list<int>{}}; } with: clang++ -std=gnu++17 test.cpp -v and drop the compiler output here? Just wanna check if it's an issue with library search paths or smth else 🤔 u should see smth kinda like this: FreeBSD clang version 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15a9eac9)
Target: x86_64-unknown-freebsd14.1
Thread model: posix
InstalledDir: /usr/bin
"/usr/bin/clang++" -cc1 -triple x86_64-unknown-freebsd14.1 -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model static -mframe-pointer=all -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/jint/Desktop -v -fcoverage-compilation-dir=/home/jint/Desktop -resource-dir /usr/lib/clang/18 -internal-isystem /usr/include/c++/v1 -internal-isystem /usr/lib/clang/18/include -internal-externc-isystem /usr/include -std=gnu++17 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-829d36.o -x c++ test.cpp
clang -cc1 version 18.1.5 based upon LLVM 18.1.5 default target x86_64-unknown-freebsd14.1
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/v1
/usr/lib/clang/18/include
/usr/include
End of search list.
"/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/test-829d36.o -lc++ -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o lmk what u get! |
OK. Here is the output.
|
Thanks! First off, did u install our config using the install script? Cuz that sets up all the necessary packages for u. If yes, go to 1, otherwise skip to 2.
local function switch_source_header_splitcmd(bufnr, splitcmd)
bufnr = require("lspconfig").util.validate_bufnr(bufnr)
local clangd_client = require("lspconfig").util.get_active_client_by_name(bufnr, "clangd")
local params = { uri = vim.uri_from_bufnr(bufnr) }
if clangd_client then
clangd_client.request("textDocument/switchSourceHeader", params, function(err, result)
if err then
error(tostring(err))
end
if not result then
vim.notify("Corresponding file can’t be determined", vim.log.levels.ERROR, { title = "LSP Error!" })
return
end
vim.api.nvim_command(splitcmd .. " " .. vim.uri_to_fname(result))
end)
else
vim.notify(
"Method textDocument/switchSourceHeader is not supported by any active server on this buffer",
vim.log.levels.ERROR,
{ title = "LSP Error!" }
)
end
end
local function get_binary_path_list(binaries)
local path_list = {}
for _, binary in ipairs(binaries) do
local path = vim.fn.exepath(binary)
if path ~= "" then
table.insert(path_list, path)
end
end
return table.concat(path_list, ",")
end
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/clangd.lua
return function(options)
require("lspconfig").clangd.setup({
on_attach = options.on_attach,
capabilities = vim.tbl_deep_extend("keep", { offsetEncoding = { "utf-16", "utf-8" } }, options.capabilities),
single_file_support = true,
cmd = {
"clangd",
"-j=12",
"--enable-config",
"--background-index",
"--pch-storage=memory",
-- You MUST set this arg ↓ to your c/cpp compiler location (if not included)!
"--query-driver=" .. get_binary_path_list({ "gcc", "g++" }),
"--clang-tidy",
"--all-scopes-completion",
"--completion-style=detailed",
"--header-insertion-decorators",
"--header-insertion=iwyu",
"--limit-references=3000",
"--limit-results=350",
},
commands = {
ClangdSwitchSourceHeader = {
function()
switch_source_header_splitcmd(0, "edit")
end,
description = "Open source/header in current buffer",
},
ClangdSwitchSourceHeaderVSplit = {
function()
switch_source_header_splitcmd(0, "vsplit")
end,
description = "Open source/header in a new vsplit",
},
ClangdSwitchSourceHeaderSplit = {
function()
switch_source_header_splitcmd(0, "split")
end,
description = "Open source/header in a new split",
},
},
})
end That tells
Note Installing anything non-MSVC without a package manager is a nightmare, so I wouldn't even try it unless u really have to. |
A general advice is if ur just using C++ u don't need it. But r u using any part of LLVM's compiler infrastructure like LLVM IR or specific compiler/diagnostics options? If not, just uninstall it lol cuz on Windows u usually gotta bootstrap LLVM urself so it knows where ur system headers are and fixes the search path.
u don't need to modify anything lol just copy the code I attached above, and it'll automatically detect ur GCC install. And the file is called |
that's expected. since we define this |
Version confirmation
Following prerequisites
Not a user config issue
Neovim version
NVIM v0.10.3
Operating system/version
Windows 11
Terminal name/version
PowerShell 7.5.0
$TERM environment variable
No response
Branch info
main (Default/Latest)
Fetch Preferences
SSH (use_ssh = true)
Affected language servers
any
How to reproduce the issue
I have the same problem as the link below. I can run the cpp file normally from the terminal, but the compiler still throws an error.
#1366
How can I finish that? Thank you so much.
Actual behavior
Expected behavior
Eliminate these error messages.
Support info
Logs
Additional information
No response
The text was updated successfully, but these errors were encountered: