小编Dan*_*sin的帖子

出现未定义的参考错误,但 nm 显示符号存在

我正在使用 libkml 构建一个大型应用程序。我从这里使用 libkml 的 cmake 端口: https: //github.com/rashadkm/libkml

即使该符号似乎已被引用和定义,我仍收到奇怪的未定义符号引用错误。

这是 make 命令:

/usr/bin/c++ -fPIC -Werror=return-type -Werror=return-type -Wall 
-Werror=parentheses -Werror=uninitialized -Werror=missing-braces 
-fPIC -O0 -Wall -fPIC -fvisibility=hidden -fno-strict-aliasing 
-Wno-long-long -m64 -g -D_DEBUG --coverage -Wl,-Bsymbolic -Wl,--
no-undefined -shared -o GPS2KML.plb CMakeFiles/GPS2KML.dir
/gps.cpp.o CMakeFiles/GPS2KML.dir/kml.cpp.o CMakeFiles/GPS2KML.dir
/stdafx.cpp.o  /trunk/src/filter/GPS2KML/external/libkml/lib/cmake
/libkml/../../libkmlconvenience.so.1.3.1 /trunk/src/filter/GPS2KML
/external/libkml/lib/cmake/libkml/../../libkmlengine.so.1.3.1 
/trunk/src/filter/GPS2KML/external/libkml/lib/cmake/libkml/../..
/libkmldom.so.1.3.1 /trunk/src/filter/GPS2KML/external/libkml
/lib/cmake/libkml/../../libkmlbase.so.1.3.1 -lminizip -luriparser 
-lexpat
Run Code Online (Sandbox Code Playgroud)

制作输出:

CMakeFiles/GPS2KML.dir/kml.cpp.o: In function `cKML::~cKML()':
/trunk/src/filter/GPS2KML/src/kml.cpp:55: undefined reference to `*kmldom::SerializePretty(boost::intrusive_ptr<kmldom::Element> const&)*'
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

现在,如果我这样做: daniyal@daniyal-Inspiron-5521:/$ nm --demangle --extern-only --define-only ../trunk/src/filter/GPS2KML/external/libkml/lib/libkmldom.so | …

c++ makefile cmake kml ld

6
推荐指数
1
解决办法
4034
查看次数

复制构造函数中的递归调用

我按照三个规则实施了一个类,我遇到了崩溃.在调试时,我得出结论,复制构造函数反复调用自身而不是调用相等运算符.为什么会这样?它不应该调用相等运算符吗?

#include <iostream>
#include <deque>
#include <cstdlib>
#define LENGTH 128

typedef struct tDataStruct
{

char strA[LENGTH];

char strB[LENGTH];
int nNumberOfSignals;
double* oQueue;

tDataStruct()
{
    nNumberOfSignals = 0;
    //oQueue = NULL;
    memset(strA, 0, LENGTH);
    memset(strB, 0, LENGTH);
}

~tDataStruct()
{
    if (NULL != oQueue)
    {
        delete[] oQueue;
        oQueue = NULL;
    }
}

tDataStruct(const tDataStruct& other) // copy constructor
{
    if (this != &other)
    {
        *this = other;
    }

}
tDataStruct& operator=(tDataStruct other) // copy assignment
{
    if (this == &other)
    { …
Run Code Online (Sandbox Code Playgroud)

c++ copy-constructor rule-of-three copy-assignment

0
推荐指数
1
解决办法
293
查看次数