/usr/bin/ld: cannot find -lgcrypt

C, C++, Python, Perl, Shell, etc.

/usr/bin/ld: cannot find -lgcrypt

Postby kenorb » 06 Dec 2010, 14:59

Code: Select all
> gcc -o conftest -I/usr/local/include conftest.c -lgcrypt
/usr/bin/ld: cannot find -lgcrypt
> ldconfig -r | grep gcrypt
   308:-lgcrypt.17 => /usr/local/lib/libgcrypt.so.17
   890:-lgcrypt.16 => /usr/local/lib/compat/pkg/libgcrypt.so.16
> ldd /usr/local/lib/libgcrypt.so.17
/usr/local/lib/libgcrypt.so.17:
   libgpg-error.so.0 => /usr/local/lib/libgpg-error.so.0 (0x800c00000)
   libintl.so.9 => /usr/local/lib/libintl.so.9 (0x800d04000)
   libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x800e0d000)
   libc.so.7 => /lib/libc.so.7 (0x800645000)
> pkg_info | grep gcrypt
libgcrypt-1.4.6     General purpose crypto library based on code used in GnuPG

Tried to reinstall libgcrypt, nothing.

Simply don't understand why FreeBSD don't allow me to compile simple code with -lgcrypt, even if it's installed and loaded.
> uname -a
FreeBSD kenorb 8.1-STABLE FreeBSD 8.1-STABLE #0: Tue Oct 19 15:28:55 BST 2010 root@kenorb:/usr/obj/usr/src/sys/BRO amd64
kenorb
Member
 
Posts: 330
Joined: 20 Oct 2010, 11:32
Location: London

Postby kenorb » 06 Dec 2010, 15:02

Test file from configure:
Code: Select all
/* confdefs.h */
#define PACKAGE_NAME "libimobiledevice"
#define PACKAGE_TARNAME "libimobiledevice"
#define PACKAGE_VERSION "1.0.4"
#define PACKAGE_STRING "libimobiledevice 1.0.4"
#define PACKAGE_BUGREPORT "nospam@nowhere.com"
#define PACKAGE_URL ""
#define PACKAGE "libimobiledevice"
#define VERSION "1.0.4"
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_DLFCN_H 1
#define LT_OBJDIR ".libs/"
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char gcry_control ();
int
main ()
{
return gcry_control ();
  ;
  return 0;
}


Code: Select all
> gcc -o blah -I/usr/local/include blah.c -lgcrypt
/usr/bin/ld: cannot find -lgcrypt
> uname -a
FreeBSD kenorb 8.1-STABLE FreeBSD 8.1-STABLE #0: Tue Oct 19 15:28:55 BST 2010 root@kenorb:/usr/obj/usr/src/sys/BRO amd64
kenorb
Member
 
Posts: 330
Joined: 20 Oct 2010, 11:32
Location: London

Postby SirDice » 06 Dec 2010, 15:17

% gcc -o blah -I/usr/local/include/ -L/usr/local/libs/ -lgcrypt blah.c
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16196
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands

Postby kenorb » 06 Dec 2010, 15:19

Sorry, the same:

Code: Select all
> gcc -o blah -I/usr/local/include/ -L/usr/local/libs/ -lgcrypt blah.c
/usr/bin/ld: cannot find -lgcrypt
> uname -a
FreeBSD kenorb 8.1-STABLE FreeBSD 8.1-STABLE #0: Tue Oct 19 15:28:55 BST 2010 root@kenorb:/usr/obj/usr/src/sys/BRO amd64
kenorb
Member
 
Posts: 330
Joined: 20 Oct 2010, 11:32
Location: London

Postby expl » 06 Dec 2010, 15:28

It is -L/usr/local/lib/ not -L/usr/local/libs/
User avatar
expl
Member
 
Posts: 664
Joined: 30 Oct 2009, 23:54
Location: In your shell, stealing your cookies.

Postby kenorb » 06 Dec 2010, 15:32

Does work, thank you:)
What I've to do to be visible by default?
Shouldn't ldconfig provide final list of available and working options?


Code: Select all
> gcc -print-search-dirs
install: /usr/libexec/
programs: =/usr/bin/:/usr/bin/:/usr/libexec/:/usr/libexec/:/usr/libexec/
libraries: =/usr/lib/:/usr/lib/
> gcc -v -lgcrypt
Using built-in specs.
Target: amd64-undermydesk-freebsd
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070719  [FreeBSD]
 /usr/bin/ld --eh-frame-hdr -V -dynamic-linker /libexec/ld-elf.so.1 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib -L/usr/lib -lgcrypt -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
GNU ld version 2.15 [FreeBSD] 2004-05-23
  Supported emulations:
   elf_i386_fbsd
   elf_x86_64_fbsd
/usr/bin/ld: cannot find -lgcrypt
> uname -a
FreeBSD kenorb 8.1-STABLE FreeBSD 8.1-STABLE #0: Tue Oct 19 15:28:55 BST 2010 root@kenorb:/usr/obj/usr/src/sys/BRO amd64
kenorb
Member
 
Posts: 330
Joined: 20 Oct 2010, 11:32
Location: London

Postby SirDice » 06 Dec 2010, 15:33

Oops.. Typo..
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16196
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands

Postby expl » 06 Dec 2010, 15:41

LD will not check 3rd party lib path (/usr/local/lib) only native library path (/usr/lib) by default.
User avatar
expl
Member
 
Posts: 664
Joined: 30 Oct 2009, 23:54
Location: In your shell, stealing your cookies.

Postby kenorb » 06 Dec 2010, 15:48

Tried to made workaround by:
Code: Select all
sudo ln -s /usr/local/lib/libgcrypt.so.17 /usr/lib/libgcrypt.so.17 && sudo ldconfig -R

But doesn't work as expected;/
Is there any FreeBSD version of ld.so.conf?

Found this:
http://lists.freebsd.org/pipermail/freebsd-hackers/2003-June/001746.html

During system startup ldconfig is passed the path set by "ldconfig_paths"
in /etc/defaults/rc.conf.

But gcc don't load that.
> uname -a
FreeBSD kenorb 8.1-STABLE FreeBSD 8.1-STABLE #0: Tue Oct 19 15:28:55 BST 2010 root@kenorb:/usr/obj/usr/src/sys/BRO amd64
kenorb
Member
 
Posts: 330
Joined: 20 Oct 2010, 11:32
Location: London

Postby expl » 06 Dec 2010, 15:52

Thats because you need libgcrypt.a for linking, libgcrypt.so.x is for dynamic loading.
User avatar
expl
Member
 
Posts: 664
Joined: 30 Oct 2009, 23:54
Location: In your shell, stealing your cookies.

Postby kenorb » 06 Dec 2010, 15:54

My configure script solved as well by following LDFLAGS:
Code: Select all
> ./configure LDFLAGS="-L/usr/local/lib/"
> uname -a
FreeBSD kenorb 8.1-STABLE FreeBSD 8.1-STABLE #0: Tue Oct 19 15:28:55 BST 2010 root@kenorb:/usr/obj/usr/src/sys/BRO amd64
kenorb
Member
 
Posts: 330
Joined: 20 Oct 2010, 11:32
Location: London


Return to Userland Programming & Scripting

Who is online

Users browsing this forum: No registered users and 1 guest