delphi - What are the fundamentals of optionally compiling a library or requiring DLL? -


i write component ability developer either require dll or include unit in app compiles library project, without dll.

for example, let's it's called "mylibrary". if include mylibrary in uses clause, default require dll distributed application. on other hand, if unit mylibraryimplementation in uses clause, compile inside app without requiring dll.

this component inside package installed ide.

i'm not sure terminology this, or how go this. i'm familiar writing dll's, , not looking write full code.

what fundamental things need know make optional dll possible?

you won't find result satisfying. delphi cannot directly load classes dll. instead, you'll need define class in mylibrary unit. you'll have implement of methods there. you're welcome make methods little more stubs delegate work functions in dll, though. in stub constructor, call dll function allocates data structure , returns handle. in 3 other stub methods, pass handle corresponding dll functions along methods' other arguments.

you'll have 3 parallel implementations of class:

  1. the 1 in mylibrary.pas that's nothing stubs.
  2. the 1 in mylibrary.dll backs stubs.
  3. the 1 in mylibraryimplementation.pas same things dll, internally.

you can avoid duplicating much, not completely.

you don't need of this, though. years, delphi has offered comparable functionality built in: packages.

if customers want have class's implementation live in separate module, can choose "build runtime packages" option in projects' linker settings. disabling setting cause code compiled in exe files instead, , won't need distribute bpl file anymore.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -