Stdlib h ошибка

I am using various stdlib functions like srand(), etc. I have the line

#include <stdlib.h>

at the top of my code.

I entered this on the command line:

# find / -name stdlib.h

find: `/home/dmurvihill/.gvfs: permission denied
/usr/include/stdlib.h
/usr/include/bits/stdlib.h

So, stdlib.h is clearly in /usr/include.

My preprocessor:

# gcc -print-prog-name=cc1

/usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1

My preprocessor’s default search path:

# /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1 -v

ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include
/usr/include
End of search list.

So, stdlib.h is clearly in /usr/include, which is most definitely supposed to be searched by my preprocessor, but I still get this error!

/path/to/cpa_sample_code_main.c:15:20: fatal error: stdlib.h: No such file or directory
compilation terminated

Update

A program I wrote to test this code:

#include <stdio.h>
#include <stdlib.h>
#include <linux/time.h>

int main()
{
    printf("Hello, World!\n");
    printf("Getting time...\n");
    time_t seconds;
    time(&seconds);
    printf("Seeding generator...\n");
    srand((unsigned int)seconds);
    printf("Getting random number...\n");
    int value = rand();
    printf("It is %d!",value);
    printf("Goodbye, cruel world!");
    return 0;
}

The command

gcc -H -v -fsyntax-only stdlib_test.c

output

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.5.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC) 
COLLECT_GCC_OPTIONS='-H' '-v' '-fsyntax-only' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1 -quiet -v -H /CRF_Verify/stdlib_test.c -quiet -dumpbase stdlib_test.c -mtune=generic -march=x86-64 -auxbase stdlib_test -version -fsyntax-only -o /dev/null
GNU C (GCC) version 4.5.1 20100924 (Red Hat 4.5.1-4) (x86_64-redhat-linux)
    compiled by GNU C version 4.5.1 20100924 (Red Hat 4.5.1-4), GMP version 4.3.1, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include
 /usr/include
End of search list.
GNU C (GCC) version 4.5.1 20100924 (Red Hat 4.5.1-4) (x86_64-redhat-linux)
    compiled by GNU C version 4.5.1 20100924 (Red Hat 4.5.1-4), GMP version 4.3.1, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: ea394b69293dd698607206e8e43d607e
. /usr/include/stdio.h
.. /usr/include/features.h
... /usr/include/sys/cdefs.h
.... /usr/include/bits/wordsize.h
... /usr/include/gnu/stubs.h
.... /usr/include/bits/wordsize.h
.... /usr/include/gnu/stubs-64.h
.. /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stddef.h
.. /usr/include/bits/types.h
... /usr/include/bits/wordsize.h
... /usr/include/bits/typesizes.h
.. /usr/include/libio.h
... /usr/include/_G_config.h
.... /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stddef.h
.... /usr/include/wchar.h
... /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stdarg.h
.. /usr/include/bits/stdio_lim.h
.. /usr/include/bits/sys_errlist.h
. /usr/include/stdlib.h
.. /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stddef.h
.. /usr/include/bits/waitflags.h
.. /usr/include/bits/waitstatus.h
... /usr/include/endian.h
.... /usr/include/bits/endian.h
.... /usr/include/bits/byteswap.h
..... /usr/include/bits/wordsize.h
.. /usr/include/sys/types.h
... /usr/include/time.h
... /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stddef.h
... /usr/include/sys/select.h
.... /usr/include/bits/select.h
..... /usr/include/bits/wordsize.h
.... /usr/include/bits/sigset.h
.... /usr/include/time.h
.... /usr/include/bits/time.h
... /usr/include/sys/sysmacros.h
... /usr/include/bits/pthreadtypes.h
.... /usr/include/bits/wordsize.h
.. /usr/include/alloca.h
... /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stddef.h
. /usr/include/linux/time.h
.. /usr/include/linux/types.h
... /usr/include/asm/types.h
.... /usr/include/asm-generic/types.h
..... /usr/include/asm-generic/int-ll64.h
...... /usr/include/asm/bitsperlong.h
....... /usr/include/asm-generic/bitsperlong.h
... /usr/include/linux/posix_types.h
.... /usr/include/linux/stddef.h
.... /usr/include/asm/posix_types.h
..... /usr/include/asm/posix_types_64.h
In file included from /CRF_Verify/stdlib_test.c:3:0:
/usr/include/linux/time.h:9:8: error: redefinition of ‘struct timespec’
/usr/include/time.h:120:8: note: originally defined here
/usr/include/linux/time.h:15:8: error: redefinition of ‘struct timeval’
/usr/include/bits/time.h:75:8: note: originally defined here
Multiple include guards may be useful for:
/usr/include/asm/posix_types.h
/usr/include/bits/byteswap.h
/usr/include/bits/endian.h
/usr/include/bits/select.h
/usr/include/bits/sigset.h
/usr/include/bits/stdio_lim.h
/usr/include/bits/sys_errlist.h
/usr/include/bits/time.h
/usr/include/bits/typesizes.h
/usr/include/bits/waitflags.h
/usr/include/bits/waitstatus.h
/usr/include/gnu/stubs-64.h
/usr/include/gnu/stubs.h
/usr/include/wchar.h

@palapapa

With this piece of code:

#include <iostream>
#include <vector>
#include <stdlib.h>

int main()
{
    std::vector<int> v;
}

clangd gave these errors:
圖片
Notice how the stdlib.h in the code didn’t generate an error but it did for iostream. It also gave a few strange errors for std::vector.

My flags:

"clangd.fallbackFlags": [
  "-Weverything",
  "-Wno-used-but-marked-unused",
  "-Wno-declaration-after-statement",
  "-Wno-vla",
  "-Wno-missing-prototypes",
  "-Wno-c++98-compat",
  "-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32",
  "-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0",
  "-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward",
  "-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include",
  "-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include",
  "-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed",
  "-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include",
  "-nostdinc",
  "-target",
  "x86_64-pc-windows-gnu",
  "-std=c++20"
]

Logs

I[21:25:18.871] clangd version 15.0.3 (https://github.com/llvm/llvm-project 4a2c05b05ed07f1f620e94f6524a8b4b2760a0b1)
I[21:25:18.871] Features: windows+grpc
I[21:25:18.871] PID: 22900
I[21:25:18.871] Working directory: C:\Users\User\AppData\Local\Programs\Microsoft VS Code
I[21:25:18.871] argv[0]: c:\Users\User\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\15.0.3\clangd_15.0.3\bin\clangd.exe
I[21:25:18.871] argv[1]: --log=verbose
V[21:25:18.877] User config file is C:\Users\User\AppData\Local\clangd\config.yaml
I[21:25:18.877] Starting LSP over stdin/stdout
V[21:25:18.877] <<< {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"markdown":{"parser":"marked","version":"1.1.0"},"positionEncodings":["utf-16"],"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"staleRequestSupport":{"cancel":true,"retryOnContentModified":["textDocument/semanticTokens/full","textDocument/semanticTokens/range","textDocument/semanticTokens/full/delta"]}},"notebookDocument":{"synchronization":{"dynamicRegistration":true,"executionSummarySupport":true}},"textDocument":{"callHierarchy":{"dynamicRegistration":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"dynamicRegistration":true,"honorsChangeAnnotations":false,"isPreferredSupport":true,"resolveSupport":{"properties":["edit"]}},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"completion":{"completionItem":{"commitCharactersSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"insertReplaceSupport":true,"insertTextModeSupport":{"valueSet":[1,2]},"labelDetailsSupport":true,"preselectSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode"]},"contextSupport":true,"dynamicRegistration":true,"editsNearCursor":true,"insertTextMode":2},"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"diagnostic":{"dynamicRegistration":true,"relatedDocumentSupport":false},"documentHighlight":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"documentSymbol":{"dynamicRegistration":true,"hierarchicalDocumentSymbolSupport":true,"labelSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"foldingRange":{"dynamicRegistration":true,"foldingRange":{"collapsedText":false},"foldingRangeKind":{"valueSet":["comment","imports","region"]},"lineFoldingOnly":true,"rangeLimit":5000},"formatting":{"dynamicRegistration":true},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"inlayHint":{"dynamicRegistration":true,"resolveSupport":{"properties":["tooltip","textEdits","label.tooltip","label.location","label.command"]}},"inlineValue":{"dynamicRegistration":true},"linkedEditingRange":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"codeDescriptionSupport":true,"dataSupport":true,"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":false},"rangeFormatting":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"honorsChangeAnnotations":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1},"selectionRange":{"dynamicRegistration":true},"semanticTokens":{"augmentsSyntaxTokens":true,"dynamicRegistration":true,"formats":["relative"],"multilineTokenSupport":false,"overlappingTokenSupport":false,"requests":{"full":{"delta":true},"range":true},"serverCancelSupport":true,"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"]},"signatureHelp":{"contextSupport":true,"dynamicRegistration":true,"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true,"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"typeHierarchy":{"dynamicRegistration":true}},"window":{"showDocument":{"support":true},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true},"workspace":{"applyEdit":true,"codeLens":{"refreshSupport":true},"configuration":true,"diagnostics":{"refreshSupport":true},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":true},"executeCommand":{"dynamicRegistration":true},"fileOperations":{"didCreate":true,"didDelete":true,"didRename":true,"dynamicRegistration":true,"willCreate":true,"willDelete":true,"willRename":true},"inlayHint":{"refreshSupport":true},"inlineValue":{"refreshSupport":true},"semanticTokens":{"refreshSupport":true},"symbol":{"dynamicRegistration":true,"resolveSupport":{"properties":["location.range"]},"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"workspaceEdit":{"changeAnnotationSupport":{"groupsOnLabel":true},"documentChanges":true,"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"Visual Studio Code","version":"1.77.3"},"initializationOptions":{"clangdFileStatus":true,"fallbackFlags":["-Weverything","-Wno-used-but-marked-unused","-Wno-declaration-after-statement","-Wno-vla","-Wno-missing-prototypes","-Wno-c++98-compat","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include","-nostdinc","-target","x86_64-pc-windows-gnu","-std=c++20"]},"locale":"en","processId":18388,"rootPath":null,"rootUri":null,"trace":"off","workspaceFolders":null}}

I[21:25:18.877] <-- initialize(0)
I[21:25:18.881] --> reply:initialize(0) 3 ms
V[21:25:18.881] >>> {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"clangdInlayHintsProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor","info"]},"compilationDatabase":{"automaticReload":true},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/","*"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"hoverProvider":true,"implementationProvider":true,"inlayHintProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["declaration","deprecated","deduced","readonly","static","abstract","virtual","dependentName","defaultLibrary","usedAsMutableReference","functionScope","classScope","fileScope","globalScope"],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","interface","enum","enumMember","type","type","unknown","namespace","typeParameter","concept","type","macro","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",")","{","}","<",">",","]},"standardTypeHierarchyProvider":true,"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeDefinitionProvider":true,"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"clangd","version":"clangd version 15.0.3 (https://github.com/llvm/llvm-project 4a2c05b05ed07f1f620e94f6524a8b4b2760a0b1) windows+grpc x86_64-pc-windows-msvc"}}}

V[21:25:18.885] <<< {"jsonrpc":"2.0","method":"initialized","params":{}}

I[21:25:18.885] <-- initialized
V[21:25:18.892] <<< {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"#include <iostream>\r\n#include <vector>\r\n#include <stdlib.h>\r\n\r\nint main()\r\n{\r\n    std::vector<int> v;\r\n}\r\n","uri":"file:///d%3A/Download/main.cpp","version":1}}}

I[21:25:18.892] <-- textDocument/didOpen
I[21:25:18.894] Failed to find compilation database for d:\Download\main.cpp
I[21:25:18.894] ASTWorker building file d:\Download\main.cpp version 1 with command clangd fallback
[d:\Download]
"C:\\mingw64\\bin\\clang" -Weverything -Wno-used-but-marked-unused -Wno-declaration-after-statement -Wno-vla -Wno-missing-prototypes -Wno-c++98-compat -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32 -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0 -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include -nostdinc -target x86_64-pc-windows-gnu -std=c++20 "-resource-dir=c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\lib\\clang\\15.0.3" -- "d:\\Download\\main.cpp"
V[21:25:18.901] Driver produced command: cc1 -cc1 -triple x86_64-pc-windows-gnu -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -mms-bitfields -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb "-fcoverage-compilation-dir=d:\\Download" -nostdsysteminc -nobuiltininc -resource-dir "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\lib\\clang\\15.0.3" -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include -internal-isystem "C:\\mingw64\\x86_64-w64-mingw32\\include\\c++" -internal-isystem "C:\\mingw64\\x86_64-w64-mingw32\\include\\c++\\x86_64-w64-mingw32" -internal-isystem "C:\\mingw64\\x86_64-w64-mingw32\\include\\c++\\backward" -internal-isystem "C:\\mingw64\\x86_64-w64-mingw32\\include\\c++\\12.2.0" -internal-isystem "C:\\mingw64\\x86_64-w64-mingw32\\include\\c++\\12.2.0\\x86_64-w64-mingw32" -internal-isystem "C:\\mingw64\\x86_64-w64-mingw32\\include\\c++\\12.2.0\\backward" -internal-isystem "C:\\mingw64\\include\\c++\\12.2.0" -internal-isystem "C:\\mingw64\\include\\c++\\12.2.0\\x86_64-w64-mingw32" -internal-isystem "C:\\mingw64\\include\\c++\\12.2.0\\backward" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\c++" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\c++\\x86_64-w64-mingw32" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\c++\\backward" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\g++-v12.2.0" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\g++-v12.2.0\\x86_64-w64-mingw32" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\g++-v12.2.0\\backward" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\g++-v12.2" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\g++-v12.2\\x86_64-w64-mingw32" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\g++-v12.2\\backward" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\g++-v12" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\g++-v12\\x86_64-w64-mingw32" -internal-isystem "C:\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\12.2.0\\include\\g++-v12\\backward" -Weverything -Wno-used-but-marked-unused -Wno-declaration-after-statement -Wno-vla -Wno-missing-prototypes -Wno-c++98-compat -std=c++20 -fdeprecated-macro "-fdebug-compilation-dir=d:\\Download" -ferror-limit 19 -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -exception-model=seh -no-round-trip-args -faddrsig -x c++ "d:\\Download\\main.cpp"
I[21:25:18.901] --> textDocument/clangd.fileStatus
V[21:25:18.901] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Update","uri":"file:///d:/Download/main.cpp"}}

V[21:25:18.901] Building first preamble for d:\Download\main.cpp version 1
V[21:25:19.480] indexed preamble AST for d:\Download\main.cpp version 1:
  symbol slab: 5871 symbols, 1796376 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 287 relations, 5396 bytes
V[21:25:19.520] Build dynamic index for header symbols with estimated memory usage of 4973860 bytes
V[21:25:19.529] Built preamble of size 4527576 for file d:\Download\main.cpp version 1 in 0.63 seconds
I[21:25:19.529] --> workspace/semanticTokens/refresh(0)
I[21:25:19.529] --> textDocument/clangd.fileStatus
V[21:25:19.529] >>> {"id":0,"jsonrpc":"2.0","method":"workspace/semanticTokens/refresh","params":null}

V[21:25:19.529] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Build AST","uri":"file:///d:/Download/main.cpp"}}

V[21:25:19.545] indexed file AST for d:\Download\main.cpp version 1:
  symbol slab: 1 symbols, 4456 bytes
  ref slab: 2 symbols, 2 refs, 4280 bytes
  relations slab: 0 relations, 24 bytes
V[21:25:19.545] Build dynamic index for main-file symbols with estimated memory usage of 11592 bytes
I[21:25:19.545] --> textDocument/publishDiagnostics
V[21:25:19.545] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"pp_file_not_found","message":"In included file: 'stdlib.h' file not found","range":{"end":{"character":10,"line":0},"start":{"character":9,"line":0}},"relatedInformation":[{"location":{"range":{"end":{"character":24,"line":74},"start":{"character":14,"line":74}},"uri":"file:///C:/mingw64/include/c%2B%2B/12.2.0/cstdlib"},"message":"Error occurred here"}],"severity":1,"source":"clang"},{"code":"typename_nested_not_found","message":"In template: no type named '_Tp_alloc_type' in 'std::_Vector_base<int, std::allocator<int>>'","range":{"end":{"character":22,"line":6},"start":{"character":21,"line":6}},"relatedInformation":[{"location":{"range":{"end":{"character":44,"line":443},"start":{"character":14,"line":443}},"uri":"file:///C:/mingw64/include/c%2B%2B/12.2.0/bits/stl_vector.h"},"message":"Error occurred here"},{"location":{"range":{"end":{"character":22,"line":6},"start":{"character":21,"line":6}},"uri":"file:///D:/Download/main.cpp"},"message":"In instantiation of template class 'std::vector<int>' requested here"}],"severity":1,"source":"clang"},{"code":"typename_nested_not_found","message":"In included file: no type named 'pointer' in 'std::_Vector_base<int, std::allocator<int>>'","range":{"end":{"character":10,"line":1},"start":{"character":9,"line":1}},"relatedInformation":[{"location":{"range":{"end":{"character":37,"line":448},"start":{"character":14,"line":448}},"uri":"file:///C:/mingw64/include/c%2B%2B/12.2.0/bits/stl_vector.h"},"message":"Error occurred here"}],"severity":1,"source":"clang"}],"uri":"file:///d:/Download/main.cpp","version":1}}

I[21:25:19.545] --> textDocument/clangd.fileStatus
V[21:25:19.545] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:25:27.010] <<< {"id":1,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:25:27.010] <-- textDocument/documentLink(1)
V[21:25:27.010] ASTWorker running DocumentLinks on version 1 of d:\Download\main.cpp
I[21:25:27.011] --> reply:textDocument/documentLink(1) 0 ms
V[21:25:27.011] >>> {"id":1,"jsonrpc":"2.0","result":[{"range":{"end":{"character":19,"line":0},"start":{"character":9,"line":0}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/iostream"},{"range":{"end":{"character":17,"line":1},"start":{"character":9,"line":1}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/vector"},{"range":{"end":{"character":19,"line":2},"start":{"character":9,"line":2}},"target":"file:///C:/mingw64/x86_64-w64-mingw32/include/stdlib.h"}]}

I[21:25:27.011] --> textDocument/clangd.fileStatus
V[21:25:27.011] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:25:27.160] <<< {"jsonrpc":"2.0","method":"$/setTrace","params":{"value":"off"}}

I[21:25:27.160] <-- $/setTrace
I[21:25:27.160] unhandled notification $/setTrace
V[21:25:27.191] <<< {"id":2,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:25:27.191] <-- textDocument/semanticTokens/full(2)
V[21:25:27.192] ASTWorker running SemanticHighlights on version 1 of d:\Download\main.cpp
I[21:25:27.192] --> reply:textDocument/semanticTokens/full(2) 0 ms
V[21:25:27.192] >>> {"id":2,"jsonrpc":"2.0","result":{"data":[4,4,4,3,8193,2,4,3,15,8448,0,5,6,8,8448,0,12,1,1,1025],"resultId":"1"}}

I[21:25:27.192] --> textDocument/clangd.fileStatus
V[21:25:27.192] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:25:27.233] <<< {"jsonrpc":"2.0","method":"$/setTrace","params":{"value":"off"}}

I[21:25:27.233] <-- $/setTrace
I[21:25:27.233] unhandled notification $/setTrace
V[21:25:27.759] <<< {"jsonrpc":"2.0","method":"$/setTrace","params":{"value":"off"}}

I[21:25:27.759] <-- $/setTrace
I[21:25:27.759] unhandled notification $/setTrace
V[21:25:27.831] <<< {"id":3,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:25:27.831] <-- textDocument/documentSymbol(3)
V[21:25:27.831] ASTWorker running DocumentSymbols on version 1 of d:\Download\main.cpp
I[21:25:27.831] --> reply:textDocument/documentSymbol(3) 0 ms
V[21:25:27.831] >>> {"id":3,"jsonrpc":"2.0","result":[{"detail":"int ()","kind":12,"name":"main","range":{"end":{"character":1,"line":7},"start":{"character":0,"line":4}},"selectionRange":{"end":{"character":8,"line":4},"start":{"character":4,"line":4}}}]}

I[21:25:27.831] --> textDocument/clangd.fileStatus
V[21:25:27.831] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:25:27.871] <<< {"id":0,"jsonrpc":"2.0","result":null}

I[21:25:27.871] <-- reply(0)
V[21:25:27.906] <<< {"id":4,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:25:27.906] <-- textDocument/documentLink(4)
V[21:25:27.906] ASTWorker running DocumentLinks on version 1 of d:\Download\main.cpp
I[21:25:27.906] --> reply:textDocument/documentLink(4) 0 ms
V[21:25:27.906] >>> {"id":4,"jsonrpc":"2.0","result":[{"range":{"end":{"character":19,"line":0},"start":{"character":9,"line":0}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/iostream"},{"range":{"end":{"character":17,"line":1},"start":{"character":9,"line":1}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/vector"},{"range":{"end":{"character":19,"line":2},"start":{"character":9,"line":2}},"target":"file:///C:/mingw64/x86_64-w64-mingw32/include/stdlib.h"}]}

I[21:25:27.906] --> textDocument/clangd.fileStatus
V[21:25:27.906] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:25:27.943] <<< {"id":5,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:25:27.943] <-- textDocument/documentSymbol(5)
V[21:25:27.944] ASTWorker running DocumentSymbols on version 1 of d:\Download\main.cpp
I[21:25:27.944] --> reply:textDocument/documentSymbol(5) 0 ms
V[21:25:27.944] >>> {"id":5,"jsonrpc":"2.0","result":[{"detail":"int ()","kind":12,"name":"main","range":{"end":{"character":1,"line":7},"start":{"character":0,"line":4}},"selectionRange":{"end":{"character":8,"line":4},"start":{"character":4,"line":4}}}]}

I[21:25:27.944] --> textDocument/clangd.fileStatus
V[21:25:27.944] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:25:27.955] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":3}}

I[21:25:27.955] <-- $/cancelRequest
V[21:25:27.971] <<< {"id":6,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:25:27.971] <-- textDocument/documentSymbol(6)
V[21:25:27.971] ASTWorker running DocumentSymbols on version 1 of d:\Download\main.cpp
I[21:25:27.971] --> reply:textDocument/documentSymbol(6) 0 ms
V[21:25:27.971] >>> {"id":6,"jsonrpc":"2.0","result":[{"detail":"int ()","kind":12,"name":"main","range":{"end":{"character":1,"line":7},"start":{"character":0,"line":4}},"selectionRange":{"end":{"character":8,"line":4},"start":{"character":4,"line":4}}}]}

I[21:25:27.971] --> textDocument/clangd.fileStatus
V[21:25:27.971] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:25:27.987] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":5}}

I[21:25:27.987] <-- $/cancelRequest
V[21:25:28.000] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":4}}

I[21:25:28.000] <-- $/cancelRequest
V[21:25:28.012] <<< {"id":7,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:25:28.012] <-- textDocument/documentLink(7)
V[21:25:28.012] ASTWorker running DocumentLinks on version 1 of d:\Download\main.cpp
I[21:25:28.012] --> reply:textDocument/documentLink(7) 0 ms
V[21:25:28.012] >>> {"id":7,"jsonrpc":"2.0","result":[{"range":{"end":{"character":19,"line":0},"start":{"character":9,"line":0}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/iostream"},{"range":{"end":{"character":17,"line":1},"start":{"character":9,"line":1}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/vector"},{"range":{"end":{"character":19,"line":2},"start":{"character":9,"line":2}},"target":"file:///C:/mingw64/x86_64-w64-mingw32/include/stdlib.h"}]}

I[21:25:28.012] --> textDocument/clangd.fileStatus
V[21:25:28.012] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:25:28.888] <<< {"id":8,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full/delta","params":{"previousResultId":"1","textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:25:28.888] <-- textDocument/semanticTokens/full/delta(8)
V[21:25:28.888] ASTWorker running SemanticHighlights on version 1 of d:\Download\main.cpp
I[21:25:28.888] --> reply:textDocument/semanticTokens/full/delta(8) 0 ms
V[21:25:28.888] >>> {"id":8,"jsonrpc":"2.0","result":{"edits":[],"resultId":"2"}}

I[21:25:28.888] --> textDocument/clangd.fileStatus
V[21:25:28.888] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

System information
Clangd version (from the log, or clangd --version): 15.0.3
clangd extension version: 0.1.24
Operating system: Windows 10

@HighCommander4

The usual diagnostic strategy to try in a situation like this is to take the command clangd tells you it’s running from the log, and try running it on the command line, with the slight modification of removing the -resource-dir argument which it adds.

So that gives us:

"C:\\mingw64\\bin\\clang" -Weverything -Wno-used-but-marked-unused -Wno-declaration-after-statement -Wno-vla -Wno-missing-prototypes -Wno-c++98-compat -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32 -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0 -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include -nostdinc -target x86_64-pc-windows-gnu -std=c++20 -- "d:\\Download\\main.cpp"

Does that give any errors when run on the command line?

@palapapa

That gives:

In file included from d:\\Download\\main.cpp:1:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/iostream:34:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_IOSTREAM 1
        ^
In file included from d:\\Download\\main.cpp:2:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/vector:56:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_VECTOR 1
        ^
In file included from d:\\Download\\main.cpp:3:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/stdlib.h:34:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_STDLIB_H 1
        ^
3 warnings generated.
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.text+0xc): undefined reference to `std::ios_base::Init::Init()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.text+0x3c): undefined reference to `std::ios_base::Init::~Init()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.xdata$_ZNSt6vectorIiSaIiEED2Ev+0x8): undefined reference to `__gxx_personality_seh0'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.text$__clang_call_terminate[__clang_call_terminate]+0x5): undefined reference to `__cxa_begin_catch'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.text$__clang_call_terminate[__clang_call_terminate]+0xa): undefined reference to `std::terminate()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.xdata$_ZNSt12_Vector_baseIiSaIiEED2Ev+0x8): undefined reference to `__gxx_personality_seh0'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.text$_ZNSt15__new_allocatorIiE10deallocateEPiy[_ZNSt15__new_allocatorIiE10deallocateEPiy]+0x19): undefined reference to `operator delete(void*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

With -v:

(built by Brecht Sanders) clang version 16.0.0
Target: x86_64-pc-windows-gnu
Thread model: posix
InstalledDir: C:/mingw64/bin
 "C:/mingw64/bin/clang.exe" -cc1 -triple x86_64-pc-windows-gnu -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -mms-bitfields -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=D:/Download -nostdsysteminc -nobuiltininc -resource-dir C:/mingw64/lib/clang/16 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include -Weverything -Wno-used-but-marked-unused -Wno-declaration-after-statement -Wno-vla -Wno-missing-prototypes -Wno-c++98-compat -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=D:/Download -ferror-limit 19 -fmessage-length=252 -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -exception-model=seh -fcolor-diagnostics -faddrsig -o C:/Users/User/AppData/Local/Temp/main-1dc091.o -x c++ "d:\\\\Download\\\\main.cpp"
clang -cc1 version 16.0.0 based upon LLVM 16.0.0 default target x86_64-w64-mingw32
#include "..." search starts here:
#include <...> search starts here:
 C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32
 C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0
 C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward
 C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include
 C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include
 C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed
 C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include
End of search list.
In file included from d:\\Download\\main.cpp:1:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/iostream:34:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_IOSTREAM 1
        ^
In file included from d:\\Download\\main.cpp:2:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/vector:56:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_VECTOR 1
        ^
In file included from d:\\Download\\main.cpp:3:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/stdlib.h:34:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_STDLIB_H 1
        ^
3 warnings generated.
 "C:/mingw64/bin/ld" -m i386pep -Bdynamic -o a.exe C:/mingw64/x86_64-w64-mingw32/lib/crt2.o C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/crtbegin.o -LC:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0 -LC:/mingw64/x86_64-w64-mingw32/lib -LC:/mingw64/x86_64-w64-mingw32/mingw/lib -LC:/mingw64/lib C:/Users/User/AppData/Local/Temp/main-1dc091.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/crtend.o
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.text+0xc): undefined reference to `std::ios_base::Init::Init()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.text+0x3c): undefined reference to `std::ios_base::Init::~Init()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.xdata$_ZNSt6vectorIiSaIiEED2Ev+0x8): undefined reference to `__gxx_personality_seh0'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.text$__clang_call_terminate[__clang_call_terminate]+0x5): undefined reference to `__cxa_begin_catch'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.text$__clang_call_terminate[__clang_call_terminate]+0xa): undefined reference to `std::terminate()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.xdata$_ZNSt12_Vector_baseIiSaIiEED2Ev+0x8): undefined reference to `__gxx_personality_seh0'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.text$_ZNSt15__new_allocatorIiE10deallocateEPiy[_ZNSt15__new_allocatorIiE10deallocateEPiy]+0x19): undefined reference to `operator delete(void*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@HighCommander4

Interesting, so the command line version is not giving the same errors you’re seeing in the editor.

I wonder if the difference in versions (clangd 15 vs. clang 16) is relevant here. Are you by chance able to test the command-line command with clang 15, or alternatively try using clangd 16 to match your compiler version?

@palapapa

Somehow by completely removing clang from my PATH, it worked correctly again. No errors were reported and the includes were correctly found. Here’s the log:

I[21:41:08.818] clangd version 15.0.3 (https://github.com/llvm/llvm-project 4a2c05b05ed07f1f620e94f6524a8b4b2760a0b1)
I[21:41:08.819] Features: windows+grpc
I[21:41:08.819] PID: 17208
I[21:41:08.819] Working directory: C:\Users\User\AppData\Local\Programs\Microsoft VS Code
I[21:41:08.819] argv[0]: c:\Users\User\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\15.0.3\clangd_15.0.3\bin\clangd.exe
I[21:41:08.819] argv[1]: --log=verbose
V[21:41:08.824] User config file is C:\Users\User\AppData\Local\clangd\config.yaml
I[21:41:08.824] Starting LSP over stdin/stdout
V[21:41:08.917] <<< {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"markdown":{"parser":"marked","version":"1.1.0"},"positionEncodings":["utf-16"],"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"staleRequestSupport":{"cancel":true,"retryOnContentModified":["textDocument/semanticTokens/full","textDocument/semanticTokens/range","textDocument/semanticTokens/full/delta"]}},"notebookDocument":{"synchronization":{"dynamicRegistration":true,"executionSummarySupport":true}},"textDocument":{"callHierarchy":{"dynamicRegistration":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"dynamicRegistration":true,"honorsChangeAnnotations":false,"isPreferredSupport":true,"resolveSupport":{"properties":["edit"]}},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"completion":{"completionItem":{"commitCharactersSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"insertReplaceSupport":true,"insertTextModeSupport":{"valueSet":[1,2]},"labelDetailsSupport":true,"preselectSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode"]},"contextSupport":true,"dynamicRegistration":true,"editsNearCursor":true,"insertTextMode":2},"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"diagnostic":{"dynamicRegistration":true,"relatedDocumentSupport":false},"documentHighlight":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"documentSymbol":{"dynamicRegistration":true,"hierarchicalDocumentSymbolSupport":true,"labelSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"foldingRange":{"dynamicRegistration":true,"foldingRange":{"collapsedText":false},"foldingRangeKind":{"valueSet":["comment","imports","region"]},"lineFoldingOnly":true,"rangeLimit":5000},"formatting":{"dynamicRegistration":true},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"inlayHint":{"dynamicRegistration":true,"resolveSupport":{"properties":["tooltip","textEdits","label.tooltip","label.location","label.command"]}},"inlineValue":{"dynamicRegistration":true},"linkedEditingRange":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"codeDescriptionSupport":true,"dataSupport":true,"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":false},"rangeFormatting":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"honorsChangeAnnotations":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1},"selectionRange":{"dynamicRegistration":true},"semanticTokens":{"augmentsSyntaxTokens":true,"dynamicRegistration":true,"formats":["relative"],"multilineTokenSupport":false,"overlappingTokenSupport":false,"requests":{"full":{"delta":true},"range":true},"serverCancelSupport":true,"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"]},"signatureHelp":{"contextSupport":true,"dynamicRegistration":true,"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true,"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"typeHierarchy":{"dynamicRegistration":true}},"window":{"showDocument":{"support":true},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true},"workspace":{"applyEdit":true,"codeLens":{"refreshSupport":true},"configuration":true,"diagnostics":{"refreshSupport":true},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":true},"executeCommand":{"dynamicRegistration":true},"fileOperations":{"didCreate":true,"didDelete":true,"didRename":true,"dynamicRegistration":true,"willCreate":true,"willDelete":true,"willRename":true},"inlayHint":{"refreshSupport":true},"inlineValue":{"refreshSupport":true},"semanticTokens":{"refreshSupport":true},"symbol":{"dynamicRegistration":true,"resolveSupport":{"properties":["location.range"]},"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"workspaceEdit":{"changeAnnotationSupport":{"groupsOnLabel":true},"documentChanges":true,"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"Visual Studio Code","version":"1.77.3"},"initializationOptions":{"clangdFileStatus":true,"fallbackFlags":["-Weverything","-Wno-used-but-marked-unused","-Wno-declaration-after-statement","-Wno-vla","-Wno-missing-prototypes","-Wno-c++98-compat","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include","-nostdinc","-target","x86_64-pc-windows-gnu"]},"locale":"en","processId":14244,"rootPath":null,"rootUri":null,"trace":"off","workspaceFolders":null}}

I[21:41:08.917] <-- initialize(0)
I[21:41:08.958] --> reply:initialize(0) 40 ms
V[21:41:08.958] >>> {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"clangdInlayHintsProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor","info"]},"compilationDatabase":{"automaticReload":true},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/","*"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"hoverProvider":true,"implementationProvider":true,"inlayHintProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["declaration","deprecated","deduced","readonly","static","abstract","virtual","dependentName","defaultLibrary","usedAsMutableReference","functionScope","classScope","fileScope","globalScope"],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","interface","enum","enumMember","type","type","unknown","namespace","typeParameter","concept","type","macro","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",")","{","}","<",">",","]},"standardTypeHierarchyProvider":true,"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeDefinitionProvider":true,"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"clangd","version":"clangd version 15.0.3 (https://github.com/llvm/llvm-project 4a2c05b05ed07f1f620e94f6524a8b4b2760a0b1) windows+grpc x86_64-pc-windows-msvc"}}}

V[21:41:10.316] <<< {"jsonrpc":"2.0","method":"initialized","params":{}}

I[21:41:10.316] <-- initialized
V[21:41:10.477] <<< {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"#include <iostream>\r\n#include <vector>\r\n#include <stdlib.h>\r\n\r\nint main()\r\n{\r\n    std::vector<int> v;\r\n}\r\n","uri":"file:///d%3A/Download/main.cpp","version":1}}}

I[21:41:10.477] <-- textDocument/didOpen
I[21:41:10.479] Failed to find compilation database for d:\Download\main.cpp
I[21:41:10.479] ASTWorker building file d:\Download\main.cpp version 1 with command clangd fallback
[d:\Download]
"c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\bin\\clang" -Weverything -Wno-used-but-marked-unused -Wno-declaration-after-statement -Wno-vla -Wno-missing-prototypes -Wno-c++98-compat -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32 -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0 -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include -nostdinc -target x86_64-pc-windows-gnu "-resource-dir=c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\lib\\clang\\15.0.3" -- "d:\\Download\\main.cpp"
V[21:41:10.512] <<< {"id":1,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:41:10.512] <-- textDocument/documentSymbol(1)
V[21:41:10.525] Driver produced command: cc1 -cc1 -triple x86_64-pc-windows-gnu -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -mms-bitfields -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb "-fcoverage-compilation-dir=d:\\Download" -nostdsysteminc -nobuiltininc -resource-dir "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\lib\\clang\\15.0.3" -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++\\x86_64-w64-mingw32" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++\\backward" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++\\" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++\\\\x86_64-w64-mingw32" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++\\\\backward" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\include\\c++\\" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\include\\c++\\\\x86_64-w64-mingw32" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\include\\c++\\\\backward" -internal-isystem "include\\c++" -internal-isystem "include\\c++\\x86_64-w64-mingw32" -internal-isystem "include\\c++\\backward" -internal-isystem "include\\g++-v0.0.0" -internal-isystem "include\\g++-v0.0.0\\x86_64-w64-mingw32" -internal-isystem "include\\g++-v0.0.0\\backward" -internal-isystem "include\\g++-v0.0" -internal-isystem "include\\g++-v0.0\\x86_64-w64-mingw32" -internal-isystem "include\\g++-v0.0\\backward" -internal-isystem "include\\g++-v0" -internal-isystem "include\\g++-v0\\x86_64-w64-mingw32" -internal-isystem "include\\g++-v0\\backward" -Weverything -Wno-used-but-marked-unused -Wno-declaration-after-statement -Wno-vla -Wno-missing-prototypes -Wno-c++98-compat -fdeprecated-macro "-fdebug-compilation-dir=d:\\Download" -ferror-limit 19 -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -exception-model=seh -no-round-trip-args -faddrsig -x c++ "d:\\Download\\main.cpp"
I[21:41:10.525] --> textDocument/clangd.fileStatus
V[21:41:10.525] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Update","uri":"file:///d:/Download/main.cpp"}}

V[21:41:10.525] Building first preamble for d:\Download\main.cpp version 1
V[21:41:10.550] <<< {"id":2,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:41:10.550] <-- textDocument/documentLink(2)
V[21:41:10.851] Dropped diagnostic: C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0\iostream: macro name is a reserved identifier
V[21:41:10.867] Dropped diagnostic: C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0\vector: macro name is a reserved identifier
V[21:41:11.044] indexed preamble AST for d:\Download\main.cpp version 1:
  symbol slab: 5132 symbols, 1588064 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 287 relations, 5396 bytes
V[21:41:11.093] Build dynamic index for header symbols with estimated memory usage of 3642040 bytes
V[21:41:11.093] Dropped diagnostic: C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0\stdlib.h: macro name is a reserved identifier
V[21:41:11.100] Built preamble of size 3045280 for file d:\Download\main.cpp version 1 in 0.57 seconds
I[21:41:11.101] --> workspace/semanticTokens/refresh(0)
I[21:41:11.101] --> textDocument/clangd.fileStatus
V[21:41:11.101] >>> {"id":0,"jsonrpc":"2.0","method":"workspace/semanticTokens/refresh","params":null}

V[21:41:11.101] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Build AST","uri":"file:///d:/Download/main.cpp"}}

V[21:41:11.188] indexed file AST for d:\Download\main.cpp version 1:
  symbol slab: 1 symbols, 4456 bytes
  ref slab: 3 symbols, 3 refs, 4304 bytes
  relations slab: 0 relations, 24 bytes
V[21:41:11.188] Build dynamic index for main-file symbols with estimated memory usage of 11648 bytes
I[21:41:11.188] --> textDocument/publishDiagnostics
V[21:41:11.188] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///d:/Download/main.cpp","version":1}}

V[21:41:11.188] ASTWorker running DocumentSymbols on version 1 of d:\Download\main.cpp
I[21:41:11.188] --> reply:textDocument/documentSymbol(1) 676 ms
V[21:41:11.188] >>> {"id":1,"jsonrpc":"2.0","result":[{"detail":"int ()","kind":12,"name":"main","range":{"end":{"character":1,"line":7},"start":{"character":0,"line":4}},"selectionRange":{"end":{"character":8,"line":4},"start":{"character":4,"line":4}}}]}

V[21:41:11.188] ASTWorker running DocumentLinks on version 1 of d:\Download\main.cpp
I[21:41:11.188] --> reply:textDocument/documentLink(2) 638 ms
V[21:41:11.188] >>> {"id":2,"jsonrpc":"2.0","result":[{"range":{"end":{"character":19,"line":0},"start":{"character":9,"line":0}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/iostream"},{"range":{"end":{"character":17,"line":1},"start":{"character":9,"line":1}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/vector"},{"range":{"end":{"character":19,"line":2},"start":{"character":9,"line":2}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/stdlib.h"}]}

I[21:41:11.188] --> textDocument/clangd.fileStatus
V[21:41:11.188] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:41:11.273] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":2}}

I[21:41:11.273] <-- $/cancelRequest
V[21:41:11.371] <<< {"id":3,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:41:11.371] <-- textDocument/documentLink(3)
V[21:41:11.371] ASTWorker running DocumentLinks on version 1 of d:\Download\main.cpp
I[21:41:11.371] --> reply:textDocument/documentLink(3) 0 ms
V[21:41:11.371] >>> {"id":3,"jsonrpc":"2.0","result":[{"range":{"end":{"character":19,"line":0},"start":{"character":9,"line":0}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/iostream"},{"range":{"end":{"character":17,"line":1},"start":{"character":9,"line":1}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/vector"},{"range":{"end":{"character":19,"line":2},"start":{"character":9,"line":2}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/stdlib.h"}]}

I[21:41:11.371] --> textDocument/clangd.fileStatus
V[21:41:11.371] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:41:11.392] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":1}}

I[21:41:11.392] <-- $/cancelRequest
V[21:41:11.437] <<< {"id":4,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:41:11.437] <-- textDocument/documentSymbol(4)
V[21:41:11.437] ASTWorker running DocumentSymbols on version 1 of d:\Download\main.cpp
I[21:41:11.437] --> reply:textDocument/documentSymbol(4) 0 ms
V[21:41:11.437] >>> {"id":4,"jsonrpc":"2.0","result":[{"detail":"int ()","kind":12,"name":"main","range":{"end":{"character":1,"line":7},"start":{"character":0,"line":4}},"selectionRange":{"end":{"character":8,"line":4},"start":{"character":4,"line":4}}}]}

I[21:41:11.437] --> textDocument/clangd.fileStatus
V[21:41:11.437] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:41:11.448] <<< {"id":5,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:41:11.448] <-- textDocument/semanticTokens/full(5)
V[21:41:11.448] ASTWorker running SemanticHighlights on version 1 of d:\Download\main.cpp
I[21:41:11.448] --> reply:textDocument/semanticTokens/full(5) 0 ms
V[21:41:11.448] >>> {"id":5,"jsonrpc":"2.0","result":{"data":[4,4,4,3,8193,2,4,3,15,8448,0,5,6,8,8448,0,12,1,1,1025],"resultId":"1"}}

I[21:41:11.448] --> textDocument/clangd.fileStatus
V[21:41:11.448] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:41:11.463] <<< {"id":0,"jsonrpc":"2.0","result":null}

I[21:41:11.463] <-- reply(0)
V[21:41:11.479] <<< {"id":6,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:41:11.479] <-- textDocument/documentLink(6)
V[21:41:11.479] ASTWorker running DocumentLinks on version 1 of d:\Download\main.cpp
I[21:41:11.479] --> reply:textDocument/documentLink(6) 0 ms
V[21:41:11.479] >>> {"id":6,"jsonrpc":"2.0","result":[{"range":{"end":{"character":19,"line":0},"start":{"character":9,"line":0}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/iostream"},{"range":{"end":{"character":17,"line":1},"start":{"character":9,"line":1}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/vector"},{"range":{"end":{"character":19,"line":2},"start":{"character":9,"line":2}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/stdlib.h"}]}

I[21:41:11.479] --> textDocument/clangd.fileStatus
V[21:41:11.479] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

V[21:41:13.842] <<< {"id":7,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}

I[21:41:13.842] <-- textDocument/semanticTokens/full(7)
V[21:41:13.842] ASTWorker running SemanticHighlights on version 1 of d:\Download\main.cpp
I[21:41:13.842] --> reply:textDocument/semanticTokens/full(7) 0 ms
V[21:41:13.842] >>> {"id":7,"jsonrpc":"2.0","result":{"data":[4,4,4,3,8193,2,4,3,15,8448,0,5,6,8,8448,0,12,1,1,1025],"resultId":"2"}}

I[21:41:13.842] --> textDocument/clangd.fileStatus
V[21:41:13.842] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}

I tried to do that because I remembered I used to not have clang installed and it also worked. Does this mean that clangd doesn’t need clang to function?

@HighCommander4

Does this mean that clangd doesn’t need clang to function?

Correct, clangd does not invoke a clang executable.

It does use clang’s libraries and some built-in headers, but those are usually included in the clangd package (or in some package manager setups, clang and clangd may share the libraries as a common dependency).

As for why the presence of clang impacts clangd in this way, I’m not sure, sorry. I’m not a Windows user so my ability to provide help with Windows issues is somewhat limited. I think clangd would benefit from someone who does use Windows who would be willing to take the time to dive more deeply into these sorts of issues.

@palapapa

I thought deleting clang worked but it actually didn’t. This issue appeared again without me changing any configs.
It seems that by setting the --target to x86_64-w64-windows-gnu, clangd will automatically detect the MinGW headers and work correctly.

I’m trying to compile OpenCV. I’ve tried the master branch (which is currently on commit dc9602e) and version/tag 3.1.0. I’m using Fedora 24, I first tried using gcc that comes with Fedora (gcc (GCC) 6.2.1 20160916 (Red Hat 6.2.1-2)). I have also tried with GCC 6.2.0, compiled on my machine.

I’m using cmake with the following parameters:

cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_NEW_PYTHON_SUPPORT=ON -DINSTALL_PYTHON_EXAMPLES=ON -DWITH_TBB=ON -DWITH_V4L=ON -DINSTALL_C_EXAMPLES=ON -DBUILD_EXAMPLES=ON -DWITH_QT=ON -DWITH_OPENGL=ON -DWITH_OPENCL=ON -DWITH_EIGEN=ON -DWITH_OPENEXR=ON

cmake runs fine and then I run make. Doesn’t matter the commbination of OpenCV version and gcc version, the result is the same:

In file included from /usr/local/include/c++/6.2.0/bits/stl_algo.h:59:0,
                 from /usr/local/include/c++/6.2.0/algorithm:62,
                 from /home/dmelo/proj2/opencv/modules/core/include/opencv2/core/base.hpp:55,
                 from /home/dmelo/proj2/opencv/modules/core/include/opencv2/core.hpp:54,
                 from /home/dmelo/proj2/opencv/modules/highgui/include/opencv2/highgui.hpp:46,
                 from /home/dmelo/proj2/opencv/build/modules/highgui/precomp.hpp:45:
/usr/local/include/c++/6.2.0/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
                         ^
compilation terminated.

Is anyone else experiencing this? How can I solve this problem?

asked Oct 26, 2016 at 12:56

Diogo Melo's user avatar

3

Try by disabling pre-compiled headers, either from cmake-gui or using the command line parameter

-DENABLE_PRECOMPILED_HEADERS=OFF

answered Oct 26, 2016 at 20:19

Antonio's user avatar

AntonioAntonio

19.5k13 gold badges99 silver badges197 bronze badges

2

Compiling from zip package (opencv-2.4.11) did not work for me but
the latest version* from github repo gave me a successful build on ubuntu 17.04

git clone https://github.com/opencv/opencv.git
cd opencv
mkdir mybin
cd mybin
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_FFMPEG=OFF ..
make
sudo make install

Update: You might want to do git checkout 3.4 after git clone because the master branch has many new changes since I wrote this

Note: ffmpeg is deprecated and optional so I have used WITH_FFMPEG=OFF flag
Update: I could build with ffmpeg on 18.04, used WITH_FFMPEG=ON flag. Latest ffmpeg should work with 17.04 as well. Comment down if you were successful!

*OpenCV commit id cca99bf8249387da9f79be8d549b2d49e39a0289

Additional info:
Dependencies I installed before compiling-

build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev libtbb2 libtbb-dev

Hope this helps someone in future!

answered Oct 22, 2017 at 15:07

sziraqui's user avatar

sziraquisziraqui

5,7733 gold badges28 silver badges37 bronze badges

I am on Manjaro Linux and this problem do exists on my system because of TBBConfig.cmake file which is a part of Intel-TBB library and contains modification to path of include folder path at line 56:

set_target_properties(TBB::${_tbb_component} PROPERTIES
                                  INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/../../../include")

While -DENABLE_PRECOMPILED_HEADERS=OFF was already off in my case and didn’t fix the issue, it seems that this flag -DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON fixes it.

answered Nov 14, 2019 at 7:20

Ossama Nasser's user avatar

For archlinux distro like Manjaro the flags -D ENABLE_PRECOMPILED_HEADERS=OFF and -D CMAKE_NO_SYSTEM_FROM_IMPORTED=ON fixed it with success.

I also got problems with blas and cblas during compilation.
I linked cblas by adding CMAKE_EXE_LINKER_FLAGS=-lcblas.

answered Dec 3, 2019 at 12:30

Valentin Nasraty's user avatar

For me this:

[ 33%] Building CXX object 
/home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++    @CMakeFiles/Transform360.dir/includes_CXX.rsp -std=c++11  -O3 -DNDEBUG   -o CMakeFiles/Transform360.dir/Library/VideoFrameTransform.cpp.obj -c /home/rdp/ffmpeg-windows-build-helpers/sandbox/win64/transform360_git/Transform360/Library/VideoFrameTransform.cppCMakeFiles/Transform360.dir/Library/VideoFrameTransform.cpp.obj
In file included from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/ext/string_conversions.h:41,
                 from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/bits/basic_string.h:6391,
                 from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/string:52,
                 from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/stdexcept:39,
                 from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/array:39,
                 from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/tuple:39,
                 from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/bits/stl_map.h:63,
                 from /home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/map:61,
                 from /home/rdp/ffmpeg-windows-build-helpers/sandbox/win64/transform360_git/Transform360/Library/VideoFrameTransform.h:18,
                 from /home/rdp/ffmpeg-windows-build-helpers/sandbox/win64/transform360_git/Transform360/Library/VideoFrameTransform.cpp:14:
/home/rdp/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/include/c++/8.2.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.

meant «edit CMakeFiles/Transform360.dir/includes_CXX.rsp and replace -isystem with -I» hint from here

answered Jan 16, 2019 at 2:19

rogerdpack's user avatar

rogerdpackrogerdpack

63k36 gold badges269 silver badges389 bronze badges

1

Ошибка fatal error: stdlib.h: No such file or directory¶

Такая ошибка может возникнуть при компиляции программ на C++ в Linux.
В моем случае это была библиотека на Qt.

Ошибка компиляции Qt модуля

$ g++ -c -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_BLUETOOTH_LIB -DQT_CORE_LIB -I. -isystem /usr/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtBluetooth -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o main.o src/main.cpp
In file included from /usr/include/c++/7/bits/stl_algo.h:59:0,
                 from /usr/include/c++/7/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:109,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/qcoreapplication.h:43,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/QCoreApplication:1,
                 from src/main.cpp:6:
/usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.
Makefile:497: recipe for target 'main.o' failed
make: *** [main.o] Error 1

Возникает только в последних версиях gcc, видимо заголовки как то не
правильно собраны в дистрибутиве Ubuntu 18.04. Поэтому для решения установим
по умолчанию компилятор gcc 5-ой версии.

Установка:

$ sudo apt install gcc-5 g++-5

Добавим его в список:

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50 --slave /usr/bin/g++ g++ /usr/bin/g++-5

И поменяем значение дефолтного компилятора:

$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-8   80        auto mode
* 1            /usr/bin/gcc-5   50        manual mode
  2            /usr/bin/gcc-8   80        manual mode

Press <enter> to keep the current choice[*], or type selection number: 1

Теперь в системе используется по умолчанию gcc 5-ой версии и все собирается без ошибок.

Issue

I am using various stdlib functions like srand(), etc. I have the line

#include <stdlib.h>

at the top of my code.

I entered this on the command line:

# find / -name stdlib.h

find: `/home/dmurvihill/.gvfs: permission denied
/usr/include/stdlib.h
/usr/include/bits/stdlib.h

So, stdlib.h is clearly in /usr/include.

My preprocessor:

# gcc -print-prog-name=cc1

/usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1

My preprocessor’s default search path:

# /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1 -v

ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include
/usr/include
End of search list.

So, stdlib.h is clearly in /usr/include, which is most definitely supposed to be searched by my preprocessor, but I still get this error!

/path/to/cpa_sample_code_main.c:15:20: fatal error: stdlib.h: No such file or directory
compilation terminated

Update

A program I wrote to test this code:

#include <stdio.h>
#include <stdlib.h>
#include <linux/time.h>

int main()
{
    printf("Hello, World!\n");
    printf("Getting time...\n");
    time_t seconds;
    time(&seconds);
    printf("Seeding generator...\n");
    srand((unsigned int)seconds);
    printf("Getting random number...\n");
    int value = rand();
    printf("It is %d!",value);
    printf("Goodbye, cruel world!");
    return 0;
}

The command

gcc -H -v -fsyntax-only stdlib_test.c

output

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.5.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC) 
COLLECT_GCC_OPTIONS='-H' '-v' '-fsyntax-only' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1 -quiet -v -H /CRF_Verify/stdlib_test.c -quiet -dumpbase stdlib_test.c -mtune=generic -march=x86-64 -auxbase stdlib_test -version -fsyntax-only -o /dev/null
GNU C (GCC) version 4.5.1 20100924 (Red Hat 4.5.1-4) (x86_64-redhat-linux)
    compiled by GNU C version 4.5.1 20100924 (Red Hat 4.5.1-4), GMP version 4.3.1, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include
 /usr/include
End of search list.
GNU C (GCC) version 4.5.1 20100924 (Red Hat 4.5.1-4) (x86_64-redhat-linux)
    compiled by GNU C version 4.5.1 20100924 (Red Hat 4.5.1-4), GMP version 4.3.1, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: ea394b69293dd698607206e8e43d607e
. /usr/include/stdio.h
.. /usr/include/features.h
... /usr/include/sys/cdefs.h
.... /usr/include/bits/wordsize.h
... /usr/include/gnu/stubs.h
.... /usr/include/bits/wordsize.h
.... /usr/include/gnu/stubs-64.h
.. /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stddef.h
.. /usr/include/bits/types.h
... /usr/include/bits/wordsize.h
... /usr/include/bits/typesizes.h
.. /usr/include/libio.h
... /usr/include/_G_config.h
.... /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stddef.h
.... /usr/include/wchar.h
... /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stdarg.h
.. /usr/include/bits/stdio_lim.h
.. /usr/include/bits/sys_errlist.h
. /usr/include/stdlib.h
.. /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stddef.h
.. /usr/include/bits/waitflags.h
.. /usr/include/bits/waitstatus.h
... /usr/include/endian.h
.... /usr/include/bits/endian.h
.... /usr/include/bits/byteswap.h
..... /usr/include/bits/wordsize.h
.. /usr/include/sys/types.h
... /usr/include/time.h
... /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stddef.h
... /usr/include/sys/select.h
.... /usr/include/bits/select.h
..... /usr/include/bits/wordsize.h
.... /usr/include/bits/sigset.h
.... /usr/include/time.h
.... /usr/include/bits/time.h
... /usr/include/sys/sysmacros.h
... /usr/include/bits/pthreadtypes.h
.... /usr/include/bits/wordsize.h
.. /usr/include/alloca.h
... /usr/lib/gcc/x86_64-redhat-linux/4.5.1/include/stddef.h
. /usr/include/linux/time.h
.. /usr/include/linux/types.h
... /usr/include/asm/types.h
.... /usr/include/asm-generic/types.h
..... /usr/include/asm-generic/int-ll64.h
...... /usr/include/asm/bitsperlong.h
....... /usr/include/asm-generic/bitsperlong.h
... /usr/include/linux/posix_types.h
.... /usr/include/linux/stddef.h
.... /usr/include/asm/posix_types.h
..... /usr/include/asm/posix_types_64.h
In file included from /CRF_Verify/stdlib_test.c:3:0:
/usr/include/linux/time.h:9:8: error: redefinition of ‘struct timespec’
/usr/include/time.h:120:8: note: originally defined here
/usr/include/linux/time.h:15:8: error: redefinition of ‘struct timeval’
/usr/include/bits/time.h:75:8: note: originally defined here
Multiple include guards may be useful for:
/usr/include/asm/posix_types.h
/usr/include/bits/byteswap.h
/usr/include/bits/endian.h
/usr/include/bits/select.h
/usr/include/bits/sigset.h
/usr/include/bits/stdio_lim.h
/usr/include/bits/sys_errlist.h
/usr/include/bits/time.h
/usr/include/bits/typesizes.h
/usr/include/bits/waitflags.h
/usr/include/bits/waitstatus.h
/usr/include/gnu/stubs-64.h
/usr/include/gnu/stubs.h
/usr/include/wchar.h

Solution

Your error appears to stem from including linux/time.h when also trying to include stdlib.h. linux/time.h is a kernel header and should only be used in kernel code. stdlib.h is a user-land function and should only be used in user programs. If you notice the error you get:

/usr/include/linux/time.h:12: error: redefinition of 'struct timespec'
/usr/include/linux/time.h:18: error: redefinition of 'struct timeval'

you can see that you are getting an error related to this. As seen in your long trace, this is because stdlib.h is including time.h (the one in /usr/include, not /usr/include/linux). I imagine that this is the real cause of the error you see about not finding stdlib.h (although I cannot imagine the details of how the errors are occurring the way they are).

Answered By — Dave

Понравилась статья? Поделить с друзьями:
  • Status invalid image hash chrome ошибка
  • Startdocprinter ошибка как исправить
  • Steam api dll скачать 64 bit ошибка
  • Startactivity intent ошибка
  • Stay out ошибка соединения 26 вход временно закрыт