[Solved] project1.lpr Error: unit not found: RP2040 lazarus / 79-Embedded - ARM ---------------------------------------------------------------------- BlueIcaro · 2022-10-02 17:12 Hi, I installed Lazarus using fpcupdeluxe version V2.2.0j. to play with raspberry pi Pico. If I open a example it works nice. I exported the projects options to have all options ready to start my own project. So I create a simple program. Like this: Code: [Select]program Prject1; {$MODE OBJFPC} {$H+} {$MEMORY 10000,10000} uses   pico_gpio_c; begin end.            But when I write gp and push ctrl+space to get a list of instruccions, I got the error: Quoteproject1.lpr Error: unit not found: RP2040This issue doesn't happen If I open a example. I think I miss some thing. Any Idea Thanks /BlueIcaro ---------------------------------------------------------------------- zeljko · 2022-10-02 17:18 Your program is named Prject1 instead of Project1. ---------------------------------------------------------------------- MiR · 2022-10-02 17:23 Please have a look at the provided project files, You are missing some path settings that you need to have to make the project find all source files. ---------------------------------------------------------------------- Thaddy · 2022-10-02 18:22 Quote from: zeljko on October 02, 2022, 07:18:31 pmYour program is named Prject1 instead of Project1. That does not matter since the program name is always silently ignored. That is not the case with unit names, these must be exactly the same in the source w/o extension as the file on disk (with extension). See the reference guide 16.1 and 16.2:  https://www.freepascal.org/docs- html/current/ref/refse111.html#x232-25600016.1 and:  https://www.freepascal.org/docs- html/current/ref/refse112.html#x233-25700016.2 It is more likely that you are not using a recent trunk/main version of FreePascal. the RP2040 cpu is still rather recent and needs a recent cross- compiler. (i.e. 3.3.1) (It need not be in the uses clause, the compiler determines it on compiling your cross-compiler.) ---------------------------------------------------------------------- Arioch · 2022-10-02 18:58 No, it is not just ignored, not always https://gitlab.com/freepascal.org/fpc/documentation/-/issues/39324 {$R *.ext}  works the same in programs and units, and probable {$I *.ext} as well Not sure, but AFAIR in Delphi such a wrong name could lead to weird linking errors later, hard to diagnose ---------------------------------------------------------------------- KodeZwerg · 2022-10-02 19:39 Quote from: Arioch on October 02, 2022, 08:58:28 pmNot sure, but AFAIR in Delphi such a wrong name could lead to weird linking errors later, hard to diagnose In Delphi it would not compile at all since unit names on disk and in source must match. It would than try search for old compiled version of that file and ignore current i guess. ---------------------------------------------------------------------- BlueIcaro · 2022-10-02 20:35 Hi, I think the name is not the problem. I don't understand what happens. If I export the configuration of compiler, used in a example. Then I import, and add the path to the units folders, that is needed for compiling. I attach the project, may you can see what happen. /BlueIcaro ---------------------------------------------------------------------- BlueIcaro · 2022-10-05 20:29 Hello, I make some test. I can compile my programs, but as I said if I push ctrl+space to get a list of possible instructions, I got the error Unit RP2040. I test the same in the examples and I got the same error. I make a video, may can explain better that me https://youtu.be/wH5QfApGNxI /BlueIcaro ---------------------------------------------------------------------- PascalDragon · 2022-10-06 07:06 Quote from: KodeZwerg on October 02, 2022, 09:39:07 pmQuote from: Arioch on October 02, 2022, 08:58:28 pmNot sure, but AFAIR in Delphi such a wrong name could lead to weird linking errors later, hard to diagnose In Delphi it would not compile at all since unit names on disk and in source must match. It would than try search for old compiled version of that file and ignore current i guess. The unit names must match. There is no such requirement for the program or library names (which are not units). In FPC there's a command line parameter to allow unit names to differ as well. ---------------------------------------------------------------------- MiR · 2022-10-06 15:52 When you install lazarus with fpcupdeluxe a lot more defaults are added to your fpc config and to lazarus to make codetools & friends work. So, just to be sure that I understood correctly: When you use lazarus from fpcupdeluxe then ctrl-space works, no error about rp2040 unit not found... correct? if this is the case then please check the FPC source directory entry in the Preferences->Environment tab in my case it is /Users/ring/fpcupdeluxe/fpcsrc find your's and then check if you see this file: rtl/embedded/arm/rp2040.pp most likely your fpcsrc directory does not have this file... ---------------------------------------------------------------------- MiR · 2022-10-06 18:39 Just rebuilt lazarus with sources of today and now my lazarus also does create the rp2040 not found error. I am investigating, currently looks as if something is broken in codetools.... TFindDeclarationTool.FindUnitSource Self="/Users/ring/devel/pico- fpcexamples/blinky/blinky.lpr" AnUnitName="pico_gpio_c" AnUnitInFilename="" TCTDirectoryCache.FindUnitSourceInCompletePath AUnitName="pico_gpio_c" InFilename="" Directory="/Users/ring/devel/pico-fpcexamples/blinky/" [TFindDeclarationTool.FindCodeToolForUsedUnit]  This source is=/Users/ring/devel/pico-fpcexamples/blinky/blinky.lpr NewCode=/Users/ring/devel/pico-fpcexamples/units/pico_gpio_c.pas TFindDeclarationTool.FindUnitSource Self="/Users/ring/devel/pico- fpcexamples/blinky/blinky.lpr" AnUnitName="RP2040" AnUnitInFilename="" TCTDirectoryCache.FindUnitSourceInCompletePath AUnitName="RP2040" InFilename="" Directory="/Users/ring/devel/pico-fpcexamples/blinky/" TCTDirectoryCache.FindUnitSourceInCompletePath unit RP2040 not found in SrcPath="/Users/ring/devel/pico- fpcexamples/blinky;/Users/ring/devel/pico-fpcexamples/units"  Directory="/Users/ring/devel/pico-fpcexamples/blinky/" searchin in unitset ... TFPCUnitSetCache.GetUnitSrcFile Unit="RP2040" SrcSearchRequiresPPU=False SkipPPUCheckIfTargetIsSourceOnly=True TFPCUnitSetCache.GetUnitSrcFile Unit="RP2040" Result= TCTDirectoryCache.FindUnitSourceInCompletePath unit RP2040 not found in unitlinks. Directory="/Users/ring/devel/pico-fpcexamples/blinky/" ### TCodeToolManager.HandleException: [20170421200056] "unit not found: RP2040" in "/Users/ring/devel/pico- fpcexamples/blinky/blinky.lpr" ---------------------------------------------------------------------- MiR · 2022-10-06 20:50 I tested a little more, I see the following behaviour: When I do a fresh install in a new directory with fpcupdeluxe and load a pico project I get the rp2040 not found error. When I then select Tools -> Rescan FPC Source directory the error goes away and I can use ctrl-space @BlueIcaro, does the same work for you? ---------------------------------------------------------------------- BlueIcaro · 2022-10-07 14:24 Hi, I'm sorry. I couldn't test it until today. As you said the problem is in codetools. I Rescan Fpc source directory, and every thing works nice. The solution works fine @Mir. Thank for all /BlueIcaro