c++对析构函数的未定义引用
对此感到抱歉,但我要重新打开它。对特征误差进行排序后,它又重新出现了。完全相同的代码完全相同的错误。 (好吧,编译器这次找到了特征标头。)所以,同样的问题:
我搜索了析构函数 C++ 和未定义的引用,但无济于事。然而我很确定这对我来说是一个相当简单的失误。
错误:
/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:
class SASAGeometry
{
public:
//methods
SASAGeometry() ;
int makeFromFiles(char *, char *, char *) ;
~SASAGeometry() ;
//globals
std::list<E......};
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
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:
# 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 类中的所有其他方法都定义得很愉快。
提前致谢。
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:
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.
Error:
/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:
class SASAGeometry
{
public:
//methods
SASAGeometry() ;
int makeFromFiles(char *, char *, char *) ;
~SASAGeometry() ;
//globals
std::list<E......};
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
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 :
# 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
My INCLUDE and LIBS flags are all ok, all other methods in the SASAGeometry class are quite happily defined.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有将
SASAGeometry.cpp
与geomTest.cpp
一起包含在 makefile 中。 makefile 应该是这样的:You are not including
SASAGeometry.cpp
in makefile along withgeomTest.cpp
. makefile should be something like this: