0

I'm trying to compile and link some C code with gcc. My codes use a library called gsl which i want to link statically.

I can compile and link my code with precompiled library located in usr/lib. but i'm trying to link it only with only needed object files from the library. library uses inline functions in header files, which these header files are included in my object files but my own code.

While linking those object files, i get undefined reference to those inline files.

I do compile with:

gcc file.c -c -std=c99 -DHAVE_INLINE -DHAVE_CONFIG_H -I/usr/include/gsl

I have actually tested with -std=c99 and -std=gnu90 both. (I have compiled all files ( my own and object files ) with same standard.

and link with:

gcc ownfile.o lib.a libgslcblas.a -lm

which lib.a is containing all object files needed for my own code.

Mateen Ulhaq
  • 24,552
  • 19
  • 101
  • 135
  • 1
    Please add the actual error message. – Jens Apr 03 '16 at 04:58
  • Can you post example code explaining this: "library uses inline functions in header files, which these header files are included in my object files but my own code"? I don't understand what that sentence means. – Michael Burr Apr 03 '16 at 05:02
  • Micheal Burr, i actually cannot but i mean, i have written a.c and included b.h, and c.c has implemented b.h, i have not included d.h but c.c has included d.h. – Shayesteh.hamid Apr 05 '16 at 06:11

0 Answers0