Libevent compile error Ubuntu
-
Hey Leute,
ich hab ein kleines problem.... Ich versuch grade eines der example programme von Libevent zu compilieren doch bekomme immer diesen error:matata_tcp.cpp: In function ‘void listener_cb(evconnlistener*, int, sockaddr*, int, void*)’: matata_tcp.cpp:92: error: invalid conversion from ‘void*’ to ‘event_base*’ matata_tcp.cpp: In function ‘void signal_cb(int, short int, void*)’: matata_tcp.cpp:135: error: invalid conversion from ‘void*’ to ‘event_base*’
mein compile befehl ist dieser:
gcc -levent matata_tcp.cpp -o matata_tcpIch hab libevent nach diesem guide installiert:
http://www.geeksww.com/tutorials/operating_systems/linux/installation/how_to_install_libevent_on_debianubuntucentos_linux.phphabs auch schon mit dem Ubuntus aptitude versucht kommt aber das gleiche bei raus.
Wisst ihr woran das liegen kann?
-
Manner schrieb:
Ich hab libevent nach diesem guide installiert:
http://www.geeksww.com/tutorials/operating_systems/linux/installation/how_to_install_libevent_on_debianubuntucentos_linux.phpWozu? Ist doch ohnehin als halbwegs aktuelles Paket verfuegbar. Das hier funktioniert bei mir (Ubuntu 12.10):
sudo aptitude install libevent-dev wget https://raw.github.com/libevent/libevent/master/sample/hello-world.c gcc -o hello-world hello-world.c -levent
-
Ich glaub mein fehler war das mein code *.cpp hieß dadurch hat der compiler was versaut....
Jetz hab ich es in *.c umbenannt und jetz bekomm ich ne viel schlimmeren error:
/usr/bin/ld: /tmp/ccCTFACu.o: in function main:hello-world.c(.text+0xce): error: undefined reference to 'evconnlistener_new_bind' /usr/bin/ld: /tmp/ccCTFACu.o: in function main:hello-world.c(.text+0x137): error: undefined reference to 'event_new' /usr/bin/ld: /tmp/ccCTFACu.o: in function main:hello-world.c(.text+0x1a1): error: undefined reference to 'evconnlistener_free' /usr/bin/ld: /tmp/ccCTFACu.o: in function main:hello-world.c(.text+0x1ad): error: undefined reference to 'event_free' /usr/bin/ld: /tmp/ccCTFACu.o: in function listener_cb:hello-world.c(.text+0x204): error: undefined reference to 'bufferevent_socket_new' /usr/bin/ld: /tmp/ccCTFACu.o: in function conn_writecb:hello-world.c(.text+0x2c1): error: undefined reference to 'bufferevent_get_output' /usr/bin/ld: /tmp/ccCTFACu.o: in function conn_writecb:hello-world.c(.text+0x2cf): error: undefined reference to 'evbuffer_get_length' collect2: ld returned 1 exit status
Weiß einer was damit anzufangen?
-
Habs gelöst musste nur die Flags bestimmen
gcc -I/usr/local/include -L/usr/local/lib -levent matata_tcp.c -o matata_tcp
-
Wenn das Ding bei dir nicht an einem Standardort liegt, nimmm einfach pkg-config, das spuckt dir mit --cflags bzw. --libs die richtigen Compiler- und Linkeroptionen aus.