13eb5 [Solved] /usr/bin/ld: cannot find -lgcrypt - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Development > Userland Programming & Scripting

Userland Programming & Scripting C, Shell, Perl, Sed & Awk

Reply
 
Thread Tools Display Modes
  #1  
Old December 6th, 2010, 15:59
kenorb kenorb is offline
Member
 
Join Date: Oct 2010
Location: London
Posts: 330
Thanks: 57
Thanked 3 Times in 3 Posts
Default /usr/bin/ld: cannot find -lgcrypt

Code:
> 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
Reply With Quote
  #2  
Old December 6th, 2010, 16:02
kenorb kenorb is offline
Member
 
Join Date: Oct 2010
Location: London
Posts: 330
Thanks: 57
Thanked 3 Times in 3 Posts
Default

Test file from configure:
Code:
/* 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:
> 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
Reply With Quote
  #3  
Old December 6th, 2010, 16:17
SirDice's Avatar
SirDice SirDice is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 13,725
Thanks: 47
Thanked 2,023 Times in 1,862 Posts
Default

% 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.
Reply With Quote
The Following User Says Thank You to SirDice For This Useful Post:
kenorb (December 6th, 2010)
  #4  
Old December 6th, 2010, 16:19
kenorb kenorb is offline
Member
 
Join Date: Oct 2010
Location: London
Posts: 330
Thanks: 57
Thanked 3 Times in 3 Posts
Default

Sorry, the same:

Code:
> 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
Reply With Quote
  #5  
Old December 6th, 2010, 16:28
expl's Avatar
expl expl is offline
Member
 
Join Date: Oct 2009
Location: In your shell, stealing your cookies.
Posts: 639
Thanks: 0
Thanked 113 Times in 104 Posts
Default

It is -L/usr/local/lib/ not -L/usr/local/libs/
Reply With Quote
The Following User Says Thank You to expl For This Useful Post:
kenorb (December 6th, 2010)
  #6  
Old December 6th, 2010, 16:32
kenorb kenorb is offline
Member
 
Join Date: Oct 2010
Location: London
Posts: 330
Thanks: 57
Thanked 3 Times in 3 Posts
Default

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:
> 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

Last edited by kenorb; December 6th, 2010 at 16:43.
Reply With Quote
  #7  
Old December 6th, 2010, 16:33
SirDice's Avatar
SirDice SirDice is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 13,725
Thanks: 47
Thanked 2,023 Times in 1,862 Posts
Default

Oops.. Typo..
__________________
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
Reply With Quote
  #8  
Old December 6th, 2010, 16:41
expl's Avatar
expl expl is offline
Member
 
Join Date: Oct 2009
Location: In your shell, stealing your cookies.
Posts: 639
Thanks: 0
Thanked 113 Times in 104 Posts
Default

LD will not check 3rd party lib path (/usr/local/lib) only native library path (/usr/lib) by default.
Reply With Quote
  #9  
Old December 6th, 2010, 16:48
kenorb kenorb is offline
Member
 
Join Date: Oct 2010
Location: London
Posts: 330
Thanks: 57
Thanked 3 Times in 3 Posts
Default

Tried to made workaround by:
Code:
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/f...ne/001746.html

Quote:
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
Reply With Quote
  #10  
Old December 6th, 2010, 16:52
expl's Avatar
expl expl is offline
Member
 
Join Date: Oct 2009
Location: In your shell, stealing your cookies.
Posts: 639
Thanks: 0
Thanked 113 Times in 104 Posts
Default

Thats because you need libgcrypt.a for linking, libgcrypt.so.x is for dynamic loading.
Reply With Quote
  #11  
Old December 6th, 2010, 16:54
kenorb kenorb is offline
Member
 
Join Date: Oct 2010
Location: London
Posts: 330
Thanks: 57
Thanked 3 Times in 3 Posts
Default

My configure script solved as well by following LDFLAGS:
Code:
> ./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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
/usr/bin/ld: cannot find -ldl cell Porting New Software 8 February 14th, 2013 17:53
[Solved] /usr/bin/find: Argument list too long. Speedy Userland Programming & Scripting 3 October 29th, 2010 00:33
/etc/crontab and /usr/bin/mail TheGuyGuy General 6 July 20th, 2009 11:02
/usr/bin/ld: unrecognized option '-pthread' rocky Installation and Maintenance of FreeBSD Ports or Packages 2 May 21st, 2009 10:21
FreeBSD 7.1 and /usr/bin/script MadLord Userland Programming & Scripting 5 January 16th, 2009 15:26


All times are GMT +1. The time now is 17:50.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0