Error free Pascal Compiler fpc

Hi everyone

What happens

When executing fpc test.pas (where test.pas is just a program that reads hello world) I get an error: Cannot open file “teste.pas”. If I open the ID and run from there I get the error: can’t find unit system used by test. I am using Virtual Machine Ubuntu.

What do you understand or find about that problem

What I have found is that the problem is with the path that the fpc compiler has.

You make any workaround? What did you do?

I have uninstalled, purged all the fpc files, reinstalled and the problem continues, also try downloading Lazarus as explained on the page https://www.lazarus-ide.org/ but it does not compile either.

Evidences

I need help with

What should I do so that from the terminal I can execute the program correctly

It seems that you’re trying to run a file that doesn’t exist in your current directory, however it is difficult to tell without knowing the installation process you used or the environment you are working in.

Please first use ls command to know if the file exists in your current directory, if it doesn’t exist, move it to the directory and retry, if this isn’t the problem I recommend you use the installation process that we recommend in the documentation Languages | Autonomic Jump

Download nix, and then install fpc as indicated but now I get the following

use this fpc -vut teste.pas

if output don’t show something like this you have a problem in the path that fpc use to search unit

Using executable path: /nix/store/n8q8pgcinl4d53929nw1s6mqvwdxybq3-fpc-3.2.0/lib/fpc/3.2.0/
Using unit path: /nix/store/n8q8pgcinl4d53929nw1s6mqvwdxybq3-fpc-3.2.0/lib/fpc/3.2.0/units/x86_64-linux/httpd22/
Using unit path: /nix/store/n8q8pgcinl4d53929nw1s6mqvwdxybq3-fpc-3.2.0/lib/fpc/3.2.0/units/x86_64-linux/rtl/

i cleaned the files and reinstalled fpc and now i have this error
Captura de pantalla de 2021-09-07 20-14-52

Looks like it already compiles the program, check if the binary file was generated.

Did you use Nix? This is the current version on the pipelines
Free Pascal Compiler version 3.2.0 [2021/07/18] for x86_64

1 Like

You should use fpc ./teste.pas instead of fpc teste.pas

The same message keeps showing.

$ fpc ./teste.pas
Free Pascal Compiler version 3.0.4+dfsg-23 [2019/11/25] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling ./teste.pas
Linking teste
/usr/bin/ld.bfd: warning: link.res contains output sections; did you forget -T?
4 lines compiled, 0.1 sec

It was already compiled, now to run the binary you must use only ./teste.
You can also run one command followed by the other using fpc ./teste.pas; ./teste to make it faster