question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Xcode 10.1 error when compiling C++ files

See original GitHub issue

I have a file abc.pyx that starts:

# distutils: language=c++

(because I am using vector).

This file compiled fine until I upgraded to Xcode 10.1 (10B61). I now get the following error:

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]
abc.cpp:636:10: fatal error: 'ios' file not found
#include "ios"
         ^~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1

All of my pyx files that are compiled using C instead of C++ are compiling correctly.

I am using Cython 0.29 in an Anaconda environment with Python 3.6.2 on macOS Mojave 10.14.1.

Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:14:59) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin

My setup.py looks like:

setup(ext_modules=cythonize[(abc.pyx)])

I am building using the following command:

python setup.py build_ext --inplace
python setup.py install

Any suggestions would be greatly appreciated. Is there any way I can pass a compiler option to just those files?

This StackOverflow response is close, but I don’t want to compile all of my pyx files into C++. I tried that, but got other errors. It would be simplest if I could just resolve the issue of this single file.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
jsawrukcommented, Nov 2, 2018

This issue was resolved by upgrading to the Xcode Command Line Tools 10.1, released on November 2, 2018.

6reactions
joshlkcommented, Jul 8, 2019

Originally posted by @TruongKhang in https://github.com/coccoc/coccoc-tokenizer/issues/5#issuecomment-504321367_

The setup.py file should be changed to something like:

from Cython.Distutils import build_ext
from distutils.core import setup
from distutils.extension import Extension

import os
os.environ['CC'] = 'g++'
os.environ['CXX'] = 'g++'

ext_modules = [
    Extension(
        name="CocCocTokenizer",
        sources=["CocCocTokenizer.pyx"],
        extra_compile_args=["-Wno-cpp", "-Wno-unused-function", "-O2", "-march=native", '-stdlib=libc++', '-std=c++11'],
        extra_link_args=["-O2", "-march=native", '-stdlib=libc++'],
        language="c++",
        include_dirs=["."],
    )
]

setup(
    name="coccoc-tokenizer", ext_modules=ext_modules, cmdclass={"build_ext": build_ext}
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

XCode 10 - "new" file not found
I tried to compile my project which use both Objective-C and C++ files. ... Compiler gives this error: 'new' file not found. Why...
Read more >
Why do I have errors when build c code with Xcode?
I have code, that compile with gcc gcc --version Apple clang version 14.0.0 (clang-1400.0.29.102) Target: arm64-apple-darwin21.6.0 Thread ...
Read more >
Unable to compile my .c files using the mex command ...
when typing the 'mex -setup' command I got: MEX configured to use 'Xcode with Clang' for C language compilation. Warning: The MATLAB C...
Read more >
Top 10 C++ header file mistakes and how to fix them
Recommendation: Check your header filies by compiling them in isolation via a testMain.cpp that includes nothing but the header file under test.
Read more >
Not able to build the swift compiler
I would try to remove this Xcode 2 completely, xcode-select -s the original one, xcode-select --install to make sure tools are installed and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found