2
我正在運行fedora 23,剛剛編譯安裝了casadi 2.4.1(不過,我不認爲這是casadi特定的)。叮噹與gcc之間的區別
我試圖編譯和運行一個簡單的測試程序:
#include <iostream>
#include <casadi/casadi.hpp>
using namespace casadi;
int main() {
const SX m(42);
const SX n(23);
const SX x = m + n ;
std::cout << x << std::endl;
}
它工作正常用gcc:
$ g++ test.cpp -std=c++11 -I$HOME/local/include -L$HOME/local/lib -lcasadi && ./a.out
SX(65)
但使用鐺,我得到一個鏈接錯誤:
$ clang++ test.cpp -std=c++11 -I$HOME/local/include -L$HOME/local/lib -lcasadi && ./a.out
/tmp/test-cde41f.o: In function `casadi::GenericMatrix<casadi::Matrix<casadi::SXElement> >::dimString() const':
test.cpp:(.text._ZNK6casadi13GenericMatrixINS_6MatrixINS_9SXElementEEEE9dimStringEv[_ZNK6casadi13GenericMatrixINS_6MatrixINS_9SXElementEEEE9dimStringEv]+0x2b): undefined reference to `casadi::Sparsity::dimString() const'
/tmp/test-cde41f.o: In function `void casadi::Sparsity::set<casadi::SXElement>(casadi::SXElement*, casadi::SXElement const*, casadi::Sparsity const&) const':
test.cpp:(.text._ZNK6casadi8Sparsity3setINS_9SXElementEEEvPT_PKS3_RKS0_[_ZNK6casadi8Sparsity3setINS_9SXElementEEEvPT_PKS3_RKS0_]+0x6f0): undefined reference to `casadi::Sparsity::dimString() const'
test.cpp:(.text._ZNK6casadi8Sparsity3setINS_9SXElementEEEvPT_PKS3_RKS0_[_ZNK6casadi8Sparsity3setINS_9SXElementEEEvPT_PKS3_RKS0_]+0x743): undefined reference to `casadi::Sparsity::dimString() const'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我相當有信心,符號是定義在th電子圖書館。但是,我不明白在這裏失蹤了什麼鏗鏘聲。是否有一些特殊的C++ 11 ABI標誌需要傳遞給鏈接器或類似的東西?