I want to compile the sample code above, but I get the following error. What is the reason for it. "OSX - / usr / local" under all the files installed
// libevent2 library
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <evhttp.h>
#include <event2/event.h>
#include <event2/http.h>
#include <event2/bufferevent.h>
void generic_handler(struct evhttp_request *req, void *arg) {
struct evbuffer *buffer;
buffer = evbuffer_new();
if (buffer == NULL) {
err(1, "failed to create response buffer");
}
evbuffer_add_printf(buffer, "Requested: %sn", evhttp_request_uri(req));
evhttp_send_reply(req, HTTP_OK, "OK", buffer);
}
int main(int argc, char **argv) {
struct evhttp *httpd;
event_init();
httpd = evhttp_start("0.0.0.0", 8080);
// Set a callback for requests to "/specific".
// evhttp_set_cb(httpd, "/specific", another_handler, NULL);
// Set a callback for all other requests.
evhttp_set_gencb(httpd, generic_handler, NULL);
// Not reached in this code as it is now.
event_dispatch();
evhttp_free(httpd);
return 0;
}
Error:
/Users/batuhangoksu/Desktop/test.c:14:10: fatal error: 'evhttp.h' file not found
#include <evhttp.h>
^
1 error generated.
Command:
gcc -o octopus /Users/batuhangoksu/Desktop/test.c -levent -lpthread
First, please find the
path
ofevhttp.h
file.Then, you could check if this
path
is in the#include
files search path list by commandThe output is like this,
If the
path
is not in the search list, then add-I /missed_include
(assume it is thepath
) to your command, likegcc -o octopus /Users/batuhangoksu/Desktop/test.c -levent -lpthread -I /missed_include