compile dll in c with winsock2.h

Asked

Viewed 205 times

0

I am using Dev-C++ and trying to compile a dll, however I always get this error in Compiler:

Compiling project changes...
--------
- Project Filename: E:\blackfish\integration\blackfish\blackfish.dev
- Compiler Name: TDM-GCC 4.9.2 32-bit Release

Building makefile...
--------
- Filename: E:\blackfish\integration\blackfish\Makefile.win

Processing makefile...
--------
- Makefile Processor: C:\Program Files\Dev-Cpp\MinGW64\bin\mingw32-make.exe
- Command: mingw32-make.exe -f "E:\blackfish\integration\blackfish\Makefile.win" all

g++.exe -shared dllmain.o -o blackfish.dll -L"C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib32" -m32 -Wl,--output-def,libblackfish.def,--out-implib,libblackfish.a,--add-stdcall-alias
dllmain.o:dllmain.cpp:(.text+0x27d): undefined reference to `_imp__WSAStartup@8'
dllmain.o:dllmain.cpp:(.text+0x290): undefined reference to `_imp__WSAGetLastError@0'
dllmain.o:dllmain.cpp:(.text+0x2be): undefined reference to `_imp__socket@12'
dllmain.o:dllmain.cpp:(.text+0x2d6): undefined reference to `_imp__WSAGetLastError@0'
dllmain.o:dllmain.cpp:(.text+0x2f3): undefined reference to `_imp__inet_addr@4'
dllmain.o:dllmain.cpp:(.text+0x30d): undefined reference to `_imp__htons@4'
dllmain.o:dllmain.cpp:(.text+0x331): undefined reference to `_imp__connect@12'
dllmain.o:dllmain.cpp:(.text+0x365): undefined reference to `_imp__send@16'
dllmain.o:dllmain.cpp:(.text+0x38f): undefined reference to `_imp__recv@16'
dllmain.o:dllmain.cpp:(.text+0x3e1): undefined reference to `_imp__SysAllocStringByteLen@8'
dllmain.o:dllmain.cpp:(.text+0x3f4): undefined reference to `_imp__closesocket@4'
dllmain.o:dllmain.cpp:(.text+0x3fe): undefined reference to `_imp__WSACleanup@0'
dllmain.o:dllmain.cpp:(.text+0x65d): undefined reference to `_imp__WSAStartup@8'
dllmain.o:dllmain.cpp:(.text+0x670): undefined reference to `_imp__WSAGetLastError@0'
dllmain.o:dllmain.cpp:(.text+0x69e): undefined reference to `_imp__socket@12'
dllmain.o:dllmain.cpp:(.text+0x6b6): undefined reference to `_imp__WSAGetLastError@0'
dllmain.o:dllmain.cpp:(.text+0x6d3): undefined reference to `_imp__inet_addr@4'
dllmain.o:dllmain.cpp:(.text+0x6ed): undefined reference to `_imp__htons@4'
dllmain.o:dllmain.cpp:(.text+0x711): undefined reference to `_imp__connect@12'
dllmain.o:dllmain.cpp:(.text+0x745): undefined reference to `_imp__send@16'
dllmain.o:dllmain.cpp:(.text+0x76f): undefined reference to `_imp__recv@16'
dllmain.o:dllmain.cpp:(.text+0x7c1): undefined reference to `_imp__SysAllocStringByteLen@8'
dllmain.o:dllmain.cpp:(.text+0x7d4): undefined reference to `_imp__closesocket@4'
dllmain.o:dllmain.cpp:(.text+0x7de): undefined reference to `_imp__WSACleanup@0'
dllmain.o:dllmain.cpp:(.text+0xa51): undefined reference to `_imp__WSAStartup@8'
dllmain.o:dllmain.cpp:(.text+0xa64): undefined reference to `_imp__WSAGetLastError@0'
dllmain.o:dllmain.cpp:(.text+0xa92): undefined reference to `_imp__socket@12'
dllmain.o:dllmain.cpp:(.text+0xaaa): undefined reference to `_imp__WSAGetLastError@0'
dllmain.o:dllmain.cpp:(.text+0xac7): undefined reference to `_imp__inet_addr@4'
dllmain.o:dllmain.cpp:(.text+0xae1): undefined reference to `_imp__htons@4'
dllmain.o:dllmain.cpp:(.text+0xb05): undefined reference to `_imp__connect@12'
dllmain.o:dllmain.cpp:(.text+0xb39): undefined reference to `_imp__send@16'
dllmain.o:dllmain.cpp:(.text+0xb63): undefined reference to `_imp__recv@16'
dllmain.o:dllmain.cpp:(.text+0xbb5): undefined reference to `_imp__SysAllocStringByteLen@8'
dllmain.o:dllmain.cpp:(.text+0xbc8): undefined reference to `_imp__closesocket@4'
dllmain.o:dllmain.cpp:(.text+0xbd2): undefined reference to `_imp__WSACleanup@0'
dllmain.o:dllmain.cpp:(.text+0xe45): undefined reference to `_imp__WSAStartup@8'
dllmain.o:dllmain.cpp:(.text+0xe58): undefined reference to `_imp__WSAGetLastError@0'
dllmain.o:dllmain.cpp:(.text+0xe86): undefined reference to `_imp__socket@12'
dllmain.o:dllmain.cpp:(.text+0xe9e): undefined reference to `_imp__WSAGetLastError@0'
dllmain.o:dllmain.cpp:(.text+0xebb): undefined reference to `_imp__inet_addr@4'
dllmain.o:dllmain.cpp:(.text+0xed5): undefined reference to `_imp__htons@4'
dllmain.o:dllmain.cpp:(.text+0xef9): undefined reference to `_imp__connect@12'
dllmain.o:dllmain.cpp:(.text+0xf2d): undefined reference to `_imp__send@16'
dllmain.o:dllmain.cpp:(.text+0xf57): undefined reference to `_imp__recv@16'
dllmain.o:dllmain.cpp:(.text+0xfa9): undefined reference to `_imp__SysAllocStringByteLen@8'
dllmain.o:dllmain.cpp:(.text+0xfbc): undefined reference to `_imp__closesocket@4'
dllmain.o:dllmain.cpp:(.text+0xfc6): undefined reference to `_imp__WSACleanup@0'
dllmain.o:dllmain.cpp:(.text+0x109c): undefined reference to `_imp__SysAllocStringByteLen@8'
dllmain.o:dllmain.cpp:(.text+0x1173): undefined reference to `_imp__SysAllocStringByteLen@8'
collect2.exe: error: ld returned 1 exit status
E:\blackfish\integration\blackfish\Makefile.win:27: recipe for target 'blackfish.dll' failed
mingw32-make.exe: *** [blackfish.dll] Error 1

After several searches, many people point to the compilation with the -lws2_32 configured, but performed the operation and unsuccessfully, tried other things and nothing yet, someone could give me an idea of what might be the problem ?

1 answer

0


The solution to build without errors is to use the following linkers:

-static-libgcc -lws2_32 -lole32 -loleaut32

Browser other questions tagged

You are not signed in. Login or sign up in order to post.