C ++未定义符号:从共享库返回的NullPointerException错误

时间:2016-03-04 09:24:10

标签: c++

我的代码遇到了一些问题。共享库导致未定义的符号错误,我无法弄清楚。所有文件都在正确的位置,共享库成功构建,但在执行程序时,它返回下面的消息。

错误消息:

libsp.so: undefined symbol: _ZTIN4Poco20NullPointerExceptionE

从我所看到的问题是我使用的Poco标题。我从外部源获取的头文件应该全部工作,我相信错误是由我调用这些头文件引起的,但我可能错了。

Bellow是在libsp库中使用Poco的唯一代码。我使用的4个头文件的代码。我已经检查并重新检查,但找不到任何问题,但我仍然得到未定义的符号异常。

文件Spexec.cpp(libsp):

#include "../poco/Poco/Base64Encoder.h"
#include "../poco/Poco/DigestEngine.h"
#include "../poco/Poco/MD5Engine.h"
#include "../poco/Poco/Path.h"

using namespace std;

stringstream s_base;
Poco::Base64Encoder encoder(s_base);

Poco::Path path(data.name);
data.path = data.name.substr(0, data.name.length() - path.getFileName().length());

    Poco::MD5Engine md5;
    stringstream ss;

    ss << data.created << data.name;
    md5.update(ss.str());
    data.name = Poco::DigestEngine::digestToHex(md5.digest());
}

文件Base64Encoder.h:

#ifndef Foundation_Base64Encoder_INCLUDED
#define Foundation_Base64Encoder_INCLUDED
#include "Foundation.h"
#include <ostream>

namespace Poco {

class Foundation_API Base64Encoder:, public std::ostream
{
public:
    Base64Encoder(std::ostream& ostr);
    ~Base64Encoder();

private:
    Base64Encoder(const Base64Encoder&);
    Base64Encoder& operator = (const Base64Encoder&);
};
} // namespace Poco

#endif // Foundation_Base64Encoder_INCLUDED

File DigestEngine.h:

#ifndef Foundation_DigestEngine_INCLUDED
#define Foundation_DigestEngine_INCLUDED
#include "Foundation.h"
#include <vector>

namespace Poco {

class Foundation_API DigestEngine
{
public:
    typedef std::vector<unsigned char> Digest;

    DigestEngine();
    virtual ~DigestEngine();

    void update(const void* data, std::size_t length);
    void update(char data);
    void update(const std::string& data);
    virtual std::size_t digestLength() const = 0;
    virtual void reset() = 0;       
    virtual const Digest& digest() = 0;
    static std::string digestToHex(const Digest& bytes);
    static Digest digestFromHex(const std::string& digest);

presentation

protected:
    virtual void updateImpl(const void* data, std::size_t length) = 0;
private:
    DigestEngine(const DigestEngine&);
    DigestEngine& operator = (const DigestEngine&);
};

文件MD5Engine.h:

#ifndef Foundation_MD5Engine_INCLUDED
#define Foundation_MD5Engine_INCLUDED
#include "Foundation.h"
#include "DigestEngine.h"

namespace Poco {

class Foundation_API MD5Engine: public DigestEngine
{
public:
    enum
    {
        BLOCK_SIZE  = 64,
        DIGEST_SIZE = 16
    };

    MD5Engine();
    ~MD5Engine();

    std::size_t digestLength() const;
    void reset();
    const DigestEngine::Digest& digest();

protected:
    void updateImpl(const void* data, std::size_t length);

private:
    static void transform(UInt32 state[4], const unsigned char block[64]);
    static void encode(unsigned char* output, const UInt32* input, std::size_t len);
    static void decode(UInt32* output, const unsigned char* input, std::size_t len);

    struct Context
    {
        UInt32 state[4];          // state (ABCD)
        UInt32 count[2];          // number of bits, modulo 2^64 (lsb first)
        unsigned char buffer[64]; // input buffer
    };
    Context _context;
    DigestEngine::Digest _digest;
    MD5Engine(const MD5Engine&);
    MD5Engine& operator = (const MD5Engine&);
};
}

文件路径:

#ifndef Foundation_Path_INCLUDED
#define Foundation_Path_INCLUDED
#include "Foundation.h"
#include <vector>

namespace Poco {

class Foundation_API Path
{
public:
    enum Style
    {
        PATH_UNIX,    /// Unix-style path
        PATH_WINDOWS, /// Windows-style path
        PATH_VMS,     /// VMS-style path
        PATH_NATIVE,  /// The current platform's native style
        PATH_GUESS    /// Guess the style by examining the path
    };
    typedef std::vector<std::string> StringVec;
    Path();   
    Path(const char* path);
    Path(const std::string& path);

protected:
    void parseUnix(const std::string& path);
    void parseWindows(const std::string& path);
    void parseVMS(const std::string& path);
    void parseGuess(const std::string& path);
    std::string buildUnix() const;
    std::string buildWindows() const;
    std::string buildVMS() const;

private:
    std::string _node;
    std::string _device;
    std::string _name;
    std::string _version;
    StringVec   _dirs;
    bool        _absolute;
};

0 个答案:

没有答案