News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Making a DLL/SO for Linux and Windows ...

Started by James Ladd, September 15, 2006, 11:44:38 PM

Previous topic - Next topic

James Ladd

Below is the Makefile I have ended up with for my projects.

I am posting it here as I had a lot of trouble trying to cleanly write a Makefile that worked of for both linux and win32.
Under win32 you need to use cygwin.

The makefile assumes you are building one dll, called libjlc.dll and each C program is going to become a single
executable.

I use GCC to assemble the Gnu Assembler source (.s) as this was more reliable and cleaner than an AS/LD
combination.

It's not a fantastic Makefile, but it does work !


LPFX=-L. -l
LEXT=.so
ASFLAGS=-gstabs
CCFLAGS:=$(ASFLAGS)
BINS=$(patsubst %.c,%,$(wildcard test*.c))

ifeq ($(OS),Windows_NT)
LPFX:=lib
LEXT:=.dll
ASFLAGS:=$(ASFLAGS) --defsym WIN=1
BINS:=$(patsubst %.c,%.exe,$(wildcard test*.c))
endif

all: libjlc$(LEXT) $(BINS)

libjlc.so: libjlc.o
gcc -shared -o libjlc.so $<

libjlc.dll: libjlc.o
gcc -shared -o libjlc.dll libjlc.o libjlc.def -Wl,--out-implib,libjlc.a

test%:
gcc $(CCFLAGS) -o test$* $(LPFX)jlc$(LEXT) testAlibjlc.c

clean:
rm -f *.so *.o *.a *.dll $(BINS)

.s.o:
as $(ASFLAGS) -o $*.o $<


Put this in a Makefile and then from the xterm or cygwin term type make.