3

i want to install libuv on OS X,but when i

brew install libuv 

then i write a simple demo :

#include <stdio.h>
#include <uv.h>
int main() {
    uv_loop_t *loop = uv_loop_new();
    printf(“Now quitting.\n”);
    uv_run(loop, UV_RUN_DEFAULT);
    return 0;
 }

always error:

main.cc:2:10: fatal error: 'uv.h' file not found
#include <uv.h>
     ^
1 error generated.
Leviathan
  • 335
  • 2
  • 5
  • 10
  • What command did you use to compile? It appears that on recent OS X version (due to Xcode?) you need to add `-I/usr/local/include` to the compiler flag. – Hiura Jan 20 '16 at 09:30

3 Answers3

0

Answers from here may help you...

$ g++ -luv main.cc

Or

$ g++ -o main main.cc build/Release/libuv.a -framework CoreFoundation -framework CoreServices
Community
  • 1
  • 1
zangw
  • 43,869
  • 19
  • 177
  • 214
0

Yes : -I/usr/local/include helped me. But one point add this compiler flags not in project but in sdk

0

If you want to use Xcode you can add libuv as a Git submodule (git submodule add https://github.com/libuv/libuv Externals/libuv) and use GYP to generate an xcodeproj for libuv (as explained in libuv's README) and add this xcodeproj to your main Xcode project.

It can be automated (for easy updating) with a simple shell script (assumes you put the libuv submodule in Externals/libuv, but can be changed):

git submodule update --init
git clone https://chromium.googlesource.com/external/gyp.git Externals/libuv/build/gyp
Externals/libuv/gyp_uv.py -f xcode

Then you'll be able to add libuv as a dependency and to the libraries to link your target to:

Xcode configuration

The last thing to do is to tell Xcode where are libuv's headers:

Headers configuration

See this post

Community
  • 1
  • 1
abidon
  • 456
  • 4
  • 15