简体   繁体   English

XCode无法找到zmq.h,即使它位于/ usr / local / include和标头搜索路径中

[英]XCode unable to find zmq.h even though it's in /usr/local/include and the header search path

I just installed the ZMQ library via brew and I can see the files in /usr/local/include and /usr/local/bin, however when I add those paths to the Header Search Path and Library Search Path in XCode I am unable to use #include as it continues to tell me it can't find the find. 我只是通过brew安装了ZMQ库,并且可以在/ usr / local / include和/ usr / local / bin中看到文件,但是当我将这些路径添加到XCode中的Header Search Path和Library Search Path时,我无法使用#include,因为它继续告诉我找不到内容。

Even when I add /usr/local/Cellar/zeromq/4.1.4/include (where the actual library is installed) to the Header Search Path it still won't find zmq.h even though the file is present in there. 即使我将/usr/local/Cellar/zeromq/4.1.4/include(已安装实际库的位置)添加到Header Search Path,即使文件存在于zmq.h中,它仍然找不到。

What should I do? 我该怎么办?

Edit: 编辑:

The full source is simply a example file from ZMQ themselfe, 完整的源代码只是ZMQ他们自己提供的示例文件,

//
//  Hello World client in C++
//  Connects REQ socket to tcp://localhost:5555
//  Sends "Hello" to server, expects "World" back
//
#include <zmq.h>
#include <string>
#include <iostream>

int main ()
{
    //  Prepare our context and socket
    zmq::context_t context (1);
    zmq::socket_t socket (context, ZMQ_REQ);

    std::cout << "Connecting to hello world server…" << std::endl;
    socket.connect ("tcp://localhost:5555");

    //  Do 10 requests, waiting each time for a response
    for (int request_nbr = 0; request_nbr != 10; request_nbr++) {
        zmq::message_t request (5);
        memcpy (request.data (), "Hello", 5);
        std::cout << "Sending Hello " << request_nbr << "…" << std::endl;
        socket.send (request);

        //  Get the reply.
        zmq::message_t reply;
        socket.recv (&reply);
        std::cout << "Received World " << request_nbr << std::endl;
    }
    return 0;
}

The exact error is simply " lexical or Preprocessor issue, 'zmq.h' file not found main.cpp " 确切的错误只是“ 词汇或预处理器问题,找不到main.cpp'zmq.h'文件

CompileC /Users/zezioen/Library/Developer/Xcode/DerivedData/ndovTest-bktygajikpscajfbqwlwhyjknvzq/Build/Intermediates/ndovTest.build/Debug/ndovTest.build/Objects-normal/x86_64/main.o ndovTest/main.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/zezioen/stack/Projecten/CPP/ndovTest
    export LANG=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu++11 -stdlib=libc++ -fmodules -gmodules -fmodules-cache-path=/Users/zezioen/Library/Developer/Xcode/DerivedData/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/zezioen/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DDEBUG=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.11 -g -fvisibility-inlines-hidden -Wno-sign-conversion -I/Users/zezioen/Library/Developer/Xcode/DerivedData/ndovTest-bktygajikpscajfbqwlwhyjknvzq/Build/Intermediates/ndovTest.build/Debug/ndovTest.build/ndovTest.hmap -I/Users/zezioen/Library/Developer/Xcode/DerivedData/ndovTest-bktygajikpscajfbqwlwhyjknvzq/Build/Products/Debug/include -Iusr/local/include -I/Users/zezioen/Library/Developer/Xcode/DerivedData/ndovTest-bktygajikpscajfbqwlwhyjknvzq/Build/Intermediates/ndovTest.build/Debug/ndovTest.build/DerivedSources/x86_64 -I/Users/zezioen/Library/Developer/Xcode/DerivedData/ndovTest-bktygajikpscajfbqwlwhyjknvzq/Build/Intermediates/ndovTest.build/Debug/ndovTest.build/DerivedSources -F/Users/zezioen/Library/Developer/Xcode/DerivedData/ndovTest-bktygajikpscajfbqwlwhyjknvzq/Build/Products/Debug -MMD -MT dependencies -MF /Users/zezioen/Library/Developer/Xcode/DerivedData/ndovTest-bktygajikpscajfbqwlwhyjknvzq/Build/Intermediates/ndovTest.build/Debug/ndovTest.build/Objects-normal/x86_64/main.d --serialize-diagnostics /Users/zezioen/Library/Developer/Xcode/DerivedData/ndovTest-bktygajikpscajfbqwlwhyjknvzq/Build/Intermediates/ndovTest.build/Debug/ndovTest.build/Objects-normal/x86_64/main.dia -c /Users/zezioen/stack/Projecten/CPP/ndovTest/ndovTest/main.cpp -o /Users/zezioen/Library/Developer/Xcode/DerivedData/ndovTest-bktygajikpscajfbqwlwhyjknvzq/Build/Intermediates/ndovTest.build/Debug/ndovTest.build/Objects-normal/x86_64/main.o

/Users/zezioen/stack/Projecten/CPP/ndovTest/ndovTest/main.cpp:6:10: fatal error: 'zmq.h' file not found
#include <zmq.h>
         ^
1 error generated.

Edit 2: 编辑2:

I have no idea what happened but I just re-created the entire project, did the exact same steps as before and now it compiles and runs like it should. 我不知道发生了什么,但我只是重新创建了整个项目,执行了与以前完全相同的步骤,现在它可以像预期的那样编译和运行。

The project I used was from a while ago so there may have been something else that was causing issues. 我使用的项目是前一段时间的项目,因此可能还有其他原因导致了问题。

检查您的构建配置中的搜索路径->始终搜索用户路径,并且在您的项目名称下应显示“是”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Boost #include在XCode上失败,即使boost在标题搜索路径上也是如此 - Boost #include is failing on XCode even though boost is on the header search path 找不到Xcode版本6.0.1 gmp.h头文件,即使gmp.h和gmpxx.h在本地/包含 - Xcode Version 6.0.1 gmp.h header file not found, even though gmp.h and gmpxx.h are in local/include / usr / include不能用作xcode中的搜索路径? - /usr/include won't work as a search path in xcode? 找不到库,即使它在搜索路径上 - Cannot find library, even though it is on search path libzmq和cppzmq之间以及zmq.h和zmq.hpp之间的区别? - Difference between libzmq and cppzmq , and between zmq.h and zmq.hpp? 对于 MacOS 上的 G++,如何添加默认包含目录 /usr/local/include 和默认库搜索路径 /usr/local/lib? - For G++ on MacOS how to add default include dir /usr/local/include and default library search path /usr/local/lib? 为什么Xcode即使在搜索路径中列出了它也无法找到GLEW动态库? - Why is Xcode unable to find a GLEW dynamic library even when it is listed in the search path? GCC没有在/ usr / local / include中找到头文件 - GCC not finding header files in /usr/local/include gcc - / usr / bin / ld错误:找不到 <library> 在/ usr / local / lib中虽然ldconfig列出它,并且路径已添加到ld.so.conf中 - gcc - /usr/bin/ld error: cannot find <library> in /usr/local/lib though ldconfig list it, and path added to ld.so.conf 为什么`/ usr / include`不在gcc默认搜索路径中 - why `/usr/include` is not in gcc default search path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM