Help: New install problems

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Help: New install problems

Anthony Walter-3
I have installed fpc from sources before but it's been a while and I've forgotten how to get it done, or perhaps something has changed and  need some help.

When i am trying to do is install and run the latest version of fpc from my home folder. Here is what I did:

# first I got a working version of fpc installed using
sudo apt-get install fpc

# then i made a ~/fpc and got a copy fpc sources there

# finally did a make all follow by make install to my home folder
make all
make install 
make install INSTALL_PREFIX=/home/myusername

Great success! Now I have a ~/bin (/home/myusername/bin) folder with all the fpc binaries as well as ~/share and ~/lib. Then put /home/myusername/bin in my path.

Problem:

When I type fpc I get:

Free Pascal Compiler version 2.4.4-2ubuntu1 [2011/09/27] for i386
Copyright (c) 1993-2010 by Florian Klaempfl
/usr/lib/fpc/2.4.4/ppc386 [options] <inputfile> [options]

And not the version I just built and installed in my ~/bin folder. When I open a terminal and cd to ~/bin and execute ./fpc ... I get the same result.

Help: 

How do I setup fpc to use the compiler in my ~/bin folder?

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Help: New install problems

Jonas Maebe-2
Anthony Walter wrote on Mon, 02 Apr 2012:

> I have installed fpc from sources before but it's been a while and I've
> forgotten how to get it done, or perhaps something has changed and  need
> some help.
>
> When i am trying to do is install and run the latest version of fpc from my
> home folder. Here is what I did:
>
> # first I got a working version of fpc installed using
> sudo apt-get install fpc
>
> # then i made a ~/fpc and got a copy fpc sources there
> svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus

Those are not the FPC sources, but the Lazarus sources. The fpc  
sources are in http://svn.freepascal.org/svn/fpc/trunk

> # finally did a make all follow by make install to my home folder
> make all
> make install
> make install INSTALL_PREFIX=/home/myusername

This first installs everything in the root (make install), and then  
again in your home directory (make install INSTALL_PREFIX=...). That  
may not be what you want.

> Great success! Now I have a ~/bin (/home/myusername/bin) folder with all
> the fpc binaries as well as ~/share and ~/lib. Then
> put /home/myusername/bin in my path.

If you did in fact compile and install FPC rather than Lazarus (it's  
better to copy/paste the actually executed commands rather than typing  
everything again from memory): the "fpc" binary looks for a compiler  
binary in its own directory, and if it doesn't find it there then it  
will look for it in the PATH.

However, "make install" does not create/overwrite any symbolic links  
to the actual compiler binaries in the $INSTALL_PREFIX/bin, so as not  
to change the default compiler version that has potentially already  
been installed in that same prefix. This means that the new fpc will  
still find the old (symlink to the) compiler binary in /usr/bin.

If you do want to change the default compiler, also execute the  
following command:
make FPC=`pwd`/compiler/ppc386 -C compiler installsymlink  
INSTALL_PREFIX=/home/myusername

(replace ppc386 with ppcx64 if you built an x86-64 compiler)


Jonas

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Help: New install problems

Anthony Walter-3
Thanks. Yes I wanted to get fpc (the compiler) installed from sources rather than lazarus. Your advice somewhat got me there, but now when I compile the source/units are not found.

cd /home/myusername
sudo apt-get install fpc
mkdir fpc
cd fpc
# now i'm at at /home/myusername/fpc/fpc
make all
make FPC=`pwd`/compiler/ppc386 -C compiler installsymlink INSTALL_PREFIX=/home/myusername
make install INSTALL_PREFIX=/home/myusername
cd /home/myusername

Then I created Hello.pas:

program Hello;

begin
  WriteLn('Hello');
end.

And then:

fpc Hello.pas


Error:

Free Pascal Compiler version 2.7.1 [2012/04/02] for i386
Copyright (c) 1993-2012 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling Hello.pas
Fatal: Can't find unit system used by Hello
Fatal: Compilation aborted
Error: /home/delluser/bin/ppc386 returned an error exitcode


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Help: New install problems

Jonas Maebe-2
Anthony Walter wrote on Mon, 02 Apr 2012:

> Thanks. Yes I wanted to get fpc (the compiler) installed from sources
> rather than lazarus. Your advice somewhat got me there, but now when I
> compile the source/units are not found.
>
> cd /home/myusername
> sudo apt-get install fpc
> mkdir fpc

> svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus

Here you are again checking out the lazarus sources?

> make FPC=`pwd`/compiler/ppc386 -C compiler installsymlink INSTALL_PREFIX=
/home/myusername
> make install INSTALL_PREFIX=/home/myusername

It's probably better to switch the order of those two commands.

> Free Pascal Compiler version 2.7.1 [2012/04/02] for i386
> Copyright (c) 1993-2012 by Florian Klaempfl and others
> Target OS: Linux for i386
> Compiling Hello.pas
> Fatal: Can't find unit system used by Hello
> Fatal: Compilation aborted
> Error: /home/delluser/bin/ppc386 returned an error exitcode

The default FPC configuration file is /etc/fpc.cfg and it includes  
information for units installed globally. If you install them  
elsewhere, you have to create an alternate configuration file that  
tells the compiler where to find them.

The easiest way is probably to copy /etc/fpc.cfg to ~/.fpc.cfg (notice  
the leading dot) and then replace all /usr/lib/fpc with  
/home/myusername/fpc. This means however that every compiler  
invocation will use this alternate configuration file, so also when  
using the globally installed 2.4.4 (which in turn will then complain  
that it can't find /its/ units).

If you also want to be able to use the globally installed FPC (by e.g.  
explicitly calling /usr/bin/ppc386), it's probably best to put the  
above in ~/.fpc-trunk.cfg, and then create a ~/.fpc.cfg with the  
following contents:

#ifdef VER2_7
#include /home/myusername/.fpc-trunk.cfg
#else
#include /etc/fpc.cfg
#endif

You will have to replace the VER2_7 with newer version numbers when  
the version number in svn trunk is changed though. Alternatively, you  
can switch around the then/else branches and use VER2_4 instead, but  
then you'll have the same problem when the version number of the  
globally installed version changes.


Jonas

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal