2015-10-17 3 views
0

Я запускаю omnet ++ 4.6 около 6 месяцев. Когда я пытался строить свой проект после того, как несколько изменений:Как исправить ошибки архитектуры x86_64?

  • удаление файла заголовка из проекта
  • добавляя больше файлов на свой включает в себя папку,

Я получаю эту ошибку

Creating shared library: ../out/gcc-debug/src/libinet.dylib 
    Undefined symbols for architecture x86_64: 
     "BloomFilter::BloomFilter(unsigned long, int, unsigned long, ...)", referenced from: 
      AODVRouting::AODVRouting() in AODVRouting.o 
      AODVRouting::AODVRouting() in AODVRouting.o 
    ld: symbol(s) not found for architecture x86_64 
    clang: error: linker command failed with exit code 1 (use -v to see invocation) 
    make[1]: *** [../out/gcc-debug/src/libinet.dylib] Error 1 
    make: *** [all] Error 2 

Мой проект использовался для создания и запуска до этого.

Это .cc файл:

#include "BloomFilter.h" 
#include <iostream> 
#include <cstring> 
#include <cstdlib> 
#include <climits> 
#include <cstdarg> 
#include <exception> 
#include <stdio.h> 
#include <string.h> 

using namespace std; 


#define SETBIT(a, n) (a[n/CHAR_BIT] |= (1<<(n%CHAR_BIT))) 
#define GETBIT(a, n) (a[n/CHAR_BIT] & (1<<(n%CHAR_BIT))) 


// The Constructor 
BloomFilter::BloomFilter(size_t size,int hash_k, size_t nfuncs, ...) { 


      va_list l; 
      unsigned int n; 

      try { 
      this->a=new char[(size+CHAR_BIT-1)/CHAR_BIT]; 
      } 
      catch(const std::exception& e) 
      { 
       // If we get here is that there is an allocation error . 
       // We must free the memory . 
      delete(this); 
      // std :: cerr << "ERROR: " << e.what() << endl; 
      // Then raise the exception to indicate that an error occurred. 
      throw; 
      } 


      try { 
        this->funcs= new hashfunc_t[nfuncs]; 
        } 
      catch(const std::exception& e){ 
      delete(this->a); 
      delete(this); 
       } 

      va_start(l, nfuncs); 
      for(n=0; n < nfuncs; ++n) { 
      this->funcs[n]=va_arg(l, hashfunc_t); 
      } 
      va_end(l); 

      this->nfuncs=nfuncs; 
      this->asize=size; 
      this->hash_k=hash_k; 

} 

// The Destructor 
BloomFilter::~BloomFilter() { 
     /* 
     delete(this->a); 
      delete(this->funcs); 
      delete(this); 
      */ 
} 

int BloomFilter::AddToBloom(std::string word){ 
    char t= '1'; 
    int AddFlag; // to know if the element is added successfully 
    for(int i=0;i<this->hash_k;i++){ 
     AddFlag=Add(word += t); 
       t++; 
    } 
    return AddFlag; 
} 


int BloomFilter::Add(std::string word){ 
     size_t size = word.size() + 1; 
     char * buffer = new char[ size ]; 
     strncpy(buffer, word.c_str(), size); 

     return Add(buffer); 
} 

int BloomFilter::Add(const char *s) 
{ 
    size_t n; 

    for(n=0; n<this->nfuncs; ++n) { 
    SETBIT(this->a, this->funcs[n](s)%this->asize); 
    } 

    return 0; 
} 

int BloomFilter::CheckBloom(std::string word){ 

    int CheckFlag; 
    char t= '1'; 
     for(int i=0;i<this->hash_k;i++){ 
      if(!Check(word += t)) return 0; 
        t++; 
     } 
     return 1; 


} 
int BloomFilter::Check(std::string word){ 
     size_t size = word.size() + 1; 
     char * buffer = new char[ size ]; 
     strncpy(buffer, word.c_str(), size); 

     return Check(buffer); 
} 

int BloomFilter::Check(const char *s) 
{ 
    size_t n; 

    for(n=0; n< this->nfuncs; ++n) { 
    if(!(GETBIT(this->a, this->funcs[n](s)%this->asize))) return 0; 
    } 

    return 1; 
} 

//Print information about this object 
void BloomFilter::toString(){ 
     /*EV << "[BloomFilter] Hello, I am ready ? " << ready 
     <<" ; max entry :" << maxEntry << endl;*/ 
} 

Что исправить эту ошибку?

ответ

0

Я избавился от этой ошибки после копирования файлов .cc и .h из моего корневого проекта к проекту, над которым я работаю (в указанном каталоге). Я сделал это во время работы omnet ++ и в браузере проектов.

Я не уверен, как эта ссылка на проблему «линкер», но она определенно решила мою проблему.

0

Это компоновщик, а не ошибка компилятора C++. Вам, вероятно, придется добавить файл .o, сгенерированный из вас .cc-файла, в список объектов, которые связаны между собой, чтобы сформировать libinet.dylib

+0

Как это сделать? Что такое файл .o? @Rudi –

Смежные вопросы