DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 15th July 2008
kasse kasse is offline
Fdisk Soldier
 
Join Date: Jun 2008
Posts: 67
Thanked 0 Times in 0 Posts
Default What include and shared library directories are searched by gcc

Hello I have a question concerning gcc with f2c files and where gcc looks for include and shared library directories. Perhaps this should be in the programming section but since the problem only occurs in freebsd and I did not intend to do programming, I hope that I can ask it here.
The problem is that I want to compile foo.c which is the output from f2c program. The makefile make.sh is as follows
Code:
 gcc -03 -o oscillator oscillator.c -lf2c -lm
but gcc complains that it cannot find the f2c.h so I look up where f2c.h is
Code:
 /usr/local/inclucde
and change the make file to
Code:
 gcc -03 -o oscillator oscillator.c -I/usr/local/include -lf2c -lm
then in complains that it cannot find lf2c so I check with
Code:
 ldconfig -r | grep lf2c
and I get
Code:
 531:-lf2c.2 => /usr/local/lib/libf2c.so.2
and I change the makefile to
Code:
gcc -03 -o oscillator oscillator.c -I/usr/local/include -L/usr/local/lib -lf2c -lm
and now it compiles.
So my question are
1)why gcc does not look in the /usr/local for include files and why if ldconfig had lf2c linked why did gcc not find the file.
2) how can I change so that gcc looks for include and library files in /usr/local
3) Is the gcc in /usr/bin the same as /usr/local/gccXX, what I can see it is not a link
Reply With Quote
  #2   (View Single Post)  
Old 15th July 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Cool

Code:
Terry@dixie$ gcc -v -E -                                                  15:26
Using built-in specs.
Target: i386-undermydesk-freebsd
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 4.2.1 20070719  [FreeBSD]
 /usr/libexec/cc1 -E -quiet -v -D_LONGLONG - -std=c99 -Wall -W -Wpointer-arith -Wbad-function-cast
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
End of search list.
^C
Terry@dixie$                                                              15:27

Why *should* the system compiler search anything but the system headers and libraries by default ?


Like most decent compilers and some indecent ones gcc can be told to append items to it's search paths.

Code:
gcc -I/usr/local/include -L/usr/local/lib -lX11 xlib_test.c -o test
If I want to use a third party library without explicitly telling the compiler where to find your files set the LIBRARY_PATH and (LANG)_INCLUDE_PATH environment variables as stated in the gcc manual.

where (LANG) is C, CPLUS, OBJC, and so on.


NOTE:


ensuring the correctness and secure implementation of third party libraries is not a core concern of the FreeBSD project when compared to system libraries.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #3   (View Single Post)  
Old 16th July 2008
kasse kasse is offline
Fdisk Soldier
 
Join Date: Jun 2008
Posts: 67
Thanked 0 Times in 0 Posts
Default

Thank you for your reply.
So I guess that /usr/local/include /usr/local/lib should not be searched by the preprocessor and linker.
I think I was confused since it was mentioned as the default in the configuration of gcc via --with-local-prefix=dirname and some post mentioned that it could be changed post installation in make.conf.
It probably worked smoother in ubunto since the package manager put the f2c things in /usr/lib and /usr/include.
Reply With Quote
  #4   (View Single Post)  
Old 16th July 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

I wouldn't be familiar with gcc's installation/initial configuration phases. I have little use for any operating system that does not include a C Compiler by default :-)


Various Linux Distros tend to place things where ever they like. But on FreeBSD, everything that doesn't come with the system gets stuffed into /usr/local/ instead of /usr/, with few exceptions (e..g grub if installed)
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
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
Shared object not found 'libwrap.so.4' magic FreeBSD General 3 22nd July 2009 09:36 PM
Is /usr/X11R6/include/ supposed to be in $CPATH kasse OpenBSD General 4 3rd December 2008 05:34 PM
shared libraries and linux emulation Business_woman FreeBSD General 4 16th November 2008 10:03 AM
/usr/local and application directories ducu_00 FreeBSD Ports and Packages 14 23rd May 2008 05:37 PM
Home directories suddenly missing in Samba Dagoles FreeBSD General 4 22nd May 2008 12:50 AM


All times are GMT. The time now is 05:37 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick