如何包括经济新闻。在OS X h ?

时间:2022-01-06 02:37:14

I'm new in C and have some problems compiling my code in OS X.

我是C的新手,在OS X中编译我的代码有一些问题。

I code Java a lot both in Eclipse and use terminal to compile my code. However now I'm learning openMP and have troubles with it.

我在Eclipse和use terminal中都编写了大量的Java代码来编译代码。但是现在我正在学习openMP,并且有问题。

First I downloaded Xcode to write openMP code but it didn't recognize <omp.h>. Then I installed g++. When I type g++ -v into terminal I get this:

首先,我下载了Xcode来编写openMP代码,但它不承认 。然后我g++安装。当我输入g++ -v到终端时,我得到这个:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix

But when I use g++ Mesh.cpp -fopenmp I still get

但是当我使用g++网格的时候。cpp -fopenmp,我还能得到。

Mesh.cpp:4:10: fatal error: 'omp.h' file not found
#include <omp.h>
         ^
1 error generated.

Then I tried to install PTP into my Eclipse and got the same problem. I thought there was no omp.h in my MacBook so I searched for it and found several omp.h under folders under gcc-4.9.1/build/.

然后我尝试在Eclipse中安装PTP,并遇到了同样的问题。我以为没有omp。在我的MacBook上,我搜索了一下,找到了几个omp。在gcc-4.9.1/build/的文件夹下。

Here comes the problem. Based on the Java experience the only reason why I have the file but cannot use it is that the Class Path is wrong. However, I have no idea how to change this configuration in g++, or in Xcode, or in Eclipse. But since I can include files like <stdio.h> and compile it with all the IDEs, how can't I do the same with <omp.h>?

问题来了。基于Java经验,我有文件但不能使用它的唯一原因是类路径是错误的。但是,我不知道如何在g++、Xcode或Eclipse中更改此配置。但是因为我可以包含像 ,用所有的ide编译它,我怎么不能用 呢? 。h> 。h>

Another thing I noticed is that the gcc folder version is 4.9.1, but when I type gcc -v into terminal I get the same with typing in g++ -v

另一件我注意到的事情是gcc的文件夹版本是4.9.1,但是当我把gcc -v输入到终端时,在g++ -v中输入的结果是一样的。

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix

Shouldn't the version information says something about 4.9.1? Just like what java -version shows

版本信息不应该是关于4.9.1的吗?就像java版本所显示的那样。

java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

Thanks for reading. Any help is appreciated.

感谢你的阅读。任何帮助都是感激。

3 个解决方案

#1


12  

GCC 4.9.1 normally does not ship with OS X (actually no GCC ships with Xcode any more). Yours must have been installed by another means, e.g. Homebrew or self compilation as described here. What you are probably missing is properly set PATH variable or the additionally installed compiler has version-suffixed binaries, i.e. gcc-4.9 or g++-4.9 instead of simply gcc / g++.

正常情况下,GCC 4.9.1不会使用osx(实际上没有任何GCC附带Xcode的船只)。您的程序必须通过另一种方式安装,如本文所述的自制程序或自编译。您可能缺少的是正确的设置路径变量,或者另外安装的编译器有版本后缀的二进制文件,即gcc-4.9或g++-4.9,而不是简单的gcc / g++。

As @rubenvb has already mentioned, Apple symlinks the Clang executables with GCC-like names. I personally find that a bad practice since recent Clang versions shipped with Xcode react on unrecognised command-line options (e.g. GCC frontend specific ones) with hard errors.

正如@rubenvb已经提到的那样,苹果将Clang的可执行文件与gcc类的名称联系起来。我个人认为,由于Xcode最近发布的Clang版本对未识别的命令行选项(例如GCC前端特定的选项)有错误的响应,这是一个糟糕的实践。

#2


10  

The gcc and g++ commands are not what you think they are with XCode: Apple thought it would be a good idea to masquerade Clang as GCC to make the transition smoother.

gcc和gc++命令并不是您认为的XCode: Apple认为将Clang化装成gcc是一个好主意,以使转换更加顺畅。

Clang OpenMP support is still being worked on. If I didn't miss any big release of the WIP code, you'll need to build this version of clang and use that.

Clang OpenMP支持仍在进行中。如果我没有错过WIP代码的任何大版本,您将需要构建这个版本的clang并使用它。

You can of course always install a real GCC through stuff like homebrew or macports, that will come with OpenMP support.

当然,您可以通过诸如homebrew或macports之类的东西来安装真正的GCC,这将伴随着OpenMP的支持。

#3


-1  

This command can help you

这个命令可以帮助你。

brew install libomp

酿造安装libomp

#1


12  

GCC 4.9.1 normally does not ship with OS X (actually no GCC ships with Xcode any more). Yours must have been installed by another means, e.g. Homebrew or self compilation as described here. What you are probably missing is properly set PATH variable or the additionally installed compiler has version-suffixed binaries, i.e. gcc-4.9 or g++-4.9 instead of simply gcc / g++.

正常情况下,GCC 4.9.1不会使用osx(实际上没有任何GCC附带Xcode的船只)。您的程序必须通过另一种方式安装,如本文所述的自制程序或自编译。您可能缺少的是正确的设置路径变量,或者另外安装的编译器有版本后缀的二进制文件,即gcc-4.9或g++-4.9,而不是简单的gcc / g++。

As @rubenvb has already mentioned, Apple symlinks the Clang executables with GCC-like names. I personally find that a bad practice since recent Clang versions shipped with Xcode react on unrecognised command-line options (e.g. GCC frontend specific ones) with hard errors.

正如@rubenvb已经提到的那样,苹果将Clang的可执行文件与gcc类的名称联系起来。我个人认为,由于Xcode最近发布的Clang版本对未识别的命令行选项(例如GCC前端特定的选项)有错误的响应,这是一个糟糕的实践。

#2


10  

The gcc and g++ commands are not what you think they are with XCode: Apple thought it would be a good idea to masquerade Clang as GCC to make the transition smoother.

gcc和gc++命令并不是您认为的XCode: Apple认为将Clang化装成gcc是一个好主意,以使转换更加顺畅。

Clang OpenMP support is still being worked on. If I didn't miss any big release of the WIP code, you'll need to build this version of clang and use that.

Clang OpenMP支持仍在进行中。如果我没有错过WIP代码的任何大版本,您将需要构建这个版本的clang并使用它。

You can of course always install a real GCC through stuff like homebrew or macports, that will come with OpenMP support.

当然,您可以通过诸如homebrew或macports之类的东西来安装真正的GCC,这将伴随着OpenMP的支持。

#3


-1  

This command can help you

这个命令可以帮助你。

brew install libomp

酿造安装libomp