简体   繁体   中英

Which .OBJ files are linked into which VCL libraries

When linking a C++ project in Embarcadero RAD Studio XE3 (with Use Runtime Packages off), I sometimes get an error of the form :

[ilink32 Error] Fatal: Unable to open file 'FOO.OBJ'

I understand what causes this. It is because there is an implicit reference in the code (usually via a #pragma link ) that causes the linker to require the unit FOO .

And if I look in the VCL source, I can usually find a FOO.PAS that gets compiled into a FOO.DCU . That's the compiled unit the linker is looking for but can't find.

I know this compiled unit lives in one of the VCL libraries, but I don't know how to find out which one. For instance, which units do VCL.LIB and RTL.LIB and BCBIE.LIB (and so forth) contain?

Given a unit name I would like to know which VCL library contains it. If I knew that, I could just add the appropriate .lib file to the LinkPackageStatics tag in my cbproj file and everything would link just fine.

It would be nice if it was just shown in the documentation for that unit, but it isn't there. Currently, I have to use trial and error to find the right library, but surely there is a publicly-available listing somewhere that shows which VCL units get linked into which VCL libraries.

Where could I find such a listing?

(By the way, I know that in normal usage of the IDE the developer isn't required to know this. The IDE generally takes care of this for you. But I find that I occasionally need this information when a .cbproj gets merged wrong or manually edited incorrectly or for a host of other reasons that go beyond normal usage of the IDE.)

EDIT: Thanks! tlib was exactly what I needed. I'm pretty lousy at shell scripts, but I wrote a little shell script that outputs the name of the library next to the name of each of the units it contains:

#!/bin/bash
while [ "$1" != "" ]; do
    name=$(basename "$1")
    tlib /L $name | grep size | awk -v name=$name '{print name, "\t", $1}'
    shift
done

Then I can invoke the script by executing it on all the .libs I'm interested in and then grepping for the unit (like SysUtils) I'm looking for:

find . -name "*.lib" -exec libunits.sh {} \; | grep SysUtils

You can use tlib.exe, for example:

tlib /l vcl.lib

Another option is to enumerate the 'PACKAGEINFO' resource in the BPLs, using GetPackageInfo as shown in this answer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM