Search code examples
freebsdmongoose-web-server

Port Mongoose web server to FreeBSD


I was wondering if anyone had success in porting the Linux versions of the Mongoose web server or the Civetweb web server to FreeBSD. I've tried to do a Make, but there is a compatibility issue between Linux and BSD, in that it cannot find -ldl. I've seen reference to this in a google search, and the recommended solution is probably beyond my skill level.


Solution

  • Linux uses GNU make by default. Its makefiles tend to be incompatible with FreeBSD's make. So you need to install GNU make using the /usr/ports/devel/gmake port. The program is called gmake on FreeBSD.

    So for mongoose, download the latest mongoose source from github. Then install GNU make using the /usr/ports/devel/gmake port. Unpack mongoose;

    > tar xf mongoose-5.3.tar.gz
    > cd mongoose-5.3/examples
    

    Then compile it;

    > gmake
    cc hello.c ../mongoose.c -o hello -W -Wall -I.. -pthread -g -pipe 
    perl mkdata.pl websocket.html > websocket_html.c
    cc websocket.c websocket_html.c ../mongoose.c -o websocket  -W -Wall -I.. -pthread -g -pipe 
    cc server.c ../mongoose.c -o server  -W -Wall -I.. -pthread -g -pipe 
    cc post.c ../mongoose.c -o post -W -Wall -I.. -pthread -g -pipe 
    cc multi_threaded.c ../mongoose.c -o multi_threaded -W -Wall -I.. -pthread -g -pipe 
    cc upload.c ../mongoose.c -o upload -W -Wall -I.. -pthread -g -pipe 
    cc auth.c ../mongoose.c -o auth -W -Wall -I.. -pthread -g -pipe
    

    Civetweb also compiles without errors using gmake.