Xcode:cstdlib 在全局命名空间中没有名为“xxx”的成员

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30638320/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:14:05  来源:igfitidea点击:

Xcode: cstdlib no member named "xxx" in the global namespace

c++xcode

提问by Dylan

enter image description here

在此处输入图片说明

I only change the search path to inform Xcode where opencv locates. Here's my search paths:

我只更改搜索路径以通知 Xcode opencv 所在的位置。这是我的搜索路径:

Framework search path: /usr/local/lib
Library search path: /usr/local/Cellar/opencv/2.4.11/lib
                     /usr/local/Cellar/opencv/2.4.11_1/lib
                     /user/local/lib
Header search path: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
                    /usr/local/include

The errors:

错误:

    In file included from /Users/lilisun/Documents/opencv_projects/faceExtractor/faceExtractor/main.cpp:8:
In file included from /usr/local/include/opencv2/objdetect/objdetect.hpp:46:
In file included from /usr/local/include/opencv2/core/core.hpp:49:
In file included from /usr/local/include/opencv2/core/types_c.h:55:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/assert.h:44:
In file included from /usr/local/include/c++/5.1.0/tr1/stdlib.h:32:
In file included from /usr/local/include/c++/5.1.0/tr1/cstdlib:34:
/usr/local/include/c++/5.1.0/cstdlib:118:11: error: no member named 'div_t' in the global namespace
  using ::div_t;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:119:11: error: no member named 'ldiv_t' in the global namespace
  using ::ldiv_t;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:121:11: error: no member named 'abort' in the global namespace
  using ::abort;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:122:11: error: no member named 'abs' in the global namespace
  using ::abs;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:123:11: error: no member named 'atexit' in the global namespace
  using ::atexit;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:129:11: error: no member named 'atof' in the global namespace
  using ::atof;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:130:11: error: no member named 'atoi' in the global namespace
  using ::atoi;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:131:11: error: no member named 'atol' in the global namespace
  using ::atol;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:132:11: error: no member named 'bsearch' in the global namespace
  using ::bsearch;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:133:11: error: no member named 'calloc' in the global namespace
  using ::calloc;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:134:11: error: no member named 'div' in the global namespace
  using ::div;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:135:11: error: no member named 'exit' in the global namespace
  using ::exit;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:136:11: error: no member named 'free' in the global namespace
  using ::free;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:137:11: error: no member named 'getenv' in the global namespace
  using ::getenv;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:138:11: error: no member named 'labs' in the global namespace
  using ::labs;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:139:11: error: no member named 'ldiv' in the global namespace
  using ::ldiv;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:140:11: error: no member named 'malloc' in the global namespace
  using ::malloc;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:142:11: error: no member named 'mblen' in the global namespace
  using ::mblen;
        ~~^
/usr/local/include/c++/5.1.0/cstdlib:143:11: error: no member named 'mbstowcs' in the global namespace
  using ::mbstowcs;
        ~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

采纳答案by Dylan

I find what mistake I made. In the Header search path: I use /usr/local/includewith recursive. After I change it to /usr/local/include non-recursive/usr/local/include/opencv non-recursive/usr/local/include/opencv2 non-recursive

我发现我犯了什么错误。在标题搜索路径中:我使用/usr/local/include递归。在我将其更改为 /usr/local/include non-recursive/usr/local/include/opencv non-recursive/usr/local/include/opencv2 non-recursive

It works. But I still don't know why the recursion version would cause errors.

有用。但是我仍然不知道为什么递归版本会导致错误。