Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-09

external .so linking in Linux w/2.5.1 rev 13680 (Sep 8 09)

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Green

Hi All!

I've noticed that someone made a headstart with a unit to bind with FUSE in FreePascal at http://bugs.freepascal.org/view.php?id=12218. I've taken the last two entries (FUSE-2008-12-20-3.PP and Test-2008-12-20-3.PP) and modified the test file on line 88 to use the move() function instead of memcpy() -- and so eliminating the need for the "libc" unit. It compiles, but it fails at linking with this error:

...
Linking Project1
/usr/bin/ld: cannot find -lfuse
...

Okay, strange, nowhere do I see "fuse" specified. But upon closer inspection, it turns out something this gets lost in translation. For example, in the FUSE-2008-12-20-3.PP file, it contains:

...
const
  FUSELIBFile = 'libfuse.so.2';
function fuse_main_real(aARGC : Integer; aARGV: PPChar; aOperations :
TOperationsP; aOperationsSize : size_t; aUserData : Pointer) : Integer;
cdecl; external FUSELIBFile;
...

But in the link.res file I see:

...
INPUT(
-lfuse
)
...

Even if I were to specify:

...
const
  FUSELIBFile = '/lib/libfuse.so.2';
...

Then the link.res file tries to use:
...
INPUT(
-l/lib/libfuse
)
...

So, where's the rest of the library's name? Is it a bug? Did I make a mistake on my end? ( And yes, that library is actually available on my system )

As noted in the subject, I'm using FPC 2.5.1 SVN rev 13680 from September 8th, x86_64 Linux (ppcrossx64). Kernel: 2.6.28-15-generic #49-Ubuntu SMP Tue Aug 18 19:25:34 UTC 2009 x86_64 GNU/Linux

-- MG

Reply by email

Jonas Maebe
to Michael Green
Michael Green wrote 15 lines
Even if I were to specify: ... const FUSELIBFile = '/lib/libfuse.so.2'; ... Then the link.res file tries to use: ... INPUT( -l/lib/libfuse ) ... So, where's the rest of the library's name? Is it a bug?

No, this is intentional. Under Unix, the convention is that the development libraries always have the default base name (i.e., libfuse.so in your case), and these are symbolic links to the library against which you want to link. At link time, the linker follows this link and encodes the name of the library that this link points to in the binary (so it will also work on systems that do not have the development libraries installed, and so that it will keep working should you one day change you development libraries and thereby implicitly change the version of the library to which the symbolic link points).

The problem in your case is most likely that you do not have the fuse- devel package (or something similar) installed, but only the plain fuse package. The latter is all that's needed to run programs that make use of the fuse library, but the former is required if you want to compile/link programs against it. This is a general principle that goes for all packages.

Jonas

Reply by email

Michael Green
to Jonas Maebe

Thanks Jonas.

I could have sworn I had it installed and never bothered to check. Shows that one should never assume ;-)

But it's good to you explained this linker behaviour though, for future reference.

-- MG

Reply by email