Question

I apologize if this seems like a stupid question, but I guess I am more used to packages that come with Makefiles or configure scripts.

I downloaded the Mongoose source tar file from the site, and untarred it.

I then tried to compile an executable out of it using gcc -g -c mongoose.c -o main.o -lpthread -ldl. However, after trying to execute, I get the error -bash: ./main.o: cannot execute binary file

When I looked into mongoose.c source, I did not find a main function.

Where can I get the main function so that the Linux mongoose web server can be compiled to work the same way as the Windows mongoose.exe?

Was it helpful?

Solution

Mongoose does come with a Makefile, and will compile as a standalone command-line program. Lua and SQLite are included.

The easiest way to compile the latest version is to cd into the "build" directory and run make unix. I'm not sure about the archived version on the downloads page, but trunk has been pretty stable.

I just checked out a clean copy of Mongoose from github earlier tonight and built it with no problems, so I can confirm that this works (assuming you have any other dependencies set up properly, of course).

OTHER TIPS

It's because mongoose is not supposed to be used standalone, but to "embed" it into your program. You need to create a program which calls the correct function from mongoose.c.

Also, the -c flag to GCC tells it to create an object file, which needs to be linked to create an executable. So you try to execute a file which is not executable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top