在带有脚本的原子中使用犰狳

Using armadillo in atom with script

我有办法在使用 armadillo 的 atom 中使用脚本编译 c++ 文件吗?我找不到与之相关的任何内容。

我已经安装了 armadillo 并尝试使用 atom 中的脚本编译一些基本代码:

#include <iostream>
#include <armadillo>

int main(int argc, const char **argv) {
  arma::arma_rng::set_seed_random();

  arma::Mat<double> A = arma::randu(4,4);
  std::cout << "A:\n" << A << "\n";

  return 0;
}

这是我得到的错误:

Undefined symbols for architecture x86_64:
  "thread-local wrapper routine for arma::arma_rng_cxx11_instance", referenced from:
      arma::arma_rng::set_seed(unsigned long long) in test1-83e853.o
      arma::arma_rng::randu<double>::fill(double*, unsigned long long) in test1-83e853.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

如果我正确阅读 source code for this atom-script thing,它只是将 -Wall -include stdio.h 硬编码为编译选项。您需要将 -larmadillo 到 link 添加到 Armadillo 库中。

简而言之:您不能将 atom-script 与自定义库结合使用,除非您编辑扩展以在编译命令行中对库进行硬编码。