[SOLVED] matrix unit not found lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- apeoperaio · 2018-05-25 11:32 I have a project using matrix unit (https://www.freepascal.org/docs- html/rtl/matrix/index.html) but I have problems using it on my Mac (fpc 3.0.4 lazarus 1.8.2). If I add the matrix unit to my application it is not found correctly, instead of matrix unit lazarus points to a matrix.pp program located in fpcsrc/tests/bench/shootout/obsolete/matrix.pp Both using carbon or cocoa. I got it even with a new project. Here a snippet of the program that lazarus found instead of matrix unit. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i { Matrix Multiplication } program matrix;uses SysUtils; const    size = 30; type tMatrix = array[0..size, 0..size] of longint;       Any hint? ---------------------------------------------------------------------- Thaddy · 2018-05-25 11:45 If you need a unit called matrix, don't call your program matrix.... ---------------------------------------------------------------------- apeoperaio · 2018-05-25 11:49 And I don't. I just create a new application (project1) and here it is the source: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, matrix; type  TForm1 = class(TForm)  private    ms: Tmatrix3_single;  public   end; var  Form1: TForm1; implementation {$R *.lfm} end.  If I try to navigate to matrix unit the matrix.pp program source is opened. ---------------------------------------------------------------------- ccrause · 2018-05-25 12:35 Quote from: apeoperaio on May 25, 2018, 01:32:35 pmI have a project using matrix unit (https://www.freepascal.org/docs- html/rtl/matrix/index.html) but I have problems using it on my Mac (fpc 3.0.4 lazarus 1.8.2). Any hint? The source is located here: [fpc source dir]\packages\rtl- extra\src\inc On my Lazarus with FPC bundled install the compiled unit is located here: [fpc compiled units dir]\x86_64-win64\rtl-extra How did you install FPC (package manager, compile from source ...)? To me it seems as if the rtl-extra package isn't installed on your Mac. ---------------------------------------------------------------------- wp · 2018-05-25 12:40 Quote from: apeoperaio on May 25, 2018, 01:49:22 pmIf I try to navigate to matrix unit the matrix.pp program source is opened. matrix.pp is not a program, but a unit. How do you navigate? If you CTRL+click on the name of the unit "matrix" the IDE will open the source file of unit matrix.pp at the top. If you CTRL+click on the word "tmatrix3_single" in your code the IDE will jump to the implementation (or interface) of this type. It is in matrix.pp, too. ---------------------------------------------------------------------- apeoperaio · 2018-05-25 14:29 I navigate using CTRL+click, if I CTRL+click on the name of matrix unit matrix.pp is opened (/usr/local/share/fpcsrc/tests/bench/shootout/obsolete/matrix.pp). See image. If I CTRL+click on tmatrix3_single nothing happen. I installed lazarus (1.8.2) and fpc (3.0.4) from source forge (https:/ /sourceforge.net/projects/lazarus/files/Lazarus%20Mac%20OS%20X%20i386/ Lazarus%201.8.2/). All the 3 dmg files. Everything works as expected (I am using it for production) except this strange behaviour for matrix unit. If I navigate through terminal I can find the correct matrix.pp here [fpc source dir]/packages/rtl-extra/src/inc, lazarus doesn't. ---------------------------------------------------------------------- apeoperaio · 2018-05-25 14:37 If I do this: uses   matrix in ''/usr/local/share/fpcsrc/packages/rtl- extra/src/inc/matrix.pp''; Ctrl+click works as expected both for matrix name and tmatrix3_single. Eventually there are variable that could I use instead of specifying the whole absolute path? ---------------------------------------------------------------------- wp · 2018-05-25 15:33 Which paths are specified in "Options" > "Compiler options" > "Paths" of your project? When I create a new project in Lazarus ("File" > "New" > "Project" > "Simple program") the path "Other unit files" is empty. And the following program compiles and runs correctly, and CTRL+Click on TMatrix3_single leads to the correct file: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; uses  matrix; var  m: Tmatrix3_single; begin  m.Init(11, 12, 13, 21, 22, 23, 31, 32, 33);  WriteLn(m.data[0,0]:0:3);  ReadLn;end. Moreover, look at the paths shown in fpc.cfg. Your path /usr/local/share/fpcsrc/tests/bench/shootout/obsolete (or part of it) should not be mentioned. ---------------------------------------------------------------------- apeoperaio · 2018-05-25 16:19 Quote from: wp on May 25, 2018, 05:33:22 pmWhich paths are specified in "Options" > "Compiler options" > "Paths" of your project? It is empty. Quote from: wp on May 25, 2018, 05:33:22 pmWhen I create a new project in Lazarus ("File" > "New" > "Project" > "Simple program") the path "Other unit files" is empty. And the following program compiles and runs correctly, and CTRL+Click on TMatrix3_single leads to the correct file: It compiles and runs fine even here but CTRL+Click on TMatrix3_single does not open anything. Below fpc.cfg located in /private/etc/fpc.cfg Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ## Config file generated by fpcmkcfg on 27-3-18 - 18:25:06# Example fpc.cfg for Free Pascal Compiler# # ----------------------# Defines (preprocessor)# ---------------------- ## nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed## -d is the same as #DEFINE# -u is the same as #UNDEF# ## Some examples (for switches see below, and the -? helppages)## Try compiling with the -dRELEASE or -dDEBUG on the commandline# # For a release compile with optimizes and strip debuginfo#IFDEF RELEASE  -O2  -Xs  #WRITE Compiling Release Version#ENDIF # For a debug version compile with debuginfo and all codegeneration checks on#IFDEF DEBUG  -gl  -Crtoi  #WRITE Compiling Debug Version#ENDIF # assembling#ifdef darwin# use pipes instead of temporary files for assembling-ap# path to Xcode 4.3+ utilities (no problem if it doesn't exist)-FD/Applications/Xcode.app/Contents/Developer/usr/bin#endif # ----------------# Parsing switches# ---------------- # Pascal language mode#      -Mfpc      free pascal dialect (default)#      -Mobjfpc   switch some Delphi 2 extensions on#      -Mdelphi   tries to be Delphi compatible#      -Mtp       tries to be TP/BP 7.0 compatible#      -Mgpc      tries to be gpc compatible#      -Mmacpas   tries to be compatible to the macintosh pascal dialects## Turn on Object Pascal extensions by default#-Mobjfpc # Assembler reader mode#      -Rdefault  use default assembler#      -Ratt      read AT&T style assembler#    -Rintel    read Intel style assembler## All assembler blocks are AT&T styled by default#-Ratt # Semantic checking#      -S2        same as -Mobjfpc#      -Sc        supports operators like C (*=,+=,/= and -=)#      -Sa        include assertion code.#      -Sd        same as -Mdelphi#      -Se     error options. is a combination of the following:#         : compiler stops after errors (default is 1)#         w   : compiler stops also after warnings#         n   : compiler stops also after notes#         h   : compiler stops also after hints#      -Sg        allow LABEL and GOTO#      -Sh        Use ansistrings#      -Si        support C++ styled INLINE#      -Sk      load fpcylix unit#      -SI     set interface style to #       -SIcom    COM compatible interface (default)#         -SIcorba  CORBA compatible interface#      -Sm        support macros like C (global)#    -So        same as -Mtp#      -Sp        same as -Mgpc#      -Ss      constructor name must be init (destructor must be done)#      -Sx        enable exception keywords (default in Delphi/ObjFPC modes)## Allow goto, inline, C-operators, C-vars-Sgic # ---------------# Code generation# --------------- # Uncomment the next line if you always want static/dynamic units by default# (can be overruled with -CD, -CS at the commandline)#-CS#-CD # Set the default heapsize to 8Mb#-Ch8000000 # Set default codegeneration checks (iocheck, overflow, range, stack)#-Ci#-Co#-Cr#-Ct # Optimizer switches# -Os        generate smaller code# -Oa=N      set alignment to N# -O1        level 1 optimizations (quick optimizations, debuggable)# -O2        level 2 optimizations (-O1 + optimizations which make debugging more difficult)# -O3        level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)# -Oo   switch on optimalization x. See fpc -i for possible values# -OoNO switch off optimalization x. See fpc -i for possible values# -Op   set target cpu for optimizing, see fpc -i for possible values #ifdef darwin#ifdef cpui386-Cppentiumm-Oppentiumm#endif#endif # -----------------------# Set Filenames and Paths# ----------------------- # Both slashes and backslashes are allowed in paths # path to the messagefile, not necessary anymore but can be used to override# the default language#- Fr/usr/local/lib/fpc/$fpcversion/msg/errore.msg#- Fr/usr/local/lib/fpc/$fpcversion/msg/errorn.msg#- Fr/usr/local/lib/fpc/$fpcversion/msg/errores.msg#- Fr/usr/local/lib/fpc/$fpcversion/msg/errord.msg#- Fr/usr/local/lib/fpc/$fpcversion/msg/errorr.msg # search path for unicode binary files (FPC 2.x does not know this switch)#ifndef VER2-FM/usr/local/lib/fpc/../../share/fpc/$fpcversion/unicode/#endif # searchpath for units and other system dependent things- Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget-Fu/usr/local/lib/fpc /$fpcversion/units/$fpctarget/*- Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/rtl #ifdef cpui8086- Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch- $fpcmemorymodel-Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/$fpc subarch-$fpcmemorymodel/*- Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch- $fpcmemorymodel/rtl#endif #IFDEF FPCAPACHE_1_3- Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/httpd13/#ELSE#IFDEF FPCAPACHE_2_0- Fu/usr/local/lib/fpc/$fpcversion/units/$fpctarget/httpd20#ELSE-Fu/usr/ local/lib/fpc/$fpcversion/units/$fpctarget/httpd22#ENDIF#ENDIF # searchpath for fppkg user-specific packages- Fu~/.fppkg/lib/fpc/$fpcversion/units/$FPCTARGET/* # path to the gcclib#ifdef cpui386- Fl/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.x ctoolchain/usr/lib/clang/9.0.0/lib/darwin17.4.0#endif#ifdef cpux86_64- Fl/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.x ctoolchain/usr/lib/clang/9.0.0/lib/darwin17.4.0#endif#ifdef cpupowerpc-Fl/Applications/Xcode.app/Contents/Developer/Toolchains/Xco deDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin17.4.0#endif#ifdef cpupowerpc64- Fl/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.x ctoolchain/usr/lib/clang/9.0.0/lib/darwin17.4.0#endif # searchpath for libraries#-Fl/usr/local/lib/fpc/$fpcversion/lib#-Fl/lib;/usr/lib- Fl/usr/local/lib/fpc/$fpcversion/lib/$FPCTARGET # searchpath for tools-FD/usr/local/lib/fpc/$fpcversion/bin/$FPCTARGET #IFNDEF Darwin#DEFINE NEEDCROSSBINUTILS#ENDIF # never need cross-prefix when targeting the JVM# (no native compiler, always cross-compiling)#ifdef cpujvm#undef NEEDCROSSBINUTILS#endif # for android cross-prefix is set by compiler#ifdef android#undef NEEDCROSSBINUTILS#endif # never need cross-prefix when targeting the i8086# (no native compiler, always cross-compiling)#ifdef cpui8086#undef NEEDCROSSBINUTILS#endif # never need cross-prefix when targeting the i8086# (no native compiler, always cross-compiling)#ifdef cpujvm#undef NEEDCROSSBINUTILS#endif # binutils prefix for cross compiling#IFDEF FPC_CROSSCOMPILING#IFDEF NEEDCROSSBINUTILS  -XP$FPCTARGET-#ENDIF#ENDIF  # -------------# Linking# ------------- # generate always debugging information for GDB (slows down the compiling# process)#      -gc        generate checks for pointers#      -gd        use dbx#      -gg        use gsym#      -gh        use heap trace unit (for memory leak debugging)#      -gl      use line info unit to show more info for backtraces#      -gv      generates programs tracable with valgrind#      -gw        generate dwarf debugging info## Enable debuginfo and use the line info unit by default#-gl # always pass an option to the linker#-k-s # Always strip debuginfo from the executable-Xs # Always use smartlinking on i8086, because the system unit exceeds the 64kb# code limit#ifdef cpui8086-CX-XX#endif  # -------------# Miscellaneous# ------------- # Write always a nice FPC logo ;)-l # Verbosity#      e : Show errors (default)       d : Show debug info#      w : Show warnings               u : Show unit info#      n : Show notes                t : Show tried/used files#      h : Show hints                s : Show time stamps#      i : Show general info           q : Show message numbers#      l : Show linenumbers            c : Show conditionals#      a : Show everything             0 : Show nothing (except errors)#      b : Write file names messages   r : Rhide/GCC compatibility mode#          with full path              x : Executable info (Win32 only)#      v : write fpcdebug.txt with     p : Write tree.log with parse tree#          lots of debugging info## Display Info, Warnings and Notes-viwn# If you don't want so much verbosity use#-vw ---------------------------------------------------------------------- Thaddy · 2018-05-25 18:38 Ok reverse my answer "If you need a unit called matrix, don't call your program matrix...." Instead: Search for a program file called "program matrix;" (with find in files...) and delete it. Problem solved. Actually I suspect this is a small bug in Lazarus: lpr and lpi (project files) are handled correctly, but .pp and .pas files can also be programs...... Who'll pick it up? Note that anyway you or someone who has access to your computer wrote a program called matrix....Rename it or delete it. Even worse: it is probably in your sourcecode root directory, otherwise Laz would pick up the unit, not the program .....< Uhh, I politely ask to re-introduce grumpy ...    > ---------------------------------------------------------------------- wp · 2018-05-25 18:45 Quote from: Thaddy on May 25, 2018, 08:38:03 pmOk reverse my answer "If you need a unit called matrix, don't call your program matrix...." Instead: Search for a program file called "program matrix" (with find in files...) and delete it. Problem solved. Actually I suspect this is a small bug in Lazarus: lpr and lpi (project files) are handled correctly, but .pp and .pas files can also be programs...... Who'll pick it up? Note that anyway you or someone who has access to your computer wrote a program called matrix.... Really? If there is a program "matrix.pp" somewhere on my disk how will Lazarus/fpc be able to find it? I still believe that something is messed up in the paths of OP's installation. ---------------------------------------------------------------------- Thaddy · 2018-05-25 18:51 No. I can repeat it and reproduce it on at least three platforms: write a Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program matrix;begin end. is enough. On all platforms. Write it with "copy con" on windows or fp or vim on linux and save it with extension .pp or .pas . Then start something like *his* project in Laz and in the same directory: F*cked up... Lazarus relies too much on the silly .lpi file.... Which matrix.pp will come first? Come on, you know which.... But *he* must have written that first, get it? And it is the sourcecode, not any binary. ---------------------------------------------------------------------- wp · 2018-05-25 19:05 Quote from: Thaddy on May 25, 2018, 08:51:42 pmThen start something like *his* project in Laz and in the same directory. Up in reply #5 the OP writes that the guilty matrix.pp is in /usr/local/share/fpcsrc/tests/bench/shootout/obsolete/matrix.pp. This is a folder belonging to fpc and certainly NOT his project folder. ---------------------------------------------------------------------- Thaddy · 2018-05-25 19:09 Well  /usr/local/share/fpcsrc/tests/bench/shootout/obsolete/matrix.pp is a program.... And I don't even have it.... (well that's funny.... ) Since there is no lpi for that program and his path is somehow pointing to that path *before* his library paths things get f*cked up. And if you reproduce my steps you know why. ---------------------------------------------------------------------- wp · 2018-05-25 23:02 The issue has been fixed in Laz trunk by Mattias Gaertner. It was an issue in codetools. apeoperaio, if you want to patch your Lazarus version 1.8.2, you should do this: In folder components/codetools/ open the file fpcsrcrules.incImmediately after line 13 (Score:=-10) add the line Add('tests');Save and recompile the IDE. ---------------------------------------------------------------------- Thaddy · 2018-05-26 07:00 Quote from: wp on May 26, 2018, 01:02:53 amThe issue has been fixed in Laz trunk by Mattias Gaertner. Many thanks to Matthias! This may be rare, but was also really annoying. (and fun to reproduce...) Will re-test in a few minutes. [edit] 58031 looks like indeed have fixed the issue. ---------------------------------------------------------------------- apeoperaio · 2018-05-28 07:57 Quote from: wp on May 26, 2018, 01:02:53 amThe issue has been fixed in Laz trunk by Mattias Gaertner. It was an issue in codetools. apeoperaio, if you want to patch your Lazarus version 1.8.2, you should do this: In folder components/codetools/ open the file fpcsrcrules.incImmediately after line 13 (Score:=-10) add the line Add('tests');Save and recompile the IDE. It works. Thanks!