Board index » cppbuilder » Bug: Using VCL as Runtime Package in DLL produces Linker Error

Bug: Using VCL as Runtime Package in DLL produces Linker Error

Hi,

I have tried to solve a frustrating problem for 5 hours now, and I'm giving
up.

Task
====
I want to write a simple DLL and use the RTL as well as the VCL dynamically
(as package). No problem with the RTL, but as soon as I use VCL functions
within the DLL, it is impossible to link an external EXE using the DLL via
an import lib.

Steps to reproduce:
===============

-DLL-
1. Create a DLL with DLL Wizard (Check 'Use VCL')
2. Check 'Use dynamic RTL' in the 'Linker'-Page of the project options
3. Check 'Build with runtime packages' in the 'Packages'-Page of the project
options
4. Make sure that VCL50 is added as a runtime package
5. Add a form to the DLL
6. Export a function or class from the DLL (i.e. prefix the form declaration
with __declspec(dllexport))

- EXE -
1. Create an Application with File|New|Application
2. Check 'Use dynamic RTL' in the 'Linker'-Page of the project options
3. Check 'Build with runtime packages' in the 'Packages'-Page of the project
options
4. Make sure that VCL50 is added as a runtime package
5. Add the import library of the DLL to the project
6. Use an exported function or class from the DLL

Result
=====
[Linker] Linking: N:\RTE\BIN\client1.exe
[Linker Error] Unresolved external 'Sysinit::VclInit(bool, bool, int, bool)'
referenced from F:\DEV\IDE\CB5\LIB\RELEASE\VCLE50.LIB|vclinit
[Linker Error] Unresolved external 'Sysinit::VclExit()' referenced from
F:\DEV\IDE\CB5\LIB\RELEASE\VCLE50.LIB|vclinit

There is no problem with the client-executable, it links perfectly with
dynamic RTL and runtime packages if  the import lib is not included in the
project(of course one can't use functions from the DLL then...). Also there
is no problem with the DLL, it links perfectly as well. Only the combination
of using an import-lib with dynamic VCL binding, within an
client-application produces the effect.

The problem goes away if I use the static version of the VCL within the
DLL - but that's not what I want...

Please help, this is driving me mad...

Thanks in advance

Eike Petersen

P.S: I am using BCB5 with Patch1 installed
P.P.S: Please don't flame me for crossposting - I just didn't know in which
group this belongs

 

Re:Bug: Using VCL as Runtime Package in DLL produces Linker Error


Hi,

There are two things you might look into:
1) Is there a DEFAULT.BPR in your BIN directory? If so, try
those steps again after deleting it. DEFAULT.BPR is created
when you click OK in the PRoject Options dialog with the
default checkbox ON. It can save (and use) settings (such
as a define of _NO_VCL ) which are not appropriate for
all project types.
2) The Wizard dialogs (at least the one for Console Apps)
can behave oddly for the Multi-threaded setting. If you
at one time turn it OFF, it will disable (and keep OFF)
the setting when you select VCL but it should actually
turn ON and disable when you select VCL.

--Craig

Other Threads