Reputation: 98906
This might be the most newbie question ever, but how do you compile a C program?
I’ve downloaded the source of a C program (ffmpeg, to be precise). How do I compile it?
Upvotes: 1
Views: 339
Reputation: 3082
to compile simple math program, it's not enough to <include math.h>. See
gcc file.c -lmath -o program_bin
for a single .c file using ffmpeg libraries, it can be made this way:
gcc -Wall -g live_segmenter.c -o live_segmenter -lavformat -lavcodec -lavutil -lbz2 -lm -lz -lfaac -lmp3lame -lx264 -lfaad -lpthread -I/home/devicer/ffmpeg/include -L/home/devicer/ffmpeg/lib
notice -L and -I options. In serious projects they are usually set by pkg-config.
for the ffmpeg itself.. - install lame, few other required libraries, then do as Chris said. Btw, sometimes it requires gmake, not make.
Also, have a look on
./configure --prefix /home/devicer/ffmpeg
This is what was mentioned (used for) in segmenter compilation above.
Upvotes: 1
Reputation: 96167
For a single file just cc file.c (or gcc or whatever you C compiler is called)
For a complex project like ffmpeg, then either make, cmake, configure some other. Check their documentation
Upvotes: 2
Reputation: 213170
It depends on what OS and compilers you have, but typically the sequence is:
$ ./configure
$ make
$ sudo make install
Upvotes: 1
Reputation: 223183
For most Unix-style C programs, the incantation is:
./configure
make
sudo make install
This should already be documented in the INSTALL
file, which additionally may contain further useful information.
Upvotes: 5