在阅读了有关FastFormat的一些知识之后,我决定将其下载并安装在运行OS X 10.8的Macbook Pro上。我成功地构建了FastFormat,并运行了性能测试。然后我写了一个小测试来检查它是否有效:
#include <cstdlib>
#include <fastformat/fastformat.hpp>
#include <fastformat/sinks/ostream.hpp>
int main()
{
return EXIT_SUCCESS;
}
使用g++-4.7进行编译(并确保所有包含路径正确)后,我从PlatformSTL中获得了编译时错误,例如以下错误。
error: #error Operating system not discriminated. Only UNIX and Windows are currently recognised by PlatformSTL
error: #error Operating system not discriminated
我尝试通过手动定义
unix
和PLATFORMSTL_OS_IS_UNIX
来抑制这些错误,但随后收到以下链接器错误:Undefined symbols for architecture x86_64:
"_fastformat_exitProcess", referenced from:
fastformat::fastformat_initialiser::fastformat_initialiser() in ccMqErni.o
"_fastformat_getInitCodeString", referenced from:
fastformat::fastformat_initialiser::record_init_failure_(int) in ccMqErni.o
"_fastformat_init", referenced from:
fastformat::fastformat_initialiser::fastformat_initialiser() in ccMqErni.o
"_fastformat_uninit", referenced from:
fastformat::fastformat_initialiser::~fastformat_initialiser() in ccMqErni.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
OS X是否支持FastFormat,如果支持,我在做什么错?
最佳答案
Mac OS X不提供UNIX
尝试检测的unix
(或__unix__
,__unix
,PlatformSTL
)宏。这样在defined(__MACH__)
中添加platformstl.h
行(第154行)后,我便能够编译您的示例:
#if defined(unix) || \
defined(UNIX) || \
defined(__unix__) || \
defined(__unix) || \
defined(__MACH__)
# define PLATFORMSTL_OS_IS_UNIX
要抑制 undefined 的符号错误,您可以定义宏
FASTFORMAT_NO_AUTO_INIT
:g++ -I<path to fastformat and stlsoft headers> -DFASTFORMAT_NO_AUTO_INIT main.cpp
关于c++ - OS X上的FastFormat,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13717936/