0

I ran the command '''python3 setup.py install''' and '''python3 setup.py install --prefix=/usr/local''' in order to install the Python package Pynini through CLI but got the following unexplained error, which I am not sure what it is due to:

'''[...] 
running build_ext
building 'pywrapfst' extension gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/anaconda3/include -arch x86_64 -I/Library/anaconda3/include -arch x86_64 -I/Library/anaconda3/include/python3.6m -c src/pywrapfst.cc -o build/temp.macosx-10.7-x86_64-3.6/src/pywrapfst.o -std=c++11 -Wno-unused-function -Wno-unused-local-typedefs -funsigned-char
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
src/pywrapfst.cc:612:10: fatal error: 'ios' file not found
#include "ios"
         ^~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1'''  

It appears that there are two errors (the iOS- and the gcc-related ones). How could I solve them ?

Any help would be appreciated !

4
  • Cross-post on StackOverflow. Commented Aug 12, 2019 at 3:52
  • Shot in the dark but try CFLAGS='-stdlib=libc++' python3 setup.py install. Commented Aug 12, 2019 at 3:57
  • @Anaksunaman thank you so much, that turned out to work ! I had some other steps to have the module be effective after that but installation was completed subsequent to your command. Can you briefly explain what it does ? Thanks again !
    – benjaming
    Commented Sep 7, 2019 at 8:33
  • You're welcome. I have added a brief answer to (hopefully) address your questions. Commented Sep 7, 2019 at 9:59

1 Answer 1

0

Try running CFLAGS='-stdlib=libc++' python3 setup.py install.

Can you briefly explain what this command does?

On Mac OS X, gcc and g++ are sometimes actually aliases for Clang, not GCC. CFLAGS='-stdlib=libc++' is (as far as I am aware) a Clang-specific compiler flag that indicates Clang should use libc++ during compilation (which is done as part of the Pynini module installation).

Regarding why this works, it appears that the header files for stdlibc++ couldn't be found. Thus, in this instance, it is apparently necessary to tell Clang to use libc++ instead

warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead

Also note that -std=c++11 has been specified and libc++ is a post-C++11 implementation of the C++ standard library from the same people who produce Clang.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .