I had modified make file as
linux:
$(CC) mongoose.c -shared -fPIC -fpic -m32 -o $(LIB) $(LINFLAGS)
$(CC) mongoose.c main.c -m32 -o $(PROG) $(LINFLAGS)
But when I run ld on mongoose I gets. I am getting warning that it is incompatible with i386
ld mongoose
ld: warning: i386 architecture of input file `mongoose' is incompatible with i386:x86-64 output
ld is trying to create an x86-64 executable from your x86-32 object files, and is unhappy because that isn’t something that makes sense. Use GCC to link instead of ld, passing the -m32 at link as well, and it will call the linker with the correct flags for linking x86-32 binaries.