FastFormat on OS X

十年热恋 提交于 2019-12-24 10:17:44

问题


After reading a little about FastFormat, I decided to download and install it on my Macbook Pro, running OS X 10.8. I successfully got FastFormat to build, and ran the performance tests. Then I wrote a small test to check whether it works:

#include <cstdlib>
#include <fastformat/fastformat.hpp>
#include <fastformat/sinks/ostream.hpp>

int main()
{
    return EXIT_SUCCESS;
}

Upon compiling it with g++-4.7 (and making sure that all the include paths were correct), I got compile-time errors, such as the ones below, from PlatformSTL.

error: #error Operating system not discriminated. Only UNIX and Windows are currently recognised by PlatformSTL
error: #error Operating system not discriminated

I tried to suppress these errors by defining unix and PLATFORMSTL_OS_IS_UNIX manually, but I then receive these linker errors:

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

Is FastFormat supported on OS X, and if so, what am I doing wrong?


回答1:


Mac OS X does not provide UNIX (or unix, __unix__, __unix) macro which PlatformSTL tries to detect. I was able to compile your example after adding the line defined(__MACH__) statement in platformstl.h like this (line 154):

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

To supress the undefined symbols error you can define macro FASTFORMAT_NO_AUTO_INIT:

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



来源:https://stackoverflow.com/questions/13717936/fastformat-on-os-x

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!