I am currently running tests on TorizonCore and its VSCode extension.
I am trying some basic C/C++ code which tests the hardware interfaces like UART, I2C etc.
My problem happens when I try to include the thread-library.
#include <thread> Results in a “No such file or directory” error message.
How do I include the thread library on the extension?
Is it correct to just add the /usr/include/** path to the c_cpp_properties.json for IntelliSense purposes?
How do I include the library in the gcc build? just edit the build options in task.json?
Or do I have to add the library as devpackages or extrapackages?
I did a quick test on my end. I created a single file C++ project in VSCode and added #include <thread> to the default hello-world app that gets generated. With no other changes to the default project configuration I was able to build the application with no errors.
It seems like I can’t reproduce this on my side then. I’ll need some additional information to figure out what could be wrong.
If you do the simple test I did above, do you still get the same error?
Did you make any configurations/changes to the project after it was generated?
What version of VSCode and our extension are you using?
No changes were made on any config file.
I merely added the include for thread to the hello-world project. It still has the same problems.
thread: No such file or directory.
I am currently running my tests on an Ubuntu 20.4 VirtualBox VM.
In that case, if you are creating a Makefile-based project the default template produces a C-based code and Makefile.You need to do slight modifications to the default produced code and Makefile. For example changing the CC environment variables to CXX in the Makefile and such changes.
Once you’ve done these simple changes you shouldn’t be getting the “No such file or directory” error message anymore.
I assume you’re intending to work with C++ rather than C since <thread> is a C++ library.
i think i have the same problem. changing the CC environment variables to CXX in the Makefile dosnt help. I have the same problem if i use Cmake or a Makefile Project. What am i doing wrong? or it is only a Problem with IntelliSense?
Thanks! but why i get the warning “aarch64-linux-gnu-gcc” not found ? Have I forgotten or done something wrong during installation or when setting up the program?
Can you check if your VS Code is actually running the Remote Container? You can check it taking a look at its bottom-left corner.
Not using Remote Container:
Using Remote Container:
If it is not using Remote Container, just click on the “> <” orange button and select “Reopen in Container”
Issue with Remote Container
If you are facing issues related to the Remote Container, rebuilding it might help you: press F1 and look for “Remote-Containers: Rebuild and Reopen in Container”
I’m on Ubuntu 20.04… You said you are using Ubuntu 20.04 on a VM so it should be the same for us. Is it possible that you have something outdated? Here is are my version for comparison (Help > About). You can see that I installed VS Code using snap.
And I have the latest stable release of VS Code (according to snap):
snap info code
$ snap info code
name: code
summary: Code editing. Redefined.
publisher: Visual Studio Code (vscode✓)
store-url: https://snapcraft.io/code
contact: https://twitter.com/code
license: unset
description: |
Visual Studio Code is a new choice of tool that combines the
simplicity of a code editor with what developers need for the core
edit-build-debug cycle.
commands:
- code
- code.url-handler
snap-id: Ht0aUHi7ofh9Fbwh6m7jUN2pAy6kzBiu
tracking: latest/stable
refresh-date: 33 days ago, at 21:48 -03
channels:
latest/stable: 899d46d8 2021-12-16 (85) 228MB classic
latest/candidate: ↑
latest/beta: ↑
latest/edge: ↑
installed: 899d46d8 (85) 228MB classic
Also, it seems like you actually are using the Remote Container. But, please perform this simple test:
Create a terminal on your VS Code and ask for the content of the CROSS_TOOLCHAIN environment variable.
Outside of the Remote Container you should see it empty (if you see some value for this variable, it is possible that you defined it somewhere for your shell):
A side comment: to show the content of an environment variable on terminal, you need to:
echo $PATH
And, in the end, are you actually able to build something?
@kevin.tx helped me with some tests (he has the same setup as you) and even though he is also getting the same warning regarding the toolchain not being found, Kevin is able to build a hello world.
So, if you can build, there is no actual issue, but I will inform the Development Team about this warning.