[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [linux-team] Prob de librairies....



On Tue, Feb 22, 2000 at 10:27:23AM +0100, calculon@netcourrier.com wrote:
...
> c++ -O3 -mpentium -Wall -D_DEBUG_  libpcap-0.3/libpcap.a global.o interface.o host.o listener.o main.o -o test
> listener.o: In function `listener::listener(void)':
> listener.o(.text+0x2f): undefined reference to `pcap_open_live(char *, int, int, int, char *)'
> collect2: ld returned 1 exit status
> make: *** [all] Error 1
vérifie déjà que le symbole existe bien
nm -o libpcap-0.3/libpcap.a | grep pcap_open_live

...
> listener.h (en partie):
> 
> #include <iostream.h>
> #include <unistd.h>
> #include "pcap.h"
> #include "interface.h"
> ....
Essaye ceci:

#include <iostream.h>
#include <unistd.h>
extern "C" {
	#include "pcap.h"
	#include "interface.h"
}

-> mets les headers C dans le bloc extern "C"

...
> Heeeeeeeeeeeeeeeeeeeeeeeeeeellllp!!!
> je peux plus rien faire si ca ne marche pas!
> Je suis sur que c'est une connerie, mais je trouve pas de solution.
> J'ai deja essayé en installant libpcap.a dans toutes les dirs. standart
> (/usr/lib, /usr/local/lib) et en placant le fichier header en bonne 
> place, mais rien à faire!
C'est très probablement ça.
Dans le header pcap.h, il n'y certainement pas de extern "C".
Or, le linker, quand il linke des objets C++, gère les noms de symboles différemment
de lorsqu'il s'agit de symboles C. La directive extern "C" indique au compilateur que
les symboles à utiliser ont des noms suivant la convention C et pas C++.

-- 
  -o)  Pascal Bleser        |
  /\\  C++/UNIX Development | God is real, unless
 _\_v  ATOS Payment Systems | declared integer.
       Aachen, Germany      | 
<pbleser@atos-group.com>-------<guru@linuxbe.org>

---------
Visit the Linux Supertore Online: http://www.redcorp.com !
If you want to be deleted from the list, send a mail to
majordomo@rtfm.be with "unsubscribe linux-team" in the body.
Archive of the list: http://tania.be.linux.org/