I want to create a web server with libuv and http-parser .
Current project structure
Makefile /src /main.c /deps /libuv (git clone of libuv) /http-parser (git clone of http-parser)
In main.c, I defined the following:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "uv.h" #include "http_parser.h"
and the makefile looks like this:
LDFLAGS = -L deps/libuv main: libuv http-parser $(CC) src/main.c -o main.out deps/libuv/libuv.a deps/http-parser/http_parser.o $(LDFLAGS) libuv: $(MAKE) -C deps/libuv libuv.a http-parser: $(MAKE) -C deps/http-parser http_parser.o clean: rm deps/libuv/libuv.a rm deps/http-parser/http_parser.o
This happens when the compiler tries to bind http_parser.
make -C deps/libuv libuv.a make[1]: `libuv.a' is up to date. make -C deps/http-parser http_parser.o make[1]: `http_parser.o' is up to date. cc src/main.c -o main.out deps/libuv/libuv.a deps/http-parser/http_parser.o src/main.c:5:10: fatal error: 'http_parser.h' file not found #include "http_parser.h" ^ 1 error generated. make: *** [main] Error 1
When I remove http_parser from inclusions and Makefile, I get a strange libuv build error:
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 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [main] Error 1
I was stuck on this issue from yesterday and generally lost my hope.
Current Makefile Status:
LDFLAGS = -Ldeps/libuv INCLFLAGS = -Ideps/http-parser main.o: libuv.a http-parser.o $(CC) src/main.c $(INCLFLAGS) -o main.o deps/libuv/libuv.a deps/http-parser/http_parser.o $(LDFLAGS) libuv.a: $(MAKE) -C deps/libuv libuv.a http-parser.o: $(MAKE) -C deps/http-parser http_parser.o clean: rm deps/libuv/libuv.a rm deps/http-parser/http_parser.o
detailed output:
#include "..." search starts here: