0

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.

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.

What should I do?

Edit:

The full source is simply a example file from ZMQ themselfe,

//
//  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"

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:

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.

MegaMiley
  • 478
  • 1
  • 5
  • 19
  • Does specifying the full path work? Check the permissions? Got the slashes the right way around? Maybe post an ls -l, the exact error message and the relevant bit of the source file just in case... – JCx May 11 '16 at 19:19
  • What should the permissions be? The full path yields the same result and I'm sure I used the right / (\ to me is escaping the next character unlike the regular / in Windows) – MegaMiley May 11 '16 at 19:20
  • Well permissions need to make sure Xcode can read it - they are probably fine...if you can read it Xcode probably can unless there's something unusual going on. – JCx May 11 '16 at 19:22
  • Oh - you can get the full compiler output from the Log window in Xcode. I think that should show what's being passed to the compiler ... let's see that... (http://stackoverflow.com/questions/30060898/xcode6-how-to-see-build-command-and-log) – JCx May 11 '16 at 19:23
  • Just installed zmq here and #include "/usr/local/include/zmq.h" works - although i get a bunch of namespace related errors - looks like the version i installed didn't include the c++ bindings which have moved to a separate project. – JCx May 11 '16 at 19:29
  • 1
    I just re-created the entire project and now it does work.. Really odd why it didn't before but at least it works now – MegaMiley May 11 '16 at 19:35
  • Awesome. :) Stuck bad. Working good! – JCx May 11 '16 at 19:37

1 Answers1

0

Check your build configuration for Search Path -> Always search for user paths and under your project name should say "yes"

Yoan
  • 161
  • 3
  • 8