/ usr / bin / ld:/tmp/cc9zxSDP.o:未定义的符号引用

时间:2017-06-20 13:06:16

标签: c++ gcc ignite

编译.cc文件时遇到以下编译错误。我正在使用apache点燃库和c ++库来编译并指定了jdk路径。

#include <iostream>
#include "ignite/ignite.h"
#include "ignite/ignition.h"
using namespace ignite;
using namespace cache;

int main()
{
    IgniteConfiguration cfg;
    cfg.jvmInitMem = 512;
    cfg.jvmMaxMem = 512;
    cfg.springCfgPath = "/home/ignite/DataGridTest.xml";
    try
    {
        Ignite grid = Ignition::Start(cfg);

        std::cout << std::endl;
        std::cout << ">>> Cache put-get example started." << std::endl;
        std::cout << std::endl;

        Cache<int, int> cache = grid.GetCache<int, int>("mycache");

        cache.Clear();
        cache.Put(1, 1);
        int orgFromCache = cache.Get(1);

        std::cout <<  ">>> Retrieved value from cache: " << std::endl;
        std::cout << orgFromCache << std::endl;
        std::cout << std::endl;

        Ignition::StopAll(false);
    }
    catch (IgniteError& err)
    {
        std::cout << "An error occurred: " << err.GetText() << std::endl;
    }

    std::cout << std::endl;
    std::cout << ">>> Example finished, press 'Enter' to exit ..." << std::endl;
    std::cout << std::endl;

    return 0;
}

在命令行中:

gcc -I /usr/java/jdk1.8.0_131/include/ -I 
/usr/java/jdk1.8.0_131/include/linux/ -I 
$IGNITE_HOME/platforms/cpp/jni/include/ -I 
$IGNITE_HOME/platforms/cpp/core/include/ -I 
$IGNITE_HOME/platforms/cpp/common/os/linux/include/ -I 
$IGNITE_HOME/platforms/cpp/examples/include/ DataGridTest.cc -o DataGridTest -lignite

/usr/bin/ld: /tmp/cc9zxSDP.o: undefined reference to symbol '_ZN6ignite3jni4java12JniErrorInfoD1Ev'
/usr/local/lib//libignite-jni-2.0.0.19668.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

1 个答案:

答案 0 :(得分:1)

除了libignite,您还需要链接到libignite-binarylibignite-commonlibignite-jni