Reputation: 177
I'm really hopeless when it comes to Unix-like systems. I tried to download an open library to my Ubuntu system, so that I could use its functions in my own C code. However, now that I've downloaded the library, it came with a lot more than just .c and .h files. It has files like Makefile.am, Makefile.in, and folders like build and configure, and right now I'm trying to figure out what to make of all of this.
What is the "normal" way to include and make use of others libraries in your own programs?
Am I now supposed to use the make command to make some sort of .a archive file to use when compiling my own program? - something like this:
gcc myProgram.c theLibrary.a -o myProgram
or would the make command only make an executable out of everything and not include my code at all?
I already tried ignoring the other files and just copied over the .c and .h files I needed for my project. However, during compiling gcc complained that it couldn't find some config.h file that one of the .c files in the library includes. I searched through the whole library and no such file exists anywhere.
I'm so lost right now, and I have no idea what to search in Google either. If someone could just point me in the right direction I'd be really grateful.
If it matters at all the library I'm trying to use is libmpdclient.
Upvotes: 0
Views: 2163
Reputation: 75150
Usually when you download a linux program (or shared library, or...) you get the source code and are expected to compile it yourself. Usually, all you do is the following three things:
./configure
make
make install
(the make install
might require root privileges).
In the case of a shared library, presumably now the shared library file is installed in your /usr/lib
(or /usr/local/lib
or whatever) directory so you can link it in when you compile programs by doing -l libname
on the command line with gcc
.
Upvotes: 4
Reputation: 18111
Is there a README
or INSTALL
file in the top-level directory of the library you downloaded? If yes, look in there.
The typical procedure comes down to doing ./configure
, then make
, and then optionally make install
, but the library may have dependencies or other issues to consider that you will find out about in the files mentioned above.
Upvotes: 4