当我尝试构建以下程序时:
#include <stdio.h>
int main(void)
{
printf("hello world\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在OS X 10.6.4上,带有以下标志:
gcc -static -o blah blah.c
Run Code Online (Sandbox Code Playgroud)
它返回:
ld: library not found for -lcrt0.o
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
有没有其他人遇到过这种情况,还是其他人没有受到影响呢?任何修复?
谢谢
我正在使用一个无法为 Apple M1 编译的库,因此我决定编译它并使用 x86_64 的 (Rosetta 2) 使用它,我成功地按照此为x86_64 安装了brew 和 clang。
但是,当我编译我的项目并尝试将其链接到该库时,我收到此错误:
ld: warning: ignoring file ..../libapronxx.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
...
ld: symbol(s) not found for architecture arm64
Run Code Online (Sandbox Code Playgroud)
我尝试设置编译器和链接器标志(“-arch x86_64”),但仍然遇到同样的问题。
我的问题是:在 Apple M1(arm)上使用 cmake 构建 macOS-x86_64 的正确方法是什么?
附加信息:我通过 CLion 使用 cmake。
更新:我使用以下命令成功编译了我的项目:
# install a x86 cmake
arch -x86_64 /usr/local/bin/brew install cmake
...
# in the build directory
arch -x86_64 /usr/local/bin/cmake ..
make
arch -x86_64 ./my_exe
Run Code Online (Sandbox Code Playgroud)
我还使用 -arch …
我使用的是Mac OS X Sierra,我发现clang(LLVM版本8.1.0(clang-802.0.38))不支持OpenMP:当我运行时clang -fopenmp program_name.c,我收到以下错误:
clang: error: unsupported option '-fopenmp'
似乎clang不支持-fopenmp旗帜.
我在自制软件中找不到任何openmp库.根据LLVM网站,LLVM已经支持OpenMP.但是在编译期间我找不到启用它的方法.
这是否意味着Mac中的默认clang不支持OpenMP?你能提供什么建议吗?
(当我切换到GCC编译相同的程序(使用gcc安装brew install gcc --without-multilib)时,编译成功.)