Hello I’m new here. I’m using VSCode with PlatformIO. Now my Problem: Every Time I create a new project and try it to run, it don’t work. Even if I use an .cpp file without any code
e.g.
main.cpp:
ERROR: C:\Users\JENSWI~1\AppData\Local\Temp\ccwbSejc.ltrans0.ltrans.o: In function main':*** ***<artificial>:(.text.startup+0x128): undefined reference tosetup’ :(.text.startup+0x130): undefined reference to `loop’ collect2.exe: error: ld returned 1 exit status
****** [.pio\build\micro\firmware.elf] Error 1***
Does anyone knows how to solve it and can help me?
Can you execute a clean and a verbose complation in the task explorer and paste it to pastebin? Especially the first compilation command is important (where it builds src\main.cpp).
Ok. Another piece of advice I can offer is that your Windows username contains spaces, which has caused some problems in PlatformIO (but shouldn’t now anymore…). Maybe renaming your user will magically make it succeed in VSCode (although it already does on the CLI…)
Oh it only fails if I run it as test. If i run it in clean, there is no error. But if i hit test and run it after the test the error occure. Then i have to run it first with “pio run -t clean” and the error is gone 'till i use test again
Okay, that it fails when using “Test” is the entire gist of it, wasn’t quiet reflected in the sentence Every Time I create a new project and try it to run, it don’t work. . When you hit “Test” it means you want to compile the unit tests which are under test/, while ignoring src/. If test/ is an empty folder you’ll get that error for sure.
… that both the test AND the normal build/run fail, I can’t reproduce that behaviour. Only the test build fails for me. The errors you were getting about undefined references is normal, as Test is for unit testing, and uses/looks for code in the test directory, not the src directory - resulting in those functions not being used - but being declared as existing.