Re: Fehler "undefined reference ... " trotz eingebundener Headerdatei

Udo Gerhards <[email protected]>
Newsgroups gmane.linux.suse.programming
Organization ...
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hmmm,

die Headerdatei wird aber in meinem Code bei "nw_device.h" mit eingebunden. 
Ich poste Euch hier mal den Auszug vom Code. Wäre super, wenn da mal jemand 
kurz drüberschauen könnte, ich komme leider nicht mehr weiter:

nw_standarts.h		=> enthält die Deklaration für die Templateklasse nw_queue

...
// Queue:      
template <class T> class nw_queue
	{
	private:
	int next;				// Offset auf das nächste, freie Element
	int current;				// Offset auf das aktuell zu lesende Element
	int max;				// Obergrenze, ab der wieder bei 0 angefangen wird
	T*  queue;				// Adresse auf Element-Vektor
	nw_action_result status;		// Status der Queue
	
	void free_queue();			// interne Routine zum Freigeben der Queue
	
	public:	
	// Konstruktoren und Destruktoren
	nw_queue(int );		
	nw_queue(const nw_queue<T> &);
	~nw_queue()		{ if (queue) free_queue();}
	
	// Operatoren
	nw_queue<T> & operator=(const nw_queue<T> & );		
	
	// weitere Funktionen
	T* Get() const;								// GET-Methode der Queue
	nw_action_result Put(const T*);						// PUT-Methode der Queue
	int Count()	
		{ 
		int count=(next<=current)?(next+max)-current:next-(current+1); 
		return count;						 	// COUNT-Methode
		};
	nw_action_result Status() const	{return status;}
	int freeClasses(void);
	};
...

nw_standarts.cpp => Implementierung von nw_queue

// NW_QUEUE

template<class T> nw_queue<T>::nw_queue(int top):max(top), next(0), 
current(0), status(NW_ACTION_OK)
	{
	queue = new T*[max];
	}
	
template<class T> nw_queue<T>::nw_queue(const nw_queue<T> & 
srcqueue):max(srcqueue.max), next(srcqueue.next), current(srcqueue.current), 
status(srcqueue.status)
	{
	queue = new T*[max];
	int i;
	for (i=0;i<max;i++)
		queue[i]=srcqueue.queue[i];
	}
	
template<class T> nw_queue<T> & nw_queue<T>::operator=(const nw_queue<T> & 
srcqueue)
	{
	// Alte queue freigeben
	
	if (queue)
		free_queue();
		
	// Neue Werte setzen;
	max=srcqueue.max;
	next=srcqueue.next;
	current=srcqueue.current;
	status=srcqueue.status;
	
	queue = new T*[max];
	int i;
	for (i=0;i<max;i++)
		queue[i]=srcqueue.queue[i];
	return *this;
	}
	
template<class T> T* nw_queue<T>::Get() const
	{
	T* ptr;

	if (current != next)
		{
		ptr=queue[current];
		current=(++current%max);
		status=NW_ACTION_OK;
		}
		else
			status=NW_QUEUE_EMPTY;
	return value;
	}
	
template<class T> nw_action_result nw_queue<T>::Put(const T* ptr)
	{
	if (next != current)
		{
		queue[next]=ptr;
		next=(++next%max);
		status=NW_ACTION_OK;
		return status;
		}
		else
			{
			status=NW_QUEUE_FULL;
			return status;
			}
	}
	
template<class T> void nw_queue<T>::free_queue(void)
	{
	delete [] queue;
	}
	
template <class T> int freeObjects(void)
	{
	int count=Count();
	if (next != current)
		for (int i=0; i<count; i++)
			{
			delete queue[next];
			next=(++next%max);
			}
	return count;
	}

nw_device.h => Deklaration von nw_device

...
#include "nw_standarts.h"		=> damit includiere ich die Deklaration von 
"nw_queue"
#include <mysql/mysql.h>
#include "nw_database.h"
...

und hier noch der Konstruktor und Kopierkonstruktor von nw_device, bei denen 
der Fehler durch den Linker gemeldet wird:

nw_device.cpp

...
nw_device::nw_device(char* device, char* net, char* mask, nw_sniff_count 
pcount, int hostmax):max_host(hostmax), err_result(0), packet_count(pcount), 
running(false)
	{
	database = new nw_database();
	hqueue=new hostqueue(max_host);
	
	int len=strlen(device);
	dev = new char[len+1];
	strcpy(device, dev);
	
	len=strlen(net);
	netaddr=new char[len+1];
	strcpy(netaddr, net);
	
	len=strlen(net);
	netmask=new char[len+1];
	strcpy(netmask, mask);
	
	errbuf = new char[PCAP_ERRBUF_SIZE];
	setCategory(NW_DEVICE);
	}
	
nw_device::nw_device(const nw_device & 
srcnw_device):max_host(srcnw_device.max_host), 
err_result(srcnw_device.err_result),  
packet_count(srcnw_device.packet_count), running(srcnw_device.running)
	{
	database = new nw_database(*(srcnw_device.database));	// Kopierkonstruktor
	hqueue=new hostqueue(*(srcnw_device.hqueue));		// Queue kopieren	
	
	int len=strlen(srcnw_device.dev);
	dev = new char[len+1];
	strcpy(dev, srcnw_device.dev);
	
	len=strlen(srcnw_device.netaddr);
	netaddr=new char[len+1];
	strcpy(netaddr, srcnw_device.netaddr);
	
	len=strlen(srcnw_device.netmask);
	netmask=new char[len+1];
	strcpy(netmask, srcnw_device.netmask);
	
	errbuf = new char[PCAP_ERRBUF_SIZE];
	strcpy(srcnw_device.errbuf, errbuf);
	setCategory(NW_DEVICE);
	}
...

Ich hoffe, es geht in Ordnung, soviel Code zu posten. Wenn jemand will, kann 
ich ihm auch mal alle Dateien zur Verfügung stellen, dann ist das ganze nicht 
so aus dem Zusammenhang gerissen.

Gruß + Danke

Udo

- -- 
- -------------------------------------------------------------------------------------------------
                                          Wir sind Bill Gates! 
Widerstand ist zwecklos! Sie werden assimiliert! Ihre Datenbestände werden den 
unseren hinzugefügt!
- -------------------------------------------------------------------------------------------------

- -- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFBYuHtw91zS84Ugh8RArHTAJwKAW8+g6kSqP6jW6WtESViSdastQCfWZD8
rgrgSWc+SGGm4hhzkqA3wtc=
=ibyt
-----END PGP SIGNATURE-----

-- 
Um die Liste abzubestellen, schicken Sie eine Mail an:
    [email protected]
Um eine Liste aller verfügbaren Kommandos zu bekommen, schicken
Sie eine Mail an: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.