Libraries to compile libuv on os x?

匆匆过客 提交于 2019-12-06 01:12:36

With libuv installed through homebrew do:

$ gcc -luv main.c

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

Thanks for the solution – I was struggling with the same problem.

I developed your answer so that I could compile and link from any folder by using the following options:

gcc -o first -L/my/folders/libuv/ -I/my/folders/libuv/include/ first.c -luv -framework CoreFoundation -framework CoreServices

Also, I added the library into Eclipse using the following steps:

To add the path to the header file uv.h:

Right click on project and select Properties->C/C++ General->Paths and Symbols->Includes. Click on Add.. and in the text box enter:

/my/folders/libuv/include/

Click Apply->Okay.

To add the library:

While in same screen, as above, click Libraries. Click on Add.. and in the text box enter:

uv

To add the path to the library:

Still on the same screen click on Library Paths. Click Add.. and enter in the text box:

/my/folders/libuv/

To add the frameworks:

Right click on project Properties->C/C++Build->Setting->Tool Settings->Miscellaneous->Mac OS X C++ Linker. Then in the text box with the title Linker Flags add:

-framework CoreFoundation –framework CoreServices

Click on Apply then build.

abidon

You can 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:

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

See this post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!