www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - pragma(lib,...)

reply "Lionello Lunesu" <lio remove.lunesu.com> writes:
Hi,

I'm having some problems with "pragma(lib,..)". I have a 1 module D program, 
main.d, to test a socket connection. It imports std.socket, whcih used to 
work just fine, without the need to provide a lib. With DMD 0.149 however 
(don't know when this issue was introduced) it won't find the winsock 
imports:

 D:\llunesu>dmd main
 C:\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 C:\dmd\bin\..\lib\phobos.lib(socket)
  Error 42: Symbol Undefined _getprotobyname 4
<and many more>

When I provide the lib name on the command line it works fine:

 D:\llunesu>dmd main WSOCK32.LIB
 C:\dmd\bin\..\..\dm\bin\link.exe main,,,WSOCK32.LIB+user32+kernel32/noi;

But when I specifiy pragma(lib,"WSOCK32.LIB") (which works just fine in 
other projects) I get:

 D:\llunesu>dmd main
 C:\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

OPTLINK : Warning 23: No Stack
main.obj(main)
 Error 42: Symbol Undefined __init_11TypeInfo_Aa
main.obj(main)
 Error 42: Symbol Undefined __nullext
main.obj(main)
 Error 42: Symbol Undefined __ModuleInfo_3std5stdio
main.obj(main)
 Error 42: Symbol Undefined __ModuleInfo_3std7cstream
main.obj(main)
 Error 42: Symbol Undefined __ModuleInfo_3std6socket
OPTLINK : Warning 134: No Start Address
--- errorlevel 5


Any idea?

L. 
Mar 13 2006
next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Lionello Lunesu" <lio remove.lunesu.com> wrote in message 
news:dv439r$2urg$1 digitaldaemon.com...
 When I provide the lib name on the command line it works fine:

Are you putting the pragma in main.d, or just in an imported module that doesn't get compiled?
Mar 13 2006
parent "Lionello Lunesu" <lio remove.lunesu.com> writes:
 Are you putting the pragma in main.d, or just in an imported module that 
 doesn't get compiled?

In main.d, right after the imports. I only import std.stdio and std.socket.. L.
Mar 13 2006
prev sibling parent reply jicman <jicman_member pathlink.com> writes:
Use build? :-)

Lionello Lunesu says...
Hi,

I'm having some problems with "pragma(lib,..)". I have a 1 module D program, 
main.d, to test a socket connection. It imports std.socket, whcih used to 
work just fine, without the need to provide a lib. With DMD 0.149 however 
(don't know when this issue was introduced) it won't find the winsock 
imports:

 D:\llunesu>dmd main
 C:\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 C:\dmd\bin\..\lib\phobos.lib(socket)
  Error 42: Symbol Undefined _getprotobyname 4
<and many more>

When I provide the lib name on the command line it works fine:

 D:\llunesu>dmd main WSOCK32.LIB
 C:\dmd\bin\..\..\dm\bin\link.exe main,,,WSOCK32.LIB+user32+kernel32/noi;

But when I specifiy pragma(lib,"WSOCK32.LIB") (which works just fine in 
other projects) I get:

 D:\llunesu>dmd main
 C:\dmd\bin\..\..\dm\bin\link.exe main,,,user32+kernel32/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

OPTLINK : Warning 23: No Stack
main.obj(main)
 Error 42: Symbol Undefined __init_11TypeInfo_Aa
main.obj(main)
 Error 42: Symbol Undefined __nullext
main.obj(main)
 Error 42: Symbol Undefined __ModuleInfo_3std5stdio
main.obj(main)
 Error 42: Symbol Undefined __ModuleInfo_3std7cstream
main.obj(main)
 Error 42: Symbol Undefined __ModuleInfo_3std6socket
OPTLINK : Warning 134: No Start Address
--- errorlevel 5


Any idea?

L. 

Mar 13 2006
parent reply "Lionello Lunesu" <lio remove.lunesu.com> writes:
"jicman" <jicman_member pathlink.com> wrote in message 
news:dv55d8$1had$1 digitaldaemon.com...
 Use build? :-)

??? I get the same linker output if I use build. Futhermore, I have to manually delete main.obj after each try, since "Files are up to date, no build required." (eventhough the previous builds had linker errors). OPTLINK is still creating an .exe, apparently.. L.
Mar 13 2006
parent Derek Parnell <Derek_member pathlink.com> writes:
In article <dv5qv3$296q$1 digitaldaemon.com>, Lionello Lunesu says...
"jicman" <jicman_member pathlink.com> wrote in message 
news:dv55d8$1had$1 digitaldaemon.com...
 Use build? :-)

??? I get the same linker output if I use build. Futhermore, I have to manually delete main.obj after each try, since "Files are up to date, no build required." (eventhough the previous builds had linker errors). OPTLINK is still creating an .exe, apparently..

Try using Build again but with ... version(build) pragma(link, "wsock32.lib"); and use the -full switch to force a full recompile.
Mar 14 2006