Sign in Join

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

Mailing lists / lazarus / 2016-02

/usr/bin/ld: cannot find -lwhatever

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Giuliano Colla

Hi,

I'm need to link some C modules to a Lazarus app.

I started with just a minimal console app, and one module, I've created with h2pas the binding module, and edited to make it compile properly, but when it comes to link I get the "cannot find" error.

I tried both a mymodule.o object and a mymodule.so shared object.

I tried putting the .o/.so in the source directory, in the unit directory, and in /usr/lib64 directory (with an ldconfig to update ld cache).

I tried declaring the external library just with the module name, and with the full path.

I tried adding the path where the .o/.so file is located in the -Fl path of the Compiler Options.

The result is always the same: cannot find -lwhatever, with "whatever" reflecting exactly my external library path/name.

I'm missing?

Giuliano

Reply by email

Giuliano Colla
to Vojtěch Čihák

Il 21/02/2016 16:29, Vojt?ch ?ih?k ha scritto:

Show quoted text 8 lines
Probably not your case but when you add manually libs to system (/usr/lib or /usr/local/lib), you need to run ldconfig as superuser in terminal so the system rescans available libraries.

I'm aware of that, and I did it, but no luck:-(

Giuliano

Reply by email

David W Noon
to Giuliano Colla: I'm need to link some C modules to a Lazarus app. I started with just a minimal console…

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, 21 Feb 2016 15:46:37 +0100, Giuliano Colla () wrote about "[Lazarus] /usr/bin/ld:
cannot find -lwhatever" (in ):

[snip]

I tried adding the path where the .o/.so file is located in the -Fl path of the Compiler Options.

You should not put .o files into library directories. You should use the ar command to build a library and put the resulting .a file into you library directory.

E.g.,

ar -crs libsomething.a something.o

Then put libsomething.a into /usr/local/lib; then use ldconfig (or SuSEconfig if you're using SuSE linux) to refresh the ld cache.

This is documented in man 1 ar.
- --
Regards,

Dave [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAlbJ9q8ACgkQogYgcI4W/5SJlgCgrNzNvYxYDBnyWT+AJyIVQjc2 qYUAoMzNBJ7OCWnyAbSmk71qxcMk05kL
=85Ws
-----END PGP SIGNATURE-----

Reply by email

Giuliano Colla
to David W Noon

Il 21/02/2016 18:41, David W Noon ha scritto:

Show quoted text 7 lines
You should not put .o files into library directories. You should use the ar command to build a library and put the resulting .a file into you library directory. E.g., ar -crs libsomething.a something.o

Thanks a lot. I wasn't aware that I must prepend *lib* to the library name. Just renaming my link to something.so into libsomething.so did the trick!

Giuliano

Reply by email