Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-06

fpc required to dynamic load VS DLL ?

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Fred van Stappen

Hello.

I use a external C library (call parent-lib). That library uses a other external library (call child-lib).

To compile a DLL using a external DLL with Microsoft Visual Studio, you need the lib file of the child-lib.

If you want to dynamically load those libraries, you need to use "loadlibrary" and so you can choose the folder of your library.

Sadly, the child-lib cannot dynamically be loaded with Visual Studio. You need to place the child-lib in the same folder that the parent-lib and if you load the parent-lib, it load the child-lib...(same for unload).

Now, if i use fpc, translate the C header and use DynLibs.LoadLibrary for both libraries... it works, i can load both parent and child libraries, even if they are not in the same folder (and of course access all the functions)... I can also load only the parent-lib or child-lib or both. (even for unload)

So the question is : Is fpc required to dynamic load C DLL ? ;-)

Reply by email

leledumbo
to Fred van Stappen
Is fpc required to dynamic load C DLL ?

No. In fact, if you take a look at wrapper units (opengl, openal, sdl, etc.), most (or probably all) of them loads the DLL they wrap statically. Some may have dynamic loading feature either using different units or conditional compilation.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/fpc-required-to-dynamic-load-VS-DLL-tp5715395p5715404.html Sent from the Free Pascal - General mailing list .

Reply by email

Fred van Stappen
to leledumbo
Show quoted text 11 lines
Date: Thu, 20 Jun 2013 00:06:42 -0700 From: To: Subject: [fpc-pascal] Re: fpc required to dynamic load VS DLL ? > Is fpc required to dynamic load C DLL ? No. In fact, if you take a look at wrapper units (opengl, openal, sdl, etc.), most (or probably all) of them loads the DLL they wrap statically. Some may have dynamic loading feature either using different units or conditional compilation.

Many thanks Leledumbo.

> most (or probably all) of them loads the DLL they wrap statically.

I was thinking that too. I have try to change compiler options in Visual Studio ( 6 and 11) to load dynamic the "child" library but i loose.

The only way i find to dynamicaly load the "child" library is to... use fpc.

PS : I wanted to help my C developper friends (who do not understand how i did to dynamically load the "child" library) and after trying lot of things, my conclusion was : C folks, migrate to Pascal, that is the best solution... ;-)

Reply by email