libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] compile problem on Visual Studio 2010


From: Jed Irvine
Subject: Re: [libmicrohttpd] compile problem on Visual Studio 2010
Date: Tue, 20 Dec 2011 10:07:48 -0800

I got the hellobrowser example to build and run.  There were few issues - one was that I copied the example into a .cpp file rather than a .c file, which caused much of the confusion I was seeing.  I've documented every step I used to get it to build below:


Get the library and hook it in
-download libmicrohttpd-0.9.17-w32.zip from ftp://ftp.gnu.org/gnu/libmicrohttpd/
-unzip it into place, ex:  C:\Documents and Settings\admin-jed\My Documents\Visual Studio 2010\Projects\mhdTest2\libmicrohttpd-0.9.17-w32  (add final dir)

-copy hellobrowser.c code from http://www.gnu.org/s/libmicrohttpd/tutorial.pdf into mhdTest.cpp
-make a new header file : ex. fire_mhd_platform.h
- use an 'extern "C"' block to include the microhttpd.h and fire_mhd_platform.h, which I create later

extern "C" {
  #include "fire_mhd_platform.h"
  #include "microhttpd.h"
}

-in mhdTest->Properties,C/C++  add into Additional Include Directories, the path to the libmicrohttpd include directory, ex: 

    C:\Documents and Settings\admin-jed\My Documents\Visual Studio 2010\Projects\mhdTest2\libmicrohttpd-0.9.17-w32\include

-in mhdTest->Properties,Linker, add into Additional Libraries Directories, the path to the import library:  

    C:\Documents and Settings\admin-jed\My Documents\Visual Studio 2010\Projects\mhdTest2\libmicrohttpd-0.9.17-w32\lib

-in mhdTest->Properties,Linker,Input, add into Additional Dependencies , the import library

    libmicrohttpd.dll.a
 
 
-create the fire_mhd_platform.h in the C:\Documents and Settings\admin-jed\My Documents\Visual Studio 2010\Projects\mhdTest2\mhdTest2 directory, with a #define to prevent default linux-friendly configurations from being included, and add in the includes and typedefs as noted

#ifndef MHD_PLATFORM_H

#define MHD_PLATFORM_H

#include <winsock2.h> // socket related definitions
#include <ws2tcpip.h> // socket related definitions

typedef SSIZE_T ssize_t; //convey Windows type to unix type
typedef UINT64 uint64_t; //convey Windows type to unix type
typedef UINT16 uint16_t; //convey Windows type to unix type

#endif


-Copy the dlls from

C:\Documents and Settings\admin-jed\My Documents\Visual Studio 2010\Projects\mhdTest2\libmicrohttpd-0.9.17-w32\bin

into the output directory, for example:

C:\Documents and Settings\admin-jed\My Documents\Visual Studio 2010\Projects\mhdTest2\Debug

(or set up a build event to do this prebuild in Properties->Build Events->Pre-Build Event)


Should compile and run at this point.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]