2017-06-20 77 views
1

我編譯.cc文件時遇到以下編譯錯誤。我正在使用apache ignite庫和C++庫進行編譯,並指定了jdk路徑。/usr/bin/ld:/tmp/cc9zxSDP.o:未定義的符號引用

#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 
+0

在'DataGridTest.cc'之前移動'-lignite' –

+0

我添加了-lignite-jni和更多的.so文件我鏈接了與點燃相關的內容,但是,僅僅爲它提供-lignite它不足以覆蓋所有.so文件作爲一個組成部分,如果點燃庫。 –

+0

你見過[this](https://stackoverflow.com/questions/19901934/strange-linking-error-dso-missing-from-command-line)嗎?確保你在目標文件之後添加庫。 – isapego

回答

0

libignite你還需要鏈接到libignite-binarylibignite-commonlibignite-jni