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

Building DLL's

 
Post new topic   Reply to topic     Forum Index -> Build
View previous topic :: View next topic  
Author Message
pragma



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

PostPosted: Fri Mar 25, 2005 8:59 pm    Post subject: Building DLL's Reply with quote

Derek, I have to say: this is a great tool. As of last week, I deleted my make files and batch scripts and haven't looked back.

I hit a snag with trying to coerce Build to create a dll. The program outputs an .exe file, which has to be renamed to a .dll file to work.

I've tried to use the '-of' option, with no luck. Apparently, "-of" is being overridden in the .rsp file, which explains why the output is always an .exe file.

Also, 'pragma(target,"foobar.dll");' doesn't do the job either. I'm not sure what I'm missing here.

Thanks,
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Sat Mar 26, 2005 12:43 am    Post subject: Re: Building DLL's Reply with quote

pragma wrote:
Derek, I have to say: this is a great tool. As of last week, I deleted my make files and batch scripts and haven't looked back.

I hit a snag with trying to coerce Build to create a dll. The program outputs an .exe file, which has to be renamed to a .dll file to work.

I've tried to use the '-of' option, with no luck. Apparently, "-of" is being overridden in the .rsp file, which explains why the output is always an .exe file.

Also, 'pragma(target,"foobar.dll");' doesn't do the job either. I'm not sure what I'm missing here.

Thanks,


Yep, DLL creation was on my list of things to do, so I guess its about time I did it Laughing

Give me few hours, okay ...?
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Sat Mar 26, 2005 12:34 pm    Post subject: Reply with quote

This is proving to be a bit more difficult than first thought.

I can get the DLL built, but I can't seem to be able to access the routines within it. Are you using the 'implib' method or the 'exports' method?
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
pragma



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

PostPosted: Sun Mar 27, 2005 8:21 pm    Post subject: Reply with quote

Derek Parnell wrote:
This is proving to be a bit more difficult than first thought.

I can get the DLL built, but I can't seem to be able to access the routines within it. Are you using the 'implib' method or the 'exports' method?


I'm using the 'exports' method with a Build-generated build file.

Code:

version(build){      
   version(DigitalMars) version(build){
      pragma(build_def,"   
      LIBRARY         'My Library'
      DESCRIPTION     'D Library'

      EXETYPE         NT
      SUBSYSTEM       WINDOWS
      CODE            PRELOAD DISCARDABLE
      DATA            PRELOAD SINGLE
      ");
   }
}

extern(C) export myfunction(){}


I'm not enumerating the exports via "build_def", since DMD is nice enough to handle all that for me. also, I'm making sure to use extern(C) to avoid name-mangling issues:

Code:

extern(C) export void foo(){} // exports "foo"
export void bar(){} // exports "D5mydll3barFZv"


... makes life much easier.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Mon Mar 28, 2005 5:32 am    Post subject: Reply with quote

V1.16 now has DLL support. Let me know how it goes as it works here with a simple example but I haven't tested it extensively.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
pragma



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

PostPosted: Tue Mar 29, 2005 9:32 pm    Post subject: Reply with quote

Derek Parnell wrote:
V1.16 now has DLL support. Let me know how it goes as it works here with a simple example but I haven't tested it extensively.


I'm now using V1.17 and it works great for building .dll files. It did it quite automatically, w/o any real prompting that I wanted one (it's almost creepy).

The only gotcha is with the build_def pragma. If I have a "LIBRARY" line added to the .def file, optlink complains that it's already there.

Code:
pragma(build_def,"LIBRARY 'mylibrary.dll'"); // optlink whines if this is present


Also, using pragma(target,"mylibrary.dll"); works as expected as does -T.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
Derek Parnell



Joined: 22 Apr 2004
Posts: 408
Location: Melbourne, Australia

PostPosted: Tue Mar 29, 2005 10:46 pm    Post subject: Reply with quote

pragma wrote:
The only gotcha is with the build_def pragma. If I have a "LIBRARY" line added to the .def file, optlink complains that it's already there.

Code:
pragma(build_def,"LIBRARY 'mylibrary.dll'"); // optlink whines if this is present


Is Build creating the .DEF file with two LIBRARY entries?

I thought I had coded it so that only one would be in the file. One possibility could be that the word 'LIBRARY' is spelled with different cases. I don't (yet) do a case insensitive compare of elements already included in the definition file.
_________________
--
Derek
skype name: derek.j.parnell
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Build 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