This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Specifying include link flags


Hello,
I am trying to write functions that make use of the gsl (an external
library).  Because of this I was using the -I and -L gcc compiler flags to
tell the compiler the location of the gsl include and library files (I
don't have root permissions so this is the easiest way I could think of to
accomplish this).  I am also using the math library (default for gcc) for
functions like logb and scalbn.  When I write simpler code that doesn't
include gsl files the math functions are found fine.  However, when I do
try to use gsl files, I get the following warnings from the compiler:

warning: implicit decleration of function 'logb'
warning: implicit decleration of function 'scalbn'

When I link, I get very strange behavior from both of these functions (but
it does link).

To get around this problem I have tried using the -idirafter command
instead of the -I command.  To try and figure out what is going on I have
looked at the preprocesser output from both using the -E flag.  Sure
enough, in the simple example, logb and scalbn are defined, whereas in the
gsl example they aren't (however most other math functions are.)

At this point I would like to know what I am doing wrong and how I set
including and linking options so that I can use all the math and gsl
functions.  Perhaps I should be setting some enviroment variables?
Currently I am on an x86 running redhat 7.3.  Ideally I want math.h and
its sundry files to be included before the gsl files.

Right now I am using the following options to *try* and get my code to
compile:

gcc cfunctions.c -c -idirafter /h/44/abinkley/gsl/include/ -ansi -Wall
(compile)
gcc cfunctions.o $1.o -L/h/44/abinkley/gsl/lib/
-I/h/44/abinkley/gsl/include/ -lm -lgsl -lgslcblas  -ansi -Wall -o $1.out
(link, where $1.o is the file I am linking with)

I have attached three files, cfunctions.c, which defines one of the
functions I am trying to implement, prepro.txt, which is the preprocesser
output from this file, and prepros.txt which is the preprocessor output
from a (s)imple program which uses logb, but no gsl.

Thanks,
Andrew Binkley



Attachment: cfunctions.c
Description: Implementation complex abs (c code)

Attachment: prepro.txt
Description: Preprocessor output from cfunctions.c

Attachment: prepros.txt
Description: Preprocessor output from non-gsl code


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]