3

While compiling my program which is using libevent library I am using gcc option -levent. But I am getting this error -

/usr/bin/ld: cannot find -levent

I do not have libevent on my system so I am statically linking to it while compiling using

gcc -o Hello -static -I libevent-1.4.12-stable/ hello.c -levent

How can i resolve this?

Thanks in advance!

AJ.
  • 2,561
  • 9
  • 46
  • 81

2 Answers2

6

Where is the libevent.(a|so) file on your system?

If it isn't on your system's library path then you will have to add a -L option adding its location to the list of paths searched by the linker for libraries.

e.g.

gcc -L/folder/containing/event/lib -levent mysource.cc
CB Bailey
  • 755,051
  • 104
  • 632
  • 656
  • I dont have libevent.(a|so). I am statically including libevent using gcc -o Hello -static -I libevent-1.4.12-stable/ hello.c -levent – AJ. Nov 12 '09 at 10:34
  • 2
    If you want to link against the library (statically or dynamically) you *need* the library. The static library should be called libevent.a. If that is in libevent-1.4.12-stable, then you should provide `-Llibevent-1.4.12-stable` to tell the linker to look there. – CB Bailey Nov 12 '09 at 11:00
0

You need to have the libevent on your system or need to specify its path explicitly (if its a third-party library you got with the headers).

I suspect its not in your default /lib paths.

nik
  • 13,254
  • 3
  • 41
  • 57