简体   繁体   English

在Xcode 4中链接和编译犰狳

[英]Linking and compiling armadillo in Xcode 4

I am a Mac OS X 10.8.3 user (Mountain Lion). 我是Mac OS X 10.8.3用户(Mountain Lion)。 I have download armadillo and installed it in OS X as per README.txt instructions. 我已经下载了犰狳,并按照README.txt的说明将其安装在OS X中。 It compiles fine by typing: 通过键入以下命令可以正常编译:

g++ ... *stuff* ... -O2 -larmadillo

in the terminal. 在终端。 By including the same linker arguments in Eclipse CDT, I have been able to compile armadillo in Eclipse (Juno) in OS X. However, my problem is when it comes to compiling in Xcode 4 -- the program I need to have armadillo in! 通过在Eclipse CDT中包含相同的链接器参数,我已经能够在OS X的Eclipse(Juno)中编译armadillo。但是,我的问题是要在Xcode 4中进行编译-我需要在其中添加犰狳! I have already tried adding the "-O2 -larmadillo" string to the other linker flags. 我已经尝试过将“ -O2 -larmadillo”字符串添加到其他链接器标志中。 I also tried adding /usr/local/lib and /usr/local/include/ in Header Search Paths and Library Search Paths. 我还尝试在标题搜索路径和库搜索路径中添加/ usr / local / lib和/ usr / local / include /。 I have gotten Xcode 4 to thus recognize the command: 我已经获得了Xcode 4从而可以识别命令:

# include < armadillo >

or 要么

# include "/usr/local/include/armadillo"

HOWEVER, when it comes to compile time Xcode 4 does NOT recognize a line like: 但是,在编译时,Xcode 4无法识别如下行:

mat A; 垫子A;

So for the code: 因此,对于代码:

# include < iostream >

# include < armadillo >

using namespace std;

int main() {

    mat A;

    return 0;

}

I get errors like: 我收到如下错误:

Use of undeclared identifier 'mat'; 使用未声明的标识符“ mat”; did you mean 'max'? 你是说“最大”吗?
Expected ';' 预期为“;” after expression 表达后
Use of undeclared identifier 'A' 使用未声明的标识符“ A”

Reference to overloaded function could not be resolved; 对重载函数的引用无法解析; did you mean to call it? 你是说打电话吗

Note that the code does not even get to the compile stage! 请注意,代码甚至还没有进入编译阶段!

I would like to now : how do I properly link and compile a C++ code which uses the armadillo library in Xcode 4??? 我现在想知道:如何正确链接和编译使用Xcode 4中armadillo库的C ++代码?

Thank you very much! 非常感谢你!

Daniel. 丹尼尔

did you forget to add "using namespace arma"? 您是否忘记添加“使用名称空间机制”? ie. 即。

# include <iostream>
# include <armadillo>

using namespace std;
using namespace arma;  // make Armadillo classes and functions visible by default

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM