Linking to mingw libraries.

I'm developing a server application that must use the winsock api under windows. when i compile my program with mingw, i get the following errors at the link step:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
C:\DOCUME~1\WDOUGL~1\LOCALS~1\Temp/ccet1QMR.o: In function `server_thread':
T:\wed\winroute/uslnplib.c:689: undefined reference to `listen@8'
T:\wed\winroute/uslnplib.c:695: undefined reference to `AcceptEx@32'
T:\wed\winroute/uslnplib.c:710: undefined reference to `closesocket@4'
C:\DOCUME~1\WDOUGL~1\LOCALS~1\Temp/ccet1QMR.o: In function `init_uslnplib':
T:\wed\winroute/uslnplib.c:727: undefined reference to `WSAStartup@8'
C:\DOCUME~1\WDOUGL~1\LOCALS~1\Temp/ccet1QMR.o: In function `start_server':
T:\wed\winroute/uslnplib.c:782: undefined reference to `getaddrinfo@16'
T:\wed\winroute/uslnplib.c:797: undefined reference to `socket@12'
T:\wed\winroute/uslnplib.c:802: undefined reference to `freeaddrinfo@4'
T:\wed\winroute/uslnplib.c:803: undefined reference to `WSACleanup@0'
T:\wed\winroute/uslnplib.c:807: undefined reference to `setsockopt@20'
T:\wed\winroute/uslnplib.c:811: undefined reference to `closesocket@4'
T:\wed\winroute/uslnplib.c:815: undefined reference to `bind@12'
T:\wed\winroute/uslnplib.c:818: undefined reference to `freeaddrinfo@4'
T:\wed\winroute/uslnplib.c:819: undefined reference to `closesocket@4'
T:\wed\winroute/uslnplib.c:820: undefined reference to `WSACleanup@0' 


here's my makefile:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
CC = gcc
LIBPATH = -L"C:/MinGW/lib/"
LIBS   = -lwsock32 -lws2_32
CFLAGS =  -Wall -mthreads --std=c99 -ggdb -DWIN32 -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 $(LIBPATH) $(LIBS)

all: uslnp.exe

dlls: generic.dll uslnplib.dll

uslnp.exe: uslnplib.lib main.c router.c
	$(CC) $(CFLAGS) -L./ -o uslnp.exe router.c main.c uslnplib.lib

%.dll %.lib: %.c
	$(CC) $(CFLAGS) -shared -o $(patsubst %.c,%.dll,$<) \
      -Wl,--out-implib=$(patsubst %.c,%.lib,$<) \
      -Wl,--export-all-symbols \
      -Wl,--enable-auto-import \
      $<

clean:
	$(RM) *.o *.lib *.exe *.dll


it doesn't complain about not finding the libraries, what gives? has anyone seen this?
Last edited on
Typically you compile and link in 2 different steps. Have you tried to compile them manually from the command line then link?
Topic archived. No new replies allowed.