C ++对析构函数的未定义引用 [英] c++ undefined reference to destructor

查看:286
本文介绍了C ++对析构函数的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,但是我要重新打开它。在对本征误差进行分类之后,它又重新恢复了原样。完全相同的代码完全相同的错误。 (好吧,编译器这次找到了特征头。)因此,同样的问题:

Sorry about this, but I am re-opening this. After sorting the eigen errors, this cropped right back up again. Exactly the same code exactly the same error. (well, the compiler found the eigen headers this time.) So, same question:

我已经搜索了析构函数c ++,并且未定义的引用没有用。但是我很确定这是我的一个简单的疏忽。

I have searched for destructor c++ and undefined reference to no avail. However I am pretty sure this is a fairly simple slip on my part.

/tmp/ccDsaJ9v.o: In function `main':
geomSetup.cpp:(.text+0x5ab): undefined reference to `SASAGeometry::~SASAGeometry()'
geomSetup.cpp:(.text+0x5cd): undefined reference to `SASAGeometry::~SASAGeometry()'
collect2: ld returned 1 exit status
make: *** [geomTest] Error 1



SASAGeometry.h:



SASAGeometry.h:

class SASAGeometry
{
public:
//methods
  SASAGeometry() ;
  int makeFromFiles(char *, char *, char *) ;
  ~SASAGeometry() ;
//globals
  std::list<E......};



SASAGeometry.cpp



SASAGeometry.cpp

SASAGeometry::SASAGeometry(){}

int SASAGeometry::makeFromFiles(char * xyz_file, char * dat_file, char * atoms_file)
{
  sasa_transformMatrix basisMaker ;
  list<Vect...
...
}

SASAGeometry::~SASAGeometry(){}



geomTest.cpp



geomTest.cpp

int main(int argv, char * argc[])
{
  list<Vector3d>::iterator listIterator ;
  char * xyz_file = argc[1] ;
  char * dat_file = argc[2] ;
  char * atoms_file = argc[3] ;
  SASAGeometry geomMaker ;
  int geomErr....

...
return 0 ;
}



makefile:



makefile :

# compiler choice
CXX = g++

# executable path
BIN = .

# include paths (or lack thereof :p)
INCLUDE = -I .

# compilation flags
CXXFLAGS = -pipe # -O6

# linking flags
LFLAGS = -lm

# object declarations
GeomTest_OBJS = geomTest.o SASAGeometry.o

geomTest_source     = SASAGeometry.cpp SASAGeometry.h sasa_transformMatrix.cpp sasa_transformMatrix.h geomSetup.cpp

SASAGeometry.o  :   SASAGeometry.cpp SASAGeometry.h sasa_transformMatrix.cpp sasa_transformMatrix.h

geomTest.o  :   geomSetup.cpp SASAGeometry.o

# compile 
geomTest    : $(GeomTest_OBJS) makefile
            $(CXX) -o geomTest.o -o SASAGeometry.o $(LIBS) $(INCLUDE) $(CXXFLAGS) $(geomTest_source) $(LFLAGS)
            $(CXX) $(LIBS) $(INCLUDE) $(CXXFLAGS) -o $(BIN)/geomTest geomTest.o SASAGeometry.o $(LFLAGS)

clean       : \rm *.o *~ p1

我的INCLUDE和LIBS标志都可以,SASAGeometry类中的所有其他方法都定义得很愉快。

My INCLUDE and LIBS flags are all ok, all other methods in the SASAGeometry class are quite happily defined.

预先感谢。

推荐答案

makefile中不包含 SASAGeometry.cpp 以及 geomTest.cpp 。 makefile应该是这样的:

You are not including SASAGeometry.cpp in makefile along with geomTest.cpp. makefile should be something like this:

geomTest    : $(GeomTest_OBJS) makefile
            $(CC) -o geomTest.o -o SASAGeometry.o $(LIBS) $(INCLUDE) $(CFLAGS) $(geomTest_source) $(LFLAGS)
            $(CC) $(LIBS) $(INCLUDE) $(CFLAGS) -o $(BIN)/geomTest geomTest.o $(LFLAGS)

这篇关于C ++对析构函数的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆