vscode+Arduino environment: vscode is not able to load system headers despite the configuration of paths - visual-studio-code

I'm really getting frustrated with this issue.
I have installed vscode(version: 1.69.2) & Arduino IDE(version 1.8.20) on my MacOS(version 12.5), I installed the Arduino extension in the vscode, and tried to get it work.
It just works fine if I don't include the system libraries, however if I tried to include a header file, example, the 'iostream', the complier prompts me as below:
Alternatives for iostream: []
ResolveLibrary(iostream)
-> candidates: []
main:1:10: fatal error: iostream: No such file or directory
#include <iostream>
^~~~~~~~~~
compilation terminated.
exit status 1
It looks like the VScode IntelliSense could find this file, if I click this file with Command key pressed, it will show me the location of it.
iostream can be found by vscode IntelliSense
I'm assuming that IntelliSense works with the paths I set, but the compiler just cannot, I tried editing the json file several hours last night but still no luck.
Anyone has any idea about this? Your help is greatly appreciated!
Here's part of my c_cpp_properties.json file:
{
"version": 4,
"configurations": [
{
"name": "Arduino",
"compilerPath": "/Users/steveyang/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++",
"compilerArgs": [
"-w",
"-std=gnu++11",
"-fpermissive",
"-fno-exceptions",
"-ffunction-sections",
"-fdata-sections",
"-fno-threadsafe-statics",
"-Wno-error=narrowing"
],
"intelliSenseMode": "gcc-x64",
"includePath": [
"${workspaceFolder}",
"/Users/steveyang/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino",
"/Users/steveyang/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard",
"/Users/steveyang/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include",
"/Users/steveyang/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include-fixed",
"/Users/steveyang/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/avr/include"
],
"forcedInclude": [
"/Users/steveyang/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino/Arduino.h"
],
"cStandard": "c11",
"cppStandard": "c++11",
"defines": [....
],
"browse": {
"path":[
"${workspaceFolder}/",
"/usr/local/include",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.1.6/include",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include",
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"
]
}
}
]
}

Related

C programming on PI using VS-Code. Get "undefined reference to '...' " when using the quote form of the include directive

I would like to program a PI via VS-Code. When I translate the program I get "undefined referenc to `...' ". It seems that the header files that I include via #include "..." are not translated. If I translate the data in the terminal and then link the headers afterwards, it works. If I have understood correctly, you can set this via the tasks.json. However, I have not yet found out how.
I would like to modify an existing C program that has already been programmed on a PI. The programming is to be done in VS-Code via SSH. However, as soon as I try to run the program, I get numerous error messages with "undefined reference to '...' ".
Even with the minimal program helloworld I get this notification as soon as I want to include local .h-files with #include "...". System files with #include <..> are found.
The following programme
#include <stdio.h>
int main()
{
printf("Hello World\n");
}
is translated without problems.
However, as soon as I add Messages.h
#ifndef MESSAGES_H_INCLUDED
#define MESSAGES_H_INCLUDED
void printMsg(char *str);
#endif // MESSAGES_H_INCLUDED
and Messages.c
#include "Messages.h"
void printMsg(char *str)
{
printf("Testausgabe: %s\n",str);
}
to the project and to the program
#include <stdio.h>
#include "Messages.h"
int main()
{
printf("Hello World\n");
printMsg("Somthing else.\n");
}
The compiler returns
/usr/bin/ld: /tmp/ccBVuwoo.o: in function `main':
helloworld.c:(.text+0x14): undefined reference to `printMsg'
collect2: error: ld returned 1 exit status
And this although all files are stored in the same folder.
If I create the files manually using the terminal and then link them, it works.
$ gcc -c helloworld.c
$ gcc -c Messages.h
$ gcc -o Hello helloworld.o Messages.o
Does this mean that I have to manually create a make file that I have to expand for each new header (that would be a bummer)? Couldn't this also be done automatically via VS-Code? Have I perhaps overlooked something here? Sorry, but I am very new to this.
I am grateful for any help.
Attached is also the automatically generated tasks.json from VSC.
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc Aktive Datei kompilieren",
"command": "/usr/bin/gcc",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Vom Debugger generierte Aufgabe."
}
],
"version": "2.0.0"
}

VScode wont detect the Arduino library

I am currently trying to control a servo from an Arduino for a laser turret through vscode. the problem is that vscode does not pick up on my library folder called <servo.h>. I have a folder named "workspace" with the servo library, the .ino file, and the workspace file for vscode.
Instead of platformIO, I'm using the Arduino extension for vscode. I'm using an Arduino UNO. here is the code so far:
#include <Servo.h>
Servo servo1;
Servo servo2;
int potval
int potpin = 0
void setup()
and here is what my c_cpp_properties.json file looks like:
{
"configurations": [{
"name": "Win32",
"includePath": [
"${workspaceFolder}
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}],
"version": 4
}
And I'm running Windows 10
Any local library file that is included must use "" instead of <>.
#include <Servo.h>
should be replaced with
#include "Servo.h"
Here is a post describing the difference between the two:
What is the difference between #include < filename > and #include “filename”?

vscode remote container extension launching got stuck at "installing extensions"

When I am using this remote container extension for launching a container, sometime it will stuck at "installing extensions".
It will stuck at this state as follow for a long time and no response.
Sometime it works fine and fast, sometime does not.
I have commented all the extensions in devcontainer.json file but it still happens sometime.
I dont know whether it a network issue or something else. And I want to know how can I make it stable?
Thanks!
This is my devcontainer.json.
{
"name": "gazebo_ros_docker",
"dockerFile": "Dockerfile",
"extensions": [
// "ms-iot.vscode-ros",
// "ms-vscode.cpptools",
// "mhutchie.git-graph"
],
"runArgs": [
"-it",
"--rm",
"--privileged",
"-e ROS_HOSTNAME=localhost",
"-e ROS_MASTER_URI=http://localhost:11311",
"--name=ros_container",
],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
// "postCreateCommand": "bash /catkin_ws/src/panda_simulation/scripts/docker-setup.sh",
"workspaceMount": "source=${localWorkspaceFolder},target=/catkin_ws,type=bind",
// "workspaceMount": "source=${localWorkspaceFolder},target=/catkin_ws,type=bind,consistency=delegated",
"workspaceFolder": "/catkin_ws",
"mounts": [
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind",
],
"containerEnv": {
"DISPLAY": "${localEnv:DISPLAY}",
},
"containerUser": "docker_ros"
}
I did not find the best way to solve this problem. But I export the images of the vscode-processed container and launch it. It is working well now.

TYPO3 CMS 8.7.27: Call to a member function getPackagePath() on null

After installing extensions in typo3 CMS 8.7.27, I got following error.. Seems like the ExtensionManagementUtility can't load the ah_contentapi.
This is my composer.json file in root (/var/www/html/typo3) for loading my extensions:
{
"repositories":[
{
"type":"composer",
"url":"https://composer.typo3.org/"
},
{
"type":"package",
"package":{
"name":"Bm/ah-content-api",
"version":"0.0.1",
"type":"typo3-cms-extension",
"source":{
"url":"https://user#bitbucket.org/company/ah_config_typo3.git",
"type":"git",
"reference":"master"
}
}
},
{
"type":"package",
"package":{
"name":"Bm/ah-contentelements",
"version":"0.0.1",
"type":"typo3-cms-extension",
"source":{
"url":"https://user#bitbucket.org/company/ah_contentelements_typo3.git",
"type":"git",
"reference":"master"
}
}
}
],
"name":"typo3/cms-base-distribution",
"description":"TYPO3 CMS Base Distribution",
"license":"GPL-2.0-or-later",
"require":{
"helhum/typo3-console":"^4.9.3 || ^5.2",
"typo3/cms-about":"^8.7.10",
"typo3/cms-belog":"^8.7.10",
"typo3/cms-beuser":"^8.7.10",
"typo3/cms-context-help":"^8.7.10",
"typo3/cms-documentation":"^8.7.10",
"typo3/cms-felogin":"^8.7.10",
"typo3/cms-fluid-styled-content":"^8.7.10",
"typo3/cms-form":"^8.7.10",
"typo3/cms-func":"^8.7.10",
"typo3/cms-impexp":"^8.7.10",
"typo3/cms-info":"^8.7.10",
"typo3/cms-info-pagetsconfig":"^8.7.10",
"typo3/cms-rte-ckeditor":"^8.7.10",
"typo3/cms-setup":"^8.7.10",
"typo3/cms-sys-note":"^8.7.10",
"typo3/cms-t3editor":"^8.7.10",
"typo3/cms-tstemplate":"^8.7.10",
"typo3/cms-viewpage":"^8.7.10",
"typo3/cms-wizard-crpages":"^8.7.10",
"typo3/cms-wizard-sortpages":"^8.7.10",
"typo3/cms":"^8.7",
"dmitryd/typo3-realurl":"2.*",
"GridElementsTeam/Gridelements":"8.2.*",
"clickstorm/cs_seo":"3.*",
"Bm/ah-content-api":"0.0.1",
"Bm/ah-contentelements":"0.0.1"
},
"scripts":{
"typo3-cms-scripts":[
"typo3cms install:fixfolderstructure",
"typo3cms install:generatepackagestates"
],
"post-autoload-dump":[
"#typo3-cms-scripts"
]
},
"extra":{
"typo3/cms":{
"web-dir":"public"
},
"helhum/typo3-console":{
"comment":"This option is not needed ay more for helhum/typo3-console 5.x",
"install-extension-dummy":false
}
},
"autoload":{
"psr-4":{
"Bm\\AhContentelements\\":"public/typo3conf/ext/ah_contentelements/Classes",
"Bm\\AhContentapi\\":"public/typo3conf/ext/ah_content_api/Classes"
}
}
}
I already cleared cache in install tool at:
1. -> important actions -> clear all cache
2. -> clean up -> Clean typo3temp/ folder
piece from composer.lock:
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is #generated automatically"
],
"content-hash": "954afd2318d54ec9b1dd0e4d7f9b445b",
"packages": [
{
"name": "Bm/ah-content-api",
"version": "0.0.1",
"source": {
"type": "git",
"url": "https://stevenhippovibe#bitbucket.org/hippovibe/ah_config_typo3.git",
"reference": "master"
},
"type": "typo3-cms-extension"
},
{
"name": "Bm/ah-contentelements",
"version": "0.0.1",
"source": {
"type": "git",
"url": "https://stevenhippovibe#bitbucket.org/stevenhippovibe/ah_contentelements_typo3.git",
"reference": "master"
},
"type": "typo3-cms-extension"
},
The Error occurs when the extension folder name under typo3conf/ext/<folder_name> doesn't match extension key used in some places of the system (e.g. using EXT:your_extension_key/... syntax in TypoScript).
Changing folder name fixed similar problem for me.
Check the PHP version and try to change it from i.e. 7.4 to 7.3.
I once had this problem with an extension that should be compatible with PHP 7.4, but wasn't in real life. This solved the problem for me.
Question here is:
How did you update to 8.7.27 (which composer command was executed)
How does your composer.lock look like?
Do you use TYPO3 console or any other special composer plugins / CLI commands to e.g. generate PackageStates.php?
I just ran into the same error message under TYPO3 9.5.5.
Solution:
Deinstall one TYPO3 extension after the other and try it out again. This will lead you to the extension which has an error. Most probably the error is inside of the file ext_localconf.php or ext_tables.php .
I got this error detail:
PHP Warning: Use of undefined constant FH_DEBUG_EXT - assumed 'FH_DEBUG_EXT' (this will throw an Error in a future version of PHP) in /var/www/html/global-extensions/ext/div2007/ext_localconf.php line 15
This has nothing to do with your error. But it can be that you have an error in one of your installed extensions or even in a backup of an extension, e.g. a folder named as extensionname.bak .
Also these recommendations can help:
https://wiki.typo3.org/Exception/CMS/1476107295

Error running CoffeeScript in Sublime Text 2

I am new to both CoffeeScript and Sublime Text 2, so any help would be greatly appreciated.
When I try to compile a CoffeeScript test file in Sublime, I get the following error message:
[Error 2] The system cannot find the file specified
[cmd: [u'coffee', u'-c', u'C:\\Users\\username\\Desktop\\test.coffee']]
[dir: C:\Users\username\Desktop]
[path: $HOME/bin:/usr/local/bin:$HOME/bin:/usr/local/bin:C:\Program Files (x86)\ImageMagick-6.9.1-Q16;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.8.0_25\bin;C:\Java\bin;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\nodejs\;C:\Program Files (x86)\GnuWin32\bin;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;C:\Program Files (x86)\Skype\Phone\;C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby2.1.0\bin;C:\Users\username\AppData\Roaming\npm]
[Finished]
Here are my build settings in commands:
{
"path": "$HOME/bin:/usr/local/bin:$PATH",
"cmd": ["coffee","-c","$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.coffee, source.litcoffee, source.coffee.md"
}
Any idea how to fix this problem? Thanks.
I managed to get it working with the following code in the build file:
{
"cmd": [ "coffee", "-m", "-c", "$file" ],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.coffee, source.litcoffee, source.coffee.md",
"windows":
{
"shell": true
}
}