Recent

Author Topic: Unable to compile on Ubuntu 14.04  (Read 18600 times)

Paolo_R

  • New Member
  • *
  • Posts: 34
Unable to compile on Ubuntu 14.04
« on: October 26, 2015, 04:12:48 am »
I've just installed FPC 2.6.2-8 on Ubuntu. I can't get testapp.pas (a FV example program) to compile.

First of all, in the Options -> Directories dialog I've no idea what to put in the various options i.e. Unit directories, Include files, Libraries, Object files and Miscellaneous, as I don't know where the install program has put the various files.

Second, if I try to compile testapp.pas I get an error 'Can't open include file "platform.inc"'. I don't know where this is so I commented out the line.

Third, after commenting out the {$I platform.inc} line I then get the error 'Can't find unit Drivers for testapp'.

SoI've fallen at the frst hurdle. Can any one enlighten me please?

Paul

 

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1216
    • Burdjia
Re: Unable to compile on Ubuntu 14.04
« Reply #1 on: October 26, 2015, 06:53:23 pm »
I've just installed FPC 2.6.2-8 on Ubuntu. I can't get testapp.pas (a FV example program) to compile.

First of all, in the Options -> Directories dialog I've no idea what to put in the various options i.e. Unit directories, Include files, Libraries, Object files and Miscellaneous, as I don't know where the install program has put the various files.
In most (actually almost all) cases you don't need to change that.

Second, if I try to compile testapp.pas I get an error 'Can't open include file "platform.inc"'. I don't know where this is so I commented out the line.

Third, after commenting out the {$I platform.inc} line I then get the error 'Can't find unit Drivers for testapp'.
Seems like you didn't installed everything you need, or that you didn't installed it correctly.

I recommend you to reinstall it.  Look at the wiki to be sure you're doing it correctly.
« Last Edit: October 26, 2015, 06:56:21 pm by Ñuño_Martínez »
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Paolo_R

  • New Member
  • *
  • Posts: 34
Re: Unable to compile on Ubuntu 14.04
« Reply #2 on: October 26, 2015, 11:50:59 pm »
Quote
Seems like you didn't installed everything you need, or that you didn't installed it correctly.

If I use the non-IDE compiler (fpc) the program compiles so I assume everything was installed correctly.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1216
    • Burdjia
Re: Unable to compile on Ubuntu 14.04
« Reply #3 on: October 29, 2015, 01:05:46 pm »
[edit] I've understood wrongly what you wrote, so next answer isn't what you're asking.  I've have another answer below:
______________________________________________________________________________________
Lazarus units (LCL) aren't in same path than the RTL+FCL libraries.  May be that's why it doesn't find the stuff needed.

I have a project that uses a few LCL units and I had to add the LCL path to the compiler, this way:
Code: [Select]
# From a makefile scritp:

## Where the LCL is.
#LCLDIR = /usr/lib/lazarus/default/lcl/
#CCLDIR = /usr/lib/lazarus/default/components/lazutils/

LCLDIR = /usr/lib64/lazarus/lcl/
CCLDIR = /usr/lib64/lazarus/components/lazutils/

##  Compiler options to add to the compilation command:
LCLUNITS = -Fu$(LCLDIR) -Fu$(LCLDIR)* -Fi$(LCLDIR)include -Fu$(CCLDIR)

## So, to compile:
fpc $(FLAGS) -Fu$(SRCDIR) -Fu$(SRCDIR)* $(LCLUNITS) -FU$(OBJDIR) $(SRCDIR)program.pas -o$(BINDIR)program

As you see, there are different paths depending on your system and version.  For example, I had to change it in the last update.
_______________________________________________________________________________

[edit] Here you have a better answer:

If FPC is able to compile it correctly, then Lazarus IDE should be able to compile it as well.

May be you're using a configuration for FPC that is different than the configuration you use for Lazarus.  Take a look to the command-line options you used to compile with FPC, and also look in the FPC configuration file (fpc.cfg, IIRC) and read documentation about options.  Then revise your project's configuration in Lazarus.

Also check if you're using the same compiler in any case (i.e. you have installed FPC "by hand" then installed Lazarus).
« Last Edit: October 29, 2015, 01:27:44 pm by Ñuño_Martínez »
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Paolo_R

  • New Member
  • *
  • Posts: 34
Re: Unable to compile on Ubuntu 14.04
« Reply #4 on: October 29, 2015, 11:26:34 pm »
I am not using Lazarus. When I talked about the IDE I meant the text-based UI of Free Pascal, the one that looks like Turbo Pascal. So I'm using the same compiler for both IDE and non-IDE.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1216
    • Burdjia
Re: Unable to compile on Ubuntu 14.04
« Reply #5 on: October 31, 2015, 12:50:12 pm »
You should say that from the beggining... >:(

Anyway, what was said for Lazarus works also for fpide.  You should remove the fpide configuration file (now I don't remember the name, but should be "fpide.cfg" or something) if you have problems.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Paolo_R

  • New Member
  • *
  • Posts: 34
Re: Unable to compile on Ubuntu 14.04
« Reply #6 on: November 01, 2015, 02:02:06 am »
Actually I never said anywhere that I was using Lazarus - you assumed that.

Anyway fp.cfg is in my home directory. Removing it made no difference. A new fp.cfg was created the next time I opened the Free Pascal IDE and it contained the same contents as the previous fp.cfg

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Unable to compile on Ubuntu 14.04
« Reply #7 on: November 01, 2015, 02:43:02 am »
@Paolo_R:
First realize that there are 3 _different_ configurations possible.

You can switch configurations using menu->options->mode to switch between normal, debug and release mode.

When switching modes, also all the configuration options made (and saved) belong to that mode you selected using that menu.

So, please don't be surprised to see empty directories again when switching modes  ;)

Ok, as for the directories (i had to dig out an old fp-ide windows installation), my unit directory option reads: D:\WinDev\FPC271\units\i386-win32\*

Although above is a Windows oriented path, i do hope it will help you recognize where exactly to look for the units installed by FPC. You could apply something similar for include paths.

Since you're on linux you probably would also need something like the library directory point to your linux development environment libraries (where that is depends on your linux distro and where you installed your development libraries).

Things can get complicated fast when wanting to cross-compile, but i didn't saw you mentioning that  :D

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1290
Re: Unable to compile on Ubuntu 14.04
« Reply #8 on: November 01, 2015, 02:47:05 am »
hello,
i have tried to compile testapp.pas from fv examples on Ubuntu 14.04   fpc 2.6.4 . Success adding this line in the fpide menu  Options/Directories/ tab Include Files :
Code: Pascal  [Select][+][-]
  1. /usr/share/fpcsrc/$fpcversion/packages/fv/src
  2.  
Friendly J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Unable to compile on Ubuntu 14.04
« Reply #9 on: November 01, 2015, 03:17:31 am »
@Jurassic Pork
i stumbled upon a 2.6.4 windows installation, and the file platform.inc was nowhere to be found. At least not in the binary distribution.

I guess a small oversight ? or is it expected for end-users to also install the sources ?

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Unable to compile on Ubuntu 14.04
« Reply #10 on: November 01, 2015, 03:32:33 am »
Ha, i'm able to answer my own questions  ;D

FPC 3.0 RC1 includes platform.inc inside fv example directory  8)

Paolo_R

  • New Member
  • *
  • Posts: 34
Re: Unable to compile on Ubuntu 14.04
« Reply #11 on: November 01, 2015, 05:11:25 am »
hello,
i have tried to compile testapp.pas from fv examples on Ubuntu 14.04   fpc 2.6.4 . Success adding this line in the fpide menu  Options/Directories/ tab Include Files :
Code: Pascal  [Select][+][-]
  1. /usr/share/fpcsrc/$fpcversion/packages/fv/src
  2.  
Friendly J.P

JP: thanks. I added that line to the Include Files directory substituting 2.6.2 and tried again to compile testapp.pas from the examples directory but I'm still getting Compile failed[/b with Total errors of 2. No indication what the errors are.

I have mode as Normal and targetprocessor as 808386.

One point: when I put entries into the Directories options and then Save what file are these changes written to? The fp.ini in my Home directory doesn't show any difference.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1290
Re: Unable to compile on Ubuntu 14.04
« Reply #12 on: November 01, 2015, 11:16:59 am »
the option is in the fp.cfg file :
Quote
-Fu/usr/lib/fpc/$fpcversion\units\$fpctarget
 -Fu/usr/lib/fpc/$fpcversion\units\$fpctarget\*
 -Fu/usr/lib/fpc/$fpcversion\units\$fpctarget\rtl
 -Fi/usr/share/fpcsrc/$fpcversion/packages/fv/src
 -Fl/usr/lib/gcc/x86_64-linux-gnu/4.8/32
 -Fl/usr/lib/gcc/x86_64-linux-gnu/4.8
 -XS
Processor target ATHLON64 ( UBUNTU 64 bits )
i launch fp in the /usr/share/fpcsrc/2.6.4/ide folder in an admin terminal. Version of fp : 2.6.4
« Last Edit: November 01, 2015, 11:21:12 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Unable to compile on Ubuntu 14.04
« Reply #13 on: November 01, 2015, 04:16:55 pm »
JP: thanks. I added that line to the Include Files directory substituting 2.6.2 and tried again to compile testapp.pas from the examples directory but I'm still getting Compile failed[/b with Total errors of 2. No indication what the errors are.
That's strange. The compiler message windows (F12) that should appear during compilation should at least give you an indication of what is wrong exactly.

FWIW:
If you select menu->options->compiler... and select the verbose tab, you can 'tick' several options.

If you 'checkmark' the All option then when you compile a file/project Free Pascal will show you all the files it is trying to locate, show all warnings, hints etc. -> that is the best way to locate Free Pascal and/or toolchain related errors.

It adds a fair amount of time to compilation, and produces a lot of output, but it is very helpful in case you are trying to solve a compilation related issue (besides the obvious errors located in source-code).

Quote
I have mode as Normal and targetprocessor as 808386.
Just for the record: it does not matter much for/under which mode you compile, you just have to make sure you configure all modes with similar using paths. Details of the chosen options can differ to reflect the chosen mode. E.g. in debug mode it is common to add debug information and/or put range checking on. Or as another example use paths to units compiled with debug information included.

Quote
One point: when I put entries into the Directories options and then Save what file are these changes written to? The fp.ini in my Home directory doesn't show any difference.
As explained by JP. Your comple related settings are located inside fp.cfg.

The fp.ini file just 'contains' all the desktop information like windows positions, last opened files etc.


And also to just make sure:
The missing include file that you experience is/was an oversight. e.g. it is a bug that is already solved in FPC 3.x. Normally (as end-user) you should usually have no need to set an include path to FPC sources.

So as an alternative to JP's solution (adding the include path) you can also 'follow' the solution presented by FPC 3.x and download the platform.inc file inside and place it in the directory of the example that you are trying to compile.

The platform.inc file can be downloaded here.

Paolo_R

  • New Member
  • *
  • Posts: 34
Re: Unable to compile on Ubuntu 14.04
« Reply #14 on: November 01, 2015, 11:39:19 pm »
the option is in the fp.cfg file :
 -Fu/usr/lib/fpc/$fpcversion\units\$fpctarget
 -Fu/usr/lib/fpc/$fpcversion\units\$fpctarget\*
 -Fu/usr/lib/fpc/$fpcversion\units\$fpctarget\rtl
 -Fi/usr/share/fpcsrc/$fpcversion/packages/fv/src
 -Fl/usr/lib/gcc/x86_64-linux-gnu/4.8/32
 -Fl/usr/lib/gcc/x86_64-linux-gnu/4.8
 -XS

Are there different versions of fp.cfg? I have a version in my home directory. Under #IFDEF NORMAL of those options you show only
Quote
-Fi/usr/share/fpcsrc/$fpcversion/packages/fv/src
is shown

Quote
i launch fp in the /usr/share/fpcsrc/2.6.4/ide folder in an admin terminal. Version of fp : 2.6.4

I have v 2.6.2 - version 2.6.4 doesn't appear to be available via Synaptic Package Manager.

 

TinyPortal © 2005-2018