digitalmars.D - Linking Error (WS2_32.LIB)
- Tobse (32/32) Nov 09 2011 Hey,
- Nick Sabalausky (4/41) Nov 09 2011 Not sure whether or not there's some other problem, but try this:
- Tobse (16/16) Nov 09 2011 No, did not work, same result.
- mta`chrono (12/12) Nov 09 2011 After compiling the sources dmd will call optlink to do the linking. I
- Vladimir Panteleev (8/32) Nov 09 2011 These errors don't have anything to do with ws2_32.lib. It looks like yo...
- Tobias M. (5/37) Nov 10 2011 Well, i should have the latest version because i started learning D this...
- mta`chrono (7/7) Nov 10 2011 Did you try to compile tango and druntime on your own or was that a
- Tobias M. (5/12) Nov 10 2011 Ok, so i have downloaded "DMD32 D Compiler v2.056" according to dmd.exe
- Tobias M. (10/23) Nov 10 2011 I recompiled phobos and the runtime as described here:
- mta`chrono (8/8) Nov 10 2011 Hello Tobias,
- Tobias M. (7/15) Nov 10 2011 Well, the documentation of std.socket is a bit confusing for me. The
- Walter Bright (8/28) Nov 10 2011 To compile main.d and link with ws2_32.lib,
- mta`chrono (15/43) Nov 10 2011 Walter, have you looked into his source. What he did was:
- Walter Bright (11/24) Nov 10 2011 You're right.
- Nick Sabalausky (5/36) Nov 10 2011 Isn't this a bug that the compiler accepted it and the error didn't get
- bearophile (4/6) Nov 10 2011 Of course.
- Walter Bright (3/6) Nov 10 2011 No. The reason is the implementation may be in another .obj file known o...
- Nick Sabalausky (4/11) Nov 11 2011 But even if it is, it should still at least be declared in the .d file t...
- Vladimir Panteleev (13/20) Nov 11 2011 I can't see how that makes sense, even with the above (un-idiomatic?)
- Tobias M. (6/24) Nov 11 2011 So, according to all the answers here, i simply have to implement all
Hey, i wanted to write a basic cli chat to get familiar with d. So i looked up the default library for sockets and found std.socket; There is a note that says "compile with ws2_32.lib". When i simply run: dmd main.d it tells me: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address8toStringMFZAya dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address13addressFamilyMFZE3std6socket1 3AddressFamily dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address7nameLenMFZi dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address4nameMFZPS3std1c7windows7winsoc k8sockaddr --- errorlevel 4 So then i tried this: dmd main.d -Llib ws2_32.lib But i keep getting the exact same error plus OPTLINK : Warning 9: Unknown Option : NOILIB doing this: dmd main.d link client.obj -lib ws2_32.lib Its the same again plus OPTLINK : Warning 9: Unknown Option : LIB Can somone please tell me how to link the compiled code correctly so that i can run it? Or is this a bug? Greets, Tobi
Nov 09 2011
"Tobse" <tobias.m onlinehome.de> wrote in message news:j9efl3$2igk$1 digitalmars.com...Hey, i wanted to write a basic cli chat to get familiar with d. So i looked up the default library for sockets and found std.socket; There is a note that says "compile with ws2_32.lib". When i simply run: dmd main.d it tells me: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address8toStringMFZAya dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address13addressFamilyMFZE3std6socket1 3AddressFamily dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address7nameLenMFZi dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address4nameMFZPS3std1c7windows7winsoc k8sockaddr --- errorlevel 4 So then i tried this: dmd main.d -Llib ws2_32.lib But i keep getting the exact same error plus OPTLINK : Warning 9: Unknown Option : NOILIB doing this: dmd main.d link client.obj -lib ws2_32.lib Its the same again plus OPTLINK : Warning 9: Unknown Option : LIB Can somone please tell me how to link the compiled code correctly so that i can run it? Or is this a bug? Greets, TobiNot sure whether or not there's some other problem, but try this: dmd main.d ws2_32.lib
Nov 09 2011
No, did not work, same result. C:\Users\Tobse\Documents\chat>dmd main.d ws2_32.lib -ofdist\client.exe OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address8toStringMFZAya dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address13addressFamilyMFZE3std6socket1 3AddressFamily dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address7nameLenMFZi dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address4nameMFZPS3std1c7windows7winsoc k8sockaddr --- errorlevel 4
Nov 09 2011
After compiling the sources dmd will call optlink to do the linking. I don't know why it's failing, but try to pass -v to dmd to see what's happening. Once you're done, you'll see how it calls optlink which is documented here: http://www.digitalmars.com/ctg/optlink.html Command line operation of OPTLINK uses the following syntax: LINK obj[,out[,map[,lib[,def[,res]]]]] Please also have a look at the environment variables (See link). Optlink will use them as search pathes. But it's also explanied there. I'm not quite sure, because I'm living in the linux world. But maybe you could also use the mingw tools to link ??? - mta`chrono
Nov 09 2011
On Wed, 09 Nov 2011 20:09:39 +0200, Tobse <tobias.m onlinehome.de> wrote:Hey, i wanted to write a basic cli chat to get familiar with d. So i looked up the default library for sockets and found std.socket; There is a note that says "compile with ws2_32.lib". When i simply run: dmd main.d it tells me: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address8toStringMFZAya dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address13addressFamilyMFZE3std6socket1 3AddressFamily dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address7nameLenMFZi dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address4nameMFZPS3std1c7windows7winsoc k8sockaddr --- errorlevel 4These errors don't have anything to do with ws2_32.lib. It looks like you are trying to use the latest version of std.socket sources (from git) with an outdated phobos.lib. Did you download the latest version of std.socket without rebuilding Phobos, or something? -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Nov 09 2011
Am 10.11.2011 02:32, schrieb Vladimir Panteleev:On Wed, 09 Nov 2011 20:09:39 +0200, Tobse <tobias.m onlinehome.de> wrote:Well, i should have the latest version because i started learning D this monday and downloaded the compiler on thuesday. I will try that -v option and maybe mingw works for me. I will also try this pgrama(lib, "ws2_32.lib");Hey, i wanted to write a basic cli chat to get familiar with d. So i looked up the default library for sockets and found std.socket; There is a note that says "compile with ws2_32.lib". When i simply run: dmd main.d it tells me: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address8toStringMFZAya dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address13addressFamilyMFZE3std6socket1 3AddressFamily dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address7nameLenMFZi dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address4nameMFZPS3std1c7windows7winsoc k8sockaddr --- errorlevel 4These errors don't have anything to do with ws2_32.lib. It looks like you are trying to use the latest version of std.socket sources (from git) with an outdated phobos.lib. Did you download the latest version of std.socket without rebuilding Phobos, or something?
Nov 10 2011
Did you try to compile tango and druntime on your own or was that a precompiled package that you've downloaded? Normally make clean and rebuild helps in that case. You could dig the sources of phobos and look if std.socket containts the symbols and then compare them with the symbols of phobos.lib. But unfortunally this is a more advanced task. can you tell me what you've actually downloaded? I've a windows xp virtual maschine here and I'd like to replicate your issue.
Nov 10 2011
Am 10.11.2011 19:21, schrieb mta`chrono:Did you try to compile tango and druntime on your own or was that a precompiled package that you've downloaded? Normally make clean and rebuild helps in that case. You could dig the sources of phobos and look if std.socket containts the symbols and then compare them with the symbols of phobos.lib. But unfortunally this is a more advanced task. can you tell me what you've actually downloaded? I've a windows xp virtual maschine here and I'd like to replicate your issue.Ok, so i have downloaded "DMD32 D Compiler v2.056" according to dmd.exe Ive not come that far with my code so ill attach it as rar. Ill now try to compile the sources on my own, maybe ill get the same error again and then we´ll know where the problem is ;).
Nov 10 2011
Am 10.11.2011 22:31, schrieb Tobias M.:Am 10.11.2011 19:21, schrieb mta`chrono:I recompiled phobos and the runtime as described here: http://www.digitalmars.com/d/2.0/dmd-windows.html#compiling_dmd but i still get the same errors. But there was a warning in the output: Notice: As of Phobos 2.055, std.gregorian has been deprecated. It will be remove d in February 2012. Please use std.datetime instead. So i presume that this is phobos 2.055 and my compiler is 2.056. Might this be the problem?Did you try to compile tango and druntime on your own or was that a precompiled package that you've downloaded? Normally make clean and rebuild helps in that case. You could dig the sources of phobos and look if std.socket containts the symbols and then compare them with the symbols of phobos.lib. But unfortunally this is a more advanced task. can you tell me what you've actually downloaded? I've a windows xp virtual maschine here and I'd like to replicate your issue.Ok, so i have downloaded "DMD32 D Compiler v2.056" according to dmd.exe Ive not come that far with my code so ill attach it as rar. Ill now try to compile the sources on my own, maybe ill get the same error again and then we´ll know where the problem is ;).
Nov 10 2011
Hello Tobias, thanks for attaching your code. I think we're getting closer to the bug. What is class LanAddress : Address { } used for? I don't understand it's purpose. I've modified your code for the usage of TCP/IP. Note: SocketType.RAW is for geeks only ;-). Compile: dmd -m32 main.d ws2_32.lib Usage: main.exe digitalmars.com - mta`chrono
Nov 10 2011
Am 10.11.2011 23:44, schrieb mta`chrono:Hello Tobias, thanks for attaching your code. I think we're getting closer to the bug. What is class LanAddress : Address { } used for? I don't understand it's purpose. I've modified your code for the usage of TCP/IP. Note: SocketType.RAW is for geeks only ;-). Compile: dmd -m32 main.d ws2_32.lib Usage: main.exe digitalmars.com - mta`chronoWell, the documentation of std.socket is a bit confusing for me. The only way to represent an IP that i found was the abstract class Address. And since you cant instantiate abstract classes, i had to extend and re-implement it. But well, then ill continue with that. Thanks for sovling my problem guys.
Nov 10 2011
On 11/9/2011 10:09 AM, Tobse wrote:Hey, i wanted to write a basic cli chat to get familiar with d. So i looked up the default library for sockets and found std.socket; There is a note that says "compile with ws2_32.lib". When i simply run: dmd main.d it tells me: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address8toStringMFZAya dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address13addressFamilyMFZE3std6socket1 3AddressFamily dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address7nameLenMFZi dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address4nameMFZPS3std1c7windows7winsoc k8sockaddr --- errorlevel 4To compile main.d and link with ws2_32.lib, dmd main.d ws2_32.lib will work. However, that is not the problem you're having. There's clearly a mismatch between the phobos.lib you're linking with and the std.socket being read by the compiler. One is out of date with the other. In other words, the undefined symbols reported by the linker appear in std.socket but do not appear in phobos.lib.
Nov 10 2011
Am 10.11.2011 20:46, schrieb Walter Bright:On 11/9/2011 10:09 AM, Tobse wrote:Walter, have you looked into his source. What he did was: --------- BEGIN ---------- import std.socket; class FoobarAddress : Address { } void main() { } ---------- END --------- compile this with dmd -m32 main.d and you'll see exactly the same errors that he posted. Even tough dmd's error message are a little bit confusing in this case, the problem should be clear. - mta`chronoOPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address8toStringMFZAya dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address13addressFamilyMFZE3std6socket1 3AddressFamily dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address7nameLenMFZi dist\client.obj(client) Error 42: Symbol Undefined _D3std6socket7Address4nameMFZPS3std1c7windows7winsoc k8sockaddr --- errorlevel 4To compile main.d and link with ws2_32.lib, dmd main.d ws2_32.lib will work. However, that is not the problem you're having. There's clearly a mismatch between the phobos.lib you're linking with and the std.socket being read by the compiler. One is out of date with the other. In other words, the undefined symbols reported by the linker appear in std.socket but do not appear in phobos.lib.
Nov 10 2011
On 11/10/2011 2:50 PM, mta`chrono wrote:Walter, have you looked into his source. What he did was: --------- BEGIN ---------- import std.socket; class FoobarAddress : Address { } void main() { } ---------- END --------- compile this with dmd -m32 main.d and you'll see exactly the same errors that he posted. Even tough dmd's error message are a little bit confusing in this case, the problem should be clear.You're right. And the problem is that Address is an *abstract* class, defined as: abstract class Address { protected sockaddr* name(); protected int nameLen(); AddressFamily addressFamily(); override string toString(); } This means that anyone deriving from it needs to implement those functions.
Nov 10 2011
"Walter Bright" <newshound2 digitalmars.com> wrote in message news:j9hp3g$aqd$1 digitalmars.com...On 11/10/2011 2:50 PM, mta`chrono wrote:Isn't this a bug that the compiler accepted it and the error didn't get raised until it got all the way to the linker? Doesn't the compiler normally catch that before it gets to the linker?Walter, have you looked into his source. What he did was: --------- BEGIN ---------- import std.socket; class FoobarAddress : Address { } void main() { } ---------- END --------- compile this with dmd -m32 main.d and you'll see exactly the same errors that he posted. Even tough dmd's error message are a little bit confusing in this case, the problem should be clear.You're right. And the problem is that Address is an *abstract* class, defined as: abstract class Address { protected sockaddr* name(); protected int nameLen(); AddressFamily addressFamily(); override string toString(); } This means that anyone deriving from it needs to implement those functions.
Nov 10 2011
Nick Sabalausky:Isn't this a bug that the compiler accepted it and the error didn't get raised until it got all the way to the linker?Of course. Bye, bearophile
Nov 10 2011
On 11/10/2011 5:10 PM, Nick Sabalausky wrote:Isn't this a bug that the compiler accepted it and the error didn't get raised until it got all the way to the linker? Doesn't the compiler normally catch that before it gets to the linker?No. The reason is the implementation may be in another .obj file known only to the linker.
Nov 10 2011
"Walter Bright" <newshound2 digitalmars.com> wrote in message news:j9i0c5$mlb$1 digitalmars.com...On 11/10/2011 5:10 PM, Nick Sabalausky wrote:But even if it is, it should still at least be declared in the .d file that has the class's definition, shouldn't it?Isn't this a bug that the compiler accepted it and the error didn't get raised until it got all the way to the linker? Doesn't the compiler normally catch that before it gets to the linker?No. The reason is the implementation may be in another .obj file known only to the linker.
Nov 11 2011
On Fri, 11 Nov 2011 04:12:43 +0200, Walter Bright <newshound2 digitalmars.com> wrote:On 11/10/2011 5:10 PM, Nick Sabalausky wrote:I can't see how that makes sense, even with the above (un-idiomatic?) idea. The compiler should not emit references to *abstract* methods. I think this looks like a case of class attributes not affecting methods: "Address" is declared as an abstract class, but the compiler doesn't realize that its methods are abstract too. They are simply declared as method declarations without a body. This is similar to another old bug (now fixed, I believe), when methods of "final" classes were still implicitly virtual. -- Best regards, Vladimir mailto:vladimir thecybershadow.netIsn't this a bug that the compiler accepted it and the error didn't get raised until it got all the way to the linker? Doesn't the compiler normally catch that before it gets to the linker?No. The reason is the implementation may be in another .obj file known only to the linker.
Nov 11 2011
Am 11.11.2011 13:29, schrieb Vladimir Panteleev:On Fri, 11 Nov 2011 04:12:43 +0200, Walter Bright <newshound2 digitalmars.com> wrote:So, according to all the answers here, i simply have to implement all methods from Address then? Ok, so if thats the point im fine with it. I just thought (as it is in Java and PHP), that methods in abstract classes need to have a body too. If an extending class isn´t implementing those, theyll simply get copied.On 11/10/2011 5:10 PM, Nick Sabalausky wrote:I can't see how that makes sense, even with the above (un-idiomatic?) idea. The compiler should not emit references to *abstract* methods. I think this looks like a case of class attributes not affecting methods: "Address" is declared as an abstract class, but the compiler doesn't realize that its methods are abstract too. They are simply declared as method declarations without a body. This is similar to another old bug (now fixed, I believe), when methods of "final" classes were still implicitly virtual.Isn't this a bug that the compiler accepted it and the error didn't get raised until it got all the way to the linker? Doesn't the compiler normally catch that before it gets to the linker?No. The reason is the implementation may be in another .obj file known only to the linker.
Nov 11 2011