www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - (newbie) How to import foreign (Windows) DLLs?

reply Nahon <lburger hu.tesco-europe.com> writes:
Hi.

I've read about the subject anything I could find but I've found no solution.
I want to use std.socket but as I get to Socket.select() I get more than a
page full of error messages (see below). The Phobos documentation says that
link using ws2_32.dll, but how? I've converted it to .lib but I found no way
to build it into my project. (I can not link the sample listen.d either.) I've
tried to pass it within the command line parameters, used pragma() and in my
last exasperation I've tried import...
What would solve this?

Error messages:
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _getprotobyname 4
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _getprotobynumber 4
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _getservbyname 8
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _getservbyport 8
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _WSAGetLastError 0
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _gethostbyname 4
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _gethostbyaddr 12
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _inet_addr 4
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _inet_ntoa 4
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _ioctlsocket 12
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _getsockopt 20
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _bind 12
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _connect 12
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _listen 8
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _accept 12
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _closesocket 4
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _shutdown 8
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _getpeername 12
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _getsockname 12
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _send 16
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _sendto 24
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _recv 16
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _recvfrom 24
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _setsockopt 20
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _select 20
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _WSAStartup 8
c:\DMD\bin\..\lib\phobos.lib(socket)
 Error 42: Symbol Undefined _WSACleanup 0
--- errorlevel 27


Regards,
Nahon
Oct 25 2006
parent reply "Chris Miller" <chris dprogramming.com> writes:
On Wed, 25 Oct 2006 05:08:33 -0400, Nahon <lburger hu.tesco-europe.com>  
wrote:

 Hi.

 I've read about the subject anything I could find but I've found no  
 solution.
 I want to use std.socket but as I get to Socket.select() I get more than  
 a
 page full of error messages (see below). The Phobos documentation says  
 that
 link using ws2_32.dll, but how? I've converted it to .lib but I found no  
 way
 to build it into my project. (I can not link the sample listen.d  
 either.) I've
 tried to pass it within the command line parameters, used pragma() and  
 in my
 last exasperation I've tried import...
 What would solve this?

 Error messages:
 c:\DMD\bin\..\lib\phobos.lib(socket)
  Error 42: Symbol Undefined _getprotobyname 4
Add ws2_32.lib to your command line; this file is already provided with DMD, you should not generate it.
Oct 25 2006
parent Nahon <lburger hu.tesco-europe.com> writes:
 Hi.

 I've read about the subject anything I could find but I've found no
 solution.
 I want to use std.socket but as I get to Socket.select() I get more than
 a
 page full of error messages (see below). The Phobos documentation says
 that
 link using ws2_32.dll, but how? I've converted it to .lib but I found no
 way
 to build it into my project. (I can not link the sample listen.d
 either.) I've
 tried to pass it within the command line parameters, used pragma() and
 in my
 last exasperation I've tried import...
 What would solve this?

 Error messages:
 c:\DMD\bin\..\lib\phobos.lib(socket)
  Error 42: Symbol Undefined _getprotobyname 4
Add ws2_32.lib to your command line; this file is already provided with
DMD, you should not generate it.
It works using the provided .lib, thank you. But why not with the implib-ed one?
Oct 25 2006