1

在阅读了一些关于 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

我试图通过定义unixPLATFORMSTL_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,如果支持,我做错了什么?

4

1 回答 1

1

Mac OS X 不提供UNIX(或unix, __unix__, )试图检测的__unix宏。在像这样添加 line 语句(第 154 行)PlatformSTL后,我能够编译您的示例:defined(__MACH__)platformstl.h

#if defined(unix) || \ 
    defined(UNIX) || \ 
    defined(__unix__) || \ 
    defined(__unix) || \ 
    defined(__MACH__) 
# define PLATFORMSTL_OS_IS_UNIX

要抑制未定义符号错误,您可以定义宏FASTFORMAT_NO_AUTO_INIT

g++ -I<path to fastformat and stlsoft headers> -DFASTFORMAT_NO_AUTO_INIT main.cpp

于 2013-08-23T06:48:26.153 回答