本文介绍了库编译libuv在OS X?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想学习一些libuv,似乎有通过它进入一个伟大的书。然而,这本书没有解释如何真正编译它。我跑了就了code,我从github上拉,并与GYP编译为在github上描述()。但是我不知道我需要什么样的图书馆,包括获得code编译。我试图编译这个code:

I'm trying to learn some libuv and it seems there's a great book that goes through it. However, the book doesn't explain how to actually compile it. I ran make on the code that I pulled from github, and compiled with GYP as described on the github (https://github.com/joyent/libuv). However I'm not sure what kind of libraries I need to include to get the code to compile. I tried to compile this code:

/* first.c */
#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;
}

我从 libuv 文件夹下面的命令编译它:

I compiled it with the following command from the libuv folder:

gcc -o first first.c build/Release/libuv.a

和我得到了以下缺失的符号:

and I got the following missing symbols:

Undefined symbols for architecture x86_64:
  "_CFArrayCreate", referenced from:
      _uv__fsevents_init in libuv.a(fsevents.o)
  "_CFRunLoopAddSource", referenced from:
      _uv__cf_loop_runner in libuv.a(darwin.o)
  "_CFRunLoopGetCurrent", referenced from:
      _uv__cf_loop_runner in libuv.a(darwin.o)
  "_CFRunLoopRemoveSource", referenced from:
      _uv__cf_loop_runner in libuv.a(darwin.o)
  "_CFRunLoopRun", referenced from:
      _uv__cf_loop_runner in libuv.a(darwin.o)
  "_CFRunLoopSourceCreate", referenced from:
      _uv__platform_loop_init in libuv.a(darwin.o)
  "_CFRunLoopSourceSignal", referenced from:
      _uv__cf_loop_signal in libuv.a(darwin.o)
  "_CFRunLoopStop", referenced from:
      _uv__platform_loop_delete in libuv.a(darwin.o)
  "_CFRunLoopWakeUp", referenced from:
      _uv__cf_loop_signal in libuv.a(darwin.o)
  "_CFStringCreateWithCString", referenced from:
      _uv__fsevents_init in libuv.a(fsevents.o)
  "_CFStringGetSystemEncoding", referenced from:
      _uv__fsevents_init in libuv.a(fsevents.o)
  "_FSEventStreamCreate", referenced from:
      _uv__fsevents_init in libuv.a(fsevents.o)
  "_FSEventStreamInvalidate", referenced from:
      _uv__fsevents_close in libuv.a(fsevents.o)
  "_FSEventStreamRelease", referenced from:
      _uv__fsevents_close in libuv.a(fsevents.o)
  "_FSEventStreamScheduleWithRunLoop", referenced from:
      _uv__fsevents_schedule in libuv.a(fsevents.o)
  "_FSEventStreamStart", referenced from:
      _uv__fsevents_schedule in libuv.a(fsevents.o)
  "_FSEventStreamStop", referenced from:
      _uv__fsevents_close in libuv.a(fsevents.o)
  "_kCFRunLoopDefaultMode", referenced from:
      _uv__cf_loop_runner in libuv.a(darwin.o)
      _uv__fsevents_schedule in libuv.a(fsevents.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

有人可以给我如何建立一个libuv快速教程,或者如果有什么我需要什么?

Can someone give me a quick tutorial for how to build libuv, or if there's anything else I need?

推荐答案

OK,理解了它。我必须使用OSX的CoreFoundation和CoreServices框架。下面的命令成功编译:

OK, figured it out. I have to use the OSX "CoreFoundation" and "CoreServices" frameworks. The following command compiles successfully:

gcc -o first first.c build/Release/libuv.a -framework CoreFoundation -framework CoreServices

这篇关于库编译libuv在OS X?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 10:39