I have a program which use libevent library
when compile the program, the compiling command is like:
gcc -o myprogram mysource.c mysource.h -levent
so it is dynamic linking.
now I want to run this program on a computer where there is no libevent, I need static linking so that my program can be run on that computer, are there any easy steps?
I tried -static
, but I got the following error:
[root@kitty relay]# gcc -o relay -static mysource.c mysource.h -levent -lpcap
/usr/bin/ld: cannot find -lpcap
/usr/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
why?
You should have libevent.a
. Then you can just gcc -o myprogram mysource.c libevent.a
.
Or try gcc -o myprogram -static mysource.c -levent
.
(And you probably shouldn't specify mysource.h
to gcc as it's most likely included into mysource.c with #include "mysource.h"
.)