FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problems with wsock32

 
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries
View previous topic :: View next topic  
Author Message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Wed Apr 26, 2006 10:55 pm    Post subject: Reply with quote

I tried the latest drop, Eric, and got a little further than before Smile

Loading mango.lib now works, but a GPF is thrown when the "executable" is being bound (I guess). So, I stripped some things down until I got to mango.io.Socket ~ which needs wsock32 (on Windows) to run. So, I added that to the list of libraries, but DDL refuses to load it. An error is thrown saying "can't find library wsock32.lib", although it's right there with the others.

It's odd, because there's no problem loading user32.lib, or kernel32.lib ...
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Thu Apr 27, 2006 7:36 am    Post subject: Reply with quote

kris wrote:
I tried the latest drop, Eric, and got a little further than before Smile

Loading mango.lib now works, but a GPF is thrown when the "executable" is being bound (I guess). So, I stripped some things down until I got to mango.io.Socket ~ which needs wsock32 (on Windows) to run. So, I added that to the list of libraries, but DDL refuses to load it. An error is thrown saying "can't find library wsock32.lib", although it's right there with the others.

It's odd, because there's no problem loading user32.lib, or kernel32.lib ...


Are you explicitly loading wsock32.lib via DDL?

It could be that the user32.lib and kernel32.lib parts are integrated into your .exe before you even start, thanks to dependencies that your core executable has. Check the symbol listing from your .map or .situ file and I think you'll find that kernel32 and user32 are statically linked. Smile

As for wsock32, I'll develop a test case for this and work on it. As a workaround, try to coerce wsock32 to be statically linked into your .exe.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Thu Apr 27, 2006 10:18 am    Post subject: Reply with quote

yes; explicitly loading wsock32.lib via DDL, loadAndRegister(). I just noticed that the code below eats the exception text -- I'll check that right now ...

Code:
module  host;

import  std.stdio;

import  ddl.Linker,
        ddl.DefaultRegistry;

import  utils.ArgParser;

int main (char[][] args)
{
        int     ret;

        if (args.length > 1)
           {
           // load the statically-linked symbols for this executable
           auto linker = new Linker (new DefaultRegistry);
           linker.loadAndRegister ("host.ddl");

           // get dash prefixed args
           ArgParser parser = new ArgParser;
           parser.bind ("-", "l", delegate uint(char[] value) {
                        try {
                            writefln ("loading '?s'", value);
                            linker.loadAndRegister (value);
                            } catch (Exception)
                                    {writefln ("cannot find library '?s'", value);}
                        return value.length;
                        });
           parser.parse (args[2..$]);

           // load the application file
           auto app = linker.loadAndLink (args[1]);

           // and locate the entry point
           auto entry = app.getDExport!(void function(Linker, char[][]), "app.entry")();

           try {
               entry (linker, args[1..$]);
               } catch (Object o)
                       {
                       ret = -1;
                       throw o;
                       }
           }
        else
           writefln ("usage is: host AppPath [-lLibName] [args]");
        return ret;
}
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Thu Apr 27, 2006 10:22 am    Post subject: Reply with quote

OK, the exception thrown for wsock32.lib is an "end of input" error
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Thu Apr 27, 2006 10:25 am    Post subject: Reply with quote

kris wrote:
yes; explicitly loading wsock32.lib via DDL, loadAndRegister(). I just noticed that the code below eats the exception text -- I'll check that right now ... [snip]


I like that. Just pass call with "-lphobos.lib -lsnn.lib" and you're in business. Nice.

The only thing I can think of then is that its still an OMF and/or implib problem with loading winsock, which is nothing really new - I just need more tests and benchmarks to bring the code quality up I'm afraid, so thanks!! Smile

Also, does winsock load properly via ddlinfo? Typically, that's the fastest way to determine if the problem is with a loader or the linker.

Again, thanks for the feedback Kris.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Thu Apr 27, 2006 10:39 am    Post subject: Reply with quote

pragma wrote:
Also, does winsock load properly via ddlinfo?

I'm afraid I don't understand. You'll need to step me through that one Smile
Back to top
View user's profile Send private message
larsivi
Site Admin


Joined: 27 Mar 2004
Posts: 453
Location: Trondheim, Norway

PostPosted: Thu Apr 27, 2006 10:42 am    Post subject: Reply with quote

kris wrote:
pragma wrote:
Also, does winsock load properly via ddlinfo?

I'm afraid I don't understand. You'll need to step me through that one Smile


just run

ddlinfo wsock32.lib

and see what happens. ddlinfo should be found in the utils directory.
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Thu Apr 27, 2006 10:55 am    Post subject: Reply with quote

Thanks, Larsivi.

Code:
C:\d\mango\example\WebServer>ddlinfo wsock32.lib
Error: end of input

C:\d\mango\example\WebServer>
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Thu Apr 27, 2006 11:40 am    Post subject: Reply with quote

kris wrote:
Thanks, Larsivi.

Code:
C:\d\mango\example\WebServer>ddlinfo wsock32.lib
Error: end of input

C:\d\mango\example\WebServer>


I've opened a ticket for this, as its obviously a bug:

http://www.dsource.org/projects/ddl/ticket/46#preview

Don't worry about compiling with -debug or anything like that. I should be able to reproduce it easily enough.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Sat Apr 29, 2006 11:38 am    Post subject: Reply with quote

Kris, I have a patch in SVN now that should do the trick - the current SDK and utils links include the changes. The ticket link has more information as to what was fixed - basically it was a one-liner. Wink

I had zero trouble running the following:
Code:

examples\host examples\mule.obj -lphobos.lib -lsnn.lib -lwsock32.lib


Enjoy.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Sat Apr 29, 2006 5:54 pm    Post subject: Reply with quote

Thanks ... now I'll go and break it Wink
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Sat Apr 29, 2006 6:19 pm    Post subject: Reply with quote

Spoke too soon ~ downloaded the latest zips, rebuilt everything, and now the mule.d that previously worked no longer does anything. Host.exe just loads up the libraries and quits (no message)
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Sat Apr 29, 2006 7:42 pm    Post subject: Reply with quote

Quote:
Thanks ... now I'll go and break it Wink


And that's why I can count on you Kris. Seriously, thanks for helping out. Smile

This is all just strange. I had to double-check to make sure that I was getting valid output:

Code:
loading 'phobos.lib'
loading 'snn.lib'
loading 'wsock32.lib'
Mule loaded!
0 = examples\mule.obj
1 = -lphobos.lib
2 = -lsnn.lib
3 = -lwsock32.lib
Done.


Looks like I should put the old windows box back online for validation purposes. Something isn't right here.

I did make a subtle change to the buildexamples.d script - did you rebuild that as well? (yea, yea, I should've mentioned that earlier)
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Sat Apr 29, 2006 8:34 pm    Post subject: Reply with quote

Right now it's a bit of a hassle to switch back and forth between Phobos and Ares, because I've got my environment all torn asunder. The issue I ran into may reflect this state of flux, since I have made a few silly blunders recently Embarassed

Will retry when things stablize again.

BTW, you already know that DDL doesn't yet compile under Ares ~ I guess it is just the zlib stuff that's missing? If so, then I'll pester Sean about that Smile
Back to top
View user's profile Send private message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Sun Apr 30, 2006 10:55 am    Post subject: Reply with quote

kris wrote:
Right now it's a bit of a hassle to switch back and forth between Phobos and Ares, because I've got my environment all torn asunder. The issue I ran into may reflect this state of flux, since I have made a few silly blunders recently Embarassed

Will retry when things stablize again.


Take your time. I'm going to set up a secondary windows environment so I can better validate things. Perhaps Box #2 will be the Ares test area. Wink

Quote:

BTW, you already know that DDL doesn't yet compile under Ares ~ I guess it is just the zlib stuff that's missing? If so, then I'll pester Sean about that Smile


I am aware of this, and have given the situation some thought. DDL has a little ways to go before it's 100? ready for Ares. FYI, the project currently has the following dependencies:

- std.zip for the up-and-coming zip loader and various sdk utils
- std.demangle - to stay in lock-step with spec changes
- std.moduleinit - for DMD/ABI compatbility for module initalization (Linker.d)

For what it's worth, I personally find the utiltiy of std.zip to be justification enough for having it in an emerging library like Ares - its just nice to be able to work with a (de facto) standard compression type out of the box. As for my thoughts on the matter, I'm of two minds about where std.zip should go.

On the one hand, we could just use the phobos version outright. Sean could even do a nice thing here and use the most recent zlib binary and make the improvements available to Walter for inclusion into Phobos.

On the other hand, having that extra C lib linkage in a standard library kind of flies in the face of that old "eat your own dogfood" addage. It would be *really* nice to have that library 100? ported over to D just to make life a little easier. I've looked at the source before, and its a bit involved, but the headers seem to be pretty free of macros, so bringing it over wouldn't be a huge undertaking. Its also fairly mature software, so I doubt a port would ever fall far behind the main C release.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group