带有 Mountain Lion 的 g++ 是否支持 -msse4.2
Does g++ with Mountain Lion supports -msse4.2?
我正在尝试运行一个使用该函数的程序__builtin_popcountll
。当我使用 makefile 编译代码时,它使用命令/标志编译源文件,如下所示:
g++ -c -Wall `pkg-config opencv --cflags` -I./include -O3 -fopenmp -msse4.2 src/Utils.cpp -o src/Utils.o
它在没有任何错误/警告的情况下编译。但是,当我尝试链接对象 (.o( 文件以构建可执行文件时,出现undefined symbols
错误。
这是命令:
g++ src/BoostDesc.o src/Utils.o src/main.o `pkg-config opencv --libs` -lgomp -o main
这是完整的错误:
Undefined symbols for architecture x86_64:
"___builtin_popcountll", referenced from:
__ZN9boostDesc5Utils12matchHammingERKN2cv3MatERKSt6vectorIS2_SaIS2_EERS5_IS5_INS1_6DMatchESaISA_EESaISC_EE.omp_fn.0 in Utils.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [main] Error 1
我在Apple的网站上查找了gcc的手册页,它表明该标志有效,我假设它也应该适用于g ++。有人可以确认或反驳使用此内置函数的可能性吗?哗啦!
g++ --version
返回以下内容:
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
此优化是通过执行以下操作来指定的: -mpopcnt
或-march=corei7
到编译中。
取一个样本:
% cat popcountl.c
int main(int argc , char** argv)
{
volatile long long x = 0xf0f0f0f0f0f0f0f0;
return __builtin_popcountll(x);
}
事实证明,该版本的 g++ 不支持:
~/D/e/popcountl [1]> /Applications/Xcode 4.6.3.app/Contents/Developer/usr/bin/g++ -mpopcnt -c popcountl.c
cc1plus: error: unrecognized command line option "-mpopcnt"
~/D/e/popcountl [1]> /Applications/Xcode 4.6.3.app/Contents/Developer/usr/bin/g++ -march=corei7 -c popcountl.c
popcountl.c:1: error: bad value (corei7) for -march= switch
popcountl.c:1: error: bad value (corei7) for -mtune= switch
~/D/e/popcountl> /Applications/Xcode 4.6.3.app/Contents/Developer/usr/bin/g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
不过适用于Xcode5 g ++。
% g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
g++ -mpopcnt -c popcountl.cpp
dhcp-3-127:~% otool -tV popcountl.o
popcountl.o:
:
0000000000000024 popcntq %rax, %rax
看起来此优化的标志在 XCode 提供的编译器的 4.6 版本中不存在,但在 XCode 编译器的 5.0 版本中存在。
请记住,您实际上是在运行带有 g++ 前端的 llvm 编译器,因此它实际上并没有运行官方的 g++;这可能是它在这种情况下无法正常工作的根本原因。
相关文章:
- 编译时未启用intel oneApi CUDA支持
- POCO::PostgreSQL:如何将std::vector支持添加到`Binder::bind`
- 使用CMake检测支持的C++标准
- 为什么istream不支持右值提取
- 当我编译webrtc服务器时,Windows上只支持clang-cl
- 扩展光电二极管探测器以支持多个传感器
- MSVC是否支持C++11样式的属性而不是__declspec
- 在使用GPU支持编译Tensorflow时,会遇到CUDA_TOOLKIT_PATH未绑定变量
- 当使用比格式支持的精度更高的精度来显示数字时,会写出什么数据
- 错误:(-210:不支持的格式或格式组合)功能'create'中的硬件视频解码器不支持视频源
- 哪个C++规范开始支持 std::vector
- 如何检测VS C++编译器是否支持C++11?
- CertGetCertificateChain 具有支持的内存存储和证书信任列表
- Casablanca/cpprestsdk listener.support接受函数,但不支持方法
- 将 IPv6 支持添加到雨量计
- 为什么C++不支持对未初始化变量进行智能分析?
- LMDB 是否支持随机读取?
- 在 c++ 中连接字符串和整数,以便在 C++ 11 不支持计算机的情况下读取多个文件
- 在 Ubuntu 18.04 上编译 GLSL 着色器时"不支持 GLSL 3.30"?
- 带有 Mountain Lion 的 g++ 是否支持 -msse4.2