I try to build a C++ project using mongoose, but I keep getting linker errors.
I tried to use the answer to the existing SO question describing similar symptoms: What is an undefined reference/unresolved external symbol error and how do I fix it? by #include
C header using external C linkage:
//simple_web_server credited to Cesanta Software
#include "stdafx.h"
extern "C" {
#include "mongoose.h"
}
static const char *s_http_port = "8000";
static struct mg_serve_http_opts s_http_server_opts;
static void ev_handler(struct mg_connection *nc, int ev, void *p) {
if (ev == MG_EV_HTTP_REQUEST) {
mg_serve_http(nc, (struct http_message *) p, s_http_server_opts);
}
}
int main(void) {
struct mg_mgr mgr;
struct mg_connection *nc;
mg_mgr_init(&mgr, NULL); // <== this causes linker error
...
I keep getting the following linker error:
1>------ Build started: Project: simple_web_server02, Configuration: Debug Win32 ------
1> simple_web_server02.cpp
1>simple_web_server02.obj : error LNK2019: unresolved external symbol _mg_mgr_init referenced in function _main
The location of mongoose.h
is supplied properties > VC++ > Include Directories.
I note also that omitting/including the 'extern "C" {...}' has no apparent effect.
Any help or suggestions would be much appreciated.