0

I have written a python script expanded in winxp with mingw+msys compiled. It will call libevent lib. I hope that user don't install more library, so I want to compile it statically, but there are errors. The following is my process to compile and install libevent:

​./configure -prefix=D:/libevent -enable-static
make
make install  

I wrote two makefiles and I get the same error.

libevent.a(buffer.o):In function 'evbuffer_read':undefined reference to 'WSARecv@28' 
libevent.a(buffer.o):In function 'evbuffer_write_iovec':undefined reference to 'WSASend@28' 
........................

Here are the makefiles:

makefile 1

HEAD_PATH_FLAGS=-IC:/Python27/include -ID:/boost/include/boost-1_52 -ID:/libevent/include
LIB_PATH_FLAGS=-LD:/boost/lib -LD:/libevent/lib -LC:/Python27/libs
LIB_FLAGS=-lboost_python-mgw46-s-1_52 -Wl,Bstatic -levent -Wl,Bdynamic -lpython27 -lwsock32
SOURCE=test.o 
all:${SOURCE}
g++ ${HEAD_PATH_FLAGS} ${SOURCE} ${LIB_PATH_FLAG} ${LIB_FLAGS} -fPIC -shared -o test.dll

makefile 2

HEAD_PATH_FLAGS=-IC:/Python27/include -ID:/boost/include/boost-1_52 -ID:/libevent/include
LIB_PATH_FLAGS=-LD:/boost/lib -LD:/libevent/lib -LC:/Python27/libs
LIB_FLAGS=-lboost_python-mgw46-s-1_52 -lpython27 -lwsock32
SOURCE=test.o D:/libevent/lib/libevent.a
all:${SOURCE}
g++ ${HEAD_PATH_FLAGS} ${SOURCE} ${LIB_PATH_FLAG} ${LIB_FLAGS} -fPIC -shared -o test.dll

Why does this happen? How do I get this to compile without errors?

jpaugh
  • 6,634
  • 4
  • 38
  • 90
simon
  • 569
  • 9
  • 20

1 Answers1

4

You should link to libws2_32.a, as WSASend and WSARecv defined there. Add -lws2_32 to your linker commands.

Lol4t0
  • 12,444
  • 4
  • 29
  • 65