libnl 3 (netlink library) referencia no definida a nl * y genl *

Estoy tratando de comstackr un código fuente escrito aquí , que activa el escaneo activo de Wi-Fi en el espacio del usuario.

Requiere una biblioteca de sudo apt-get install libnl-3-dev libnl-genl-3-dev , así que he hecho sudo apt-get install libnl-3-dev libnl-genl-3-dev

Y para comstackr, gcc $(pkg-config --cflags --libs libnl-3.0 libnl-genl-3.0) scan_access_points.c , que es idéntico a gcc -I/usr/include/libnl3 -lnl-genl-3 -lnl-3 scan_access_points.c

Pero la comstackción falla con números de undefined reference to 'SOMETHING' . El registro está abajo y puedes verlo aquí .

 /tmp/ccTQB59P.o: In function `family_handler': scan_access_points.c:(.text+0xc8): undefined reference to `nlmsg_hdr' scan_access_points.c:(.text+0xd0): undefined reference to `nlmsg_data' scan_access_points.c:(.text+0xe5): undefined reference to `genlmsg_attrlen' scan_access_points.c:(.text+0xf8): undefined reference to `genlmsg_attrdata' scan_access_points.c:(.text+0x114): undefined reference to `nla_parse' scan_access_points.c:(.text+0x133): undefined reference to `nla_data' scan_access_points.c:(.text+0x146): undefined reference to `nla_len' scan_access_points.c:(.text+0x160): undefined reference to `nla_len' scan_access_points.c:(.text+0x171): undefined reference to `nla_data' scan_access_points.c:(.text+0x18d): undefined reference to `nla_parse' scan_access_points.c:(.text+0x1ad): undefined reference to `nla_len' scan_access_points.c:(.text+0x1c3): undefined reference to `nla_data' scan_access_points.c:(.text+0x1e3): undefined reference to `nla_get_u32' scan_access_points.c:(.text+0x207): undefined reference to `nla_next' scan_access_points.c:(.text+0x225): undefined reference to `nla_ok' /tmp/ccTQB59P.o: In function `nl_get_multicast_id': scan_access_points.c:(.text+0x266): undefined reference to `nlmsg_alloc' scan_access_points.c:(.text+0x285): undefined reference to `nl_cb_alloc' scan_access_points.c:(.text+0x2b2): undefined reference to `genl_ctrl_resolve' scan_access_points.c:(.text+0x2eb): undefined reference to `genlmsg_put' scan_access_points.c:(.text+0x318): undefined reference to `nla_put' scan_access_points.c:(.text+0x334): undefined reference to `nl_send_auto_complete' scan_access_points.c:(.text+0x367): undefined reference to `nl_cb_err' scan_access_points.c:(.text+0x389): undefined reference to `nl_cb_set' scan_access_points.c:(.text+0x3ab): undefined reference to `nl_cb_set' scan_access_points.c:(.text+0x3c0): undefined reference to `nl_recvmsgs' scan_access_points.c:(.text+0x3e0): undefined reference to `nl_cb_put' scan_access_points.c:(.text+0x3ec): undefined reference to `nlmsg_free' /tmp/ccTQB59P.o: In function `callback_trigger': scan_access_points.c:(.text+0x628): undefined reference to `nlmsg_hdr' scan_access_points.c:(.text+0x630): undefined reference to `nlmsg_data' /tmp/ccTQB59P.o: In function `callback_dump': scan_access_points.c:(.text+0x6d1): undefined reference to `nlmsg_hdr' scan_access_points.c:(.text+0x6d9): undefined reference to `nlmsg_data' scan_access_points.c:(.text+0x6f4): undefined reference to `genlmsg_attrlen' scan_access_points.c:(.text+0x70a): undefined reference to `genlmsg_attrdata' scan_access_points.c:(.text+0x729): undefined reference to `nla_parse' scan_access_points.c:(.text+0x769): undefined reference to `nla_parse_nested' scan_access_points.c:(.text+0x7bc): undefined reference to `nla_data' scan_access_points.c:(.text+0x7f3): undefined reference to `nla_get_u32' scan_access_points.c:(.text+0x813): undefined reference to `nla_len' scan_access_points.c:(.text+0x824): undefined reference to `nla_data' /tmp/ccTQB59P.o: In function `do_scan_trigger': scan_access_points.c:(.text+0x8a5): undefined reference to `nl_socket_add_membership' scan_access_points.c:(.text+0x8aa): undefined reference to `nlmsg_alloc' scan_access_points.c:(.text+0x8ce): undefined reference to `nlmsg_alloc' scan_access_points.c:(.text+0x8ef): undefined reference to `nlmsg_free' scan_access_points.c:(.text+0x903): undefined reference to `nl_cb_alloc' scan_access_points.c:(.text+0x924): undefined reference to `nlmsg_free' scan_access_points.c:(.text+0x930): undefined reference to `nlmsg_free' scan_access_points.c:(.text+0x970): undefined reference to `genlmsg_put' scan_access_points.c:(.text+0x984): undefined reference to `nla_put_u32' scan_access_points.c:(.text+0x99f): undefined reference to `nla_put' scan_access_points.c:(.text+0x9b4): undefined reference to `nla_put_nested' scan_access_points.c:(.text+0x9c0): undefined reference to `nlmsg_free' scan_access_points.c:(.text+0x9e2): undefined reference to `nl_cb_set' scan_access_points.c:(.text+0x9ff): undefined reference to `nl_cb_err' scan_access_points.c:(.text+0xa21): undefined reference to `nl_cb_set' scan_access_points.c:(.text+0xa43): undefined reference to `nl_cb_set' scan_access_points.c:(.text+0xa64): undefined reference to `nl_cb_set' scan_access_points.c:(.text+0xa7e): undefined reference to `nl_send_auto' scan_access_points.c:(.text+0xab4): undefined reference to `nl_recvmsgs' scan_access_points.c:(.text+0xaeb): undefined reference to `nl_geterror' scan_access_points.c:(.text+0xb1c): undefined reference to `nl_recvmsgs' scan_access_points.c:(.text+0xb51): undefined reference to `nlmsg_free' scan_access_points.c:(.text+0xb5d): undefined reference to `nl_cb_put' scan_access_points.c:(.text+0xb6e): undefined reference to `nl_socket_drop_membership' /tmp/ccTQB59P.o: In function `main': scan_access_points.c:(.text+0xb94): undefined reference to `nl_socket_alloc' scan_access_points.c:(.text+0xba4): undefined reference to `genl_connect' scan_access_points.c:(.text+0xbba): undefined reference to `genl_ctrl_resolve' scan_access_points.c:(.text+0xbfb): undefined reference to `nlmsg_alloc' scan_access_points.c:(.text+0xc35): undefined reference to `genlmsg_put' scan_access_points.c:(.text+0xc49): undefined reference to `nla_put_u32' scan_access_points.c:(.text+0xc6a): undefined reference to `nl_socket_modify_cb' scan_access_points.c:(.text+0xc7d): undefined reference to `nl_send_auto' scan_access_points.c:(.text+0xca0): undefined reference to `nl_recvmsgs_default' scan_access_points.c:(.text+0xcaf): undefined reference to `nlmsg_free' scan_access_points.c:(.text+0xcc1): undefined reference to `nl_geterror' collect2: error: ld returned 1 exit status 

No tengo idea de cómo podría resolver este problema. ¿Alguien puede darme una solución o una pequeña pista para esto?

La comstackción se ha realizado en Ubuntu 14.04 LTS (kernel: 3.13.0-43-generic)

Las bibliotecas en las que se vincula, los argumentos -lnl-genl-3 -lnl-3, deben aparecer después del código que lo usa en la línea de comandos.

Lo que en su caso se puede hacer más fácil con, por ejemplo:

  gcc scan_access_points.c $(pkg-config --cflags --libs libnl-3.0 libnl-genl-3.0)