0

So I am writing a C file which includes /extfs/ext2fs.h. I am trying to call the function ext2fs_open(). I can clearly see that the header file ext2fs.h has that particular function. In fact, if I pass in the incorrect number of arguments, it even corrects me. However it does not compile, always giving me a "undefined reference" error. This problem lies with all the methods defined in the header file. How am I supposed to compile this file? Is there some library I need to link to?

Thank you.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Catie
  • 555
  • 5
  • 12
  • 23

1 Answers1

3

You do need to link to libext2fs, yes...

gcc -I/dir/containing/ext2fs.h -lext2fs your_source.c -o app
rid
  • 61,078
  • 31
  • 152
  • 193
  • Thankyou. I am still a little confused though. When you say app, you mean the executable file name I would want it to be right? If so, I couldn't run the command with the app. For instance my source code is myfile.c. I did: gcc -I/ext2fs/ext2fs.h -lext2fs myfile.c myfile -- but that did not work. I removed the myfile from the back and it compiled. However, I got an a.out file, what exactly is this? I want an executable file to run. – Catie May 28 '11 at 08:51
  • Sorry, my mistake. Updated answer. You need to use `-o myfile`. Also, put the full path to the *directory* in which the file `ext2fs.h` resides after the `-I` parameter, not the full path to the *file*. – rid May 28 '11 at 08:54