microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.46k stars 451 forks source link

cannot open source file "cblas.h" #1543

Open konradglas opened 3 years ago

konradglas commented 3 years ago

I get an intellisense include error that is reproducible by a minimal project that I can share. The Accelerate framework is somehow not included properly.

konradglas commented 3 years ago

Probably worth a different issue, but I have also discovered an include issue when precompiled headers are involved. I added this to the minimal project

bobbrow commented 3 years ago

Thank you for reporting this and also for creating a simple project that we can work with!

@andreeis just FYI, this is on macOS. I was surprised to not see any code in cpptools.ts that handled Mac frameworks. Perhaps it's just passing flags over to cpptools and expecting it to pick it up, but I don't have a mac to test it out on right now.

konradglas commented 3 years ago

fyi: I just realised I forgot to add the precompiled header command in the minimal example's CMakeLists.txt ... added now

andreeis commented 3 years ago

We have this bug about not passing the iframework switch on Mac. https://github.com/microsoft/vscode-cmake-tools/issues/1178. I'll investigate both.

MiroFurtado commented 2 years ago

Can confirm that this is still an issue.

konradglas commented 1 year ago

Is there an update on this? As a workaround I am using clangd for my Windows and MacOS projects. A solution that works out of the box for both platforms would be very nice though...

leafac commented 1 year ago

@konradglas Thank you very much for your suggestion of clangd. I didn’t know about it and it fixed the error for me 😁

aymarino commented 1 year ago

I recently hit this issue in another form, but suspect it's a similar underlying cause.

@andreeis I do not think the Framework path issue (#1178) is related here. The recommended fix in that issue is to direct CppTools to use compile_commands.json (@bobbrow finds that there's an issue with the framework path args provided by the CMake configuration provider in #2324). However, in the very nice minimal repro provided by @konradglas, the missing header Intellisense error still exists when the CppTools extension uses compile_commands.json.

Given that, I suspect there's some issue with the CppTools extension's handling of macOS frameworks (though would love if someone could confirm or find if it's a known issue), which would also explain why clangd is a viable workaround for this.

lucianthorr commented 1 year ago

I'm running into this error as well and from my understanding, it's specific to the cmake extension. Before adding the extension, I was able to get around the issue by setting "C_Cpp.errorSquiggles": "enabled" in the settings.json. With the extension, the intellisense now is unable to resolve certain frameworks, specifically Accelerate on macOS with the same error as the original poster, "cannot open source file "cblas.h"" Maybe because cblas.h is contained in an internal framework VecLib inside Accelerate?