k0shinus
k0shinus

Reputation: 81

Compiling the project using libuv with CMake

I have got a small async udp server - RiDE.

And i can't build it with CMake. When i trying to i get errors:

undefined reference to 'uv_default_loop'
undefined reference to 'uv_udp_init'
...(other libuv functions)

But when i build it with command like this:

gcc -std=c11 RiDE_server.h RiDE_server.cpp main.cpp -o main.x -Wall -luv

everything is ok.

I think that the problem is in src/CMakeLists.txt file, but i can't understand how to fix it. Path to libuv headers on my machine - /usr/include. Path to libuv shared libs - /usr/lib/x86-64-linux-gnu.

Upvotes: 3

Views: 3811

Answers (1)

John Zwinck
John Zwinck

Reputation: 249293

Run make VERBOSE=1. What linker command does it run? It must be missing -luv. To fix that, add something like this to your CMakeLists.txt:

target_link_libraries(foo uv)

Upvotes: 4

Related Questions