[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppBuilderLinkingErrors

Linking errors in C++ Builder

These are given by you linker or at runtime. Ends your program. For general C++ linking errors click here.

Other errors

Page overview

  • [Linker Error] [...]\NAME.LIB contains invalid OMF record, type 0x21 (possibly COFF)
  • [Linker Error] Unresolved external '__InitVCL' referenced from [..]
  • [Linker Error] Unresolved external '__ExitVCL' referenced from [..]
  • [Linker Error] Unresolved external '_Form2' referenced from [...]\UNIT1.OBJ
  • [Linker Error] Unresolved external 'WinMain' referenced from [...]\CBUILDER6\LIB\C0W32.OBJ
  • [Linker Error] Unresolved external [from a VCL Object you #included but have not added to your project]
  • [Linker Fatal Error] Fatal: Expected a file name
  • [Linker Fatal Error] Fatal: unable to open file '[AnyName].bpi'
  • [Linker Fatal Error] Unable to open file 'system.OBJ'
  • [Linker Fatal Error] Unable to open file 'CLASSES.OBJ'
  • [Linker Error] Fatal: Error detected (C:\1657). [Linker Error] Fatal: Access violation. Link terminated.
  • [Linker Error] Unresolved external '__fastcall Filectrl::SelectDirectory(System::AnsiString&, System::Set<Filectrl::TSelectDirOpt, 0, 2>, int)'

[Linker Error] [...]\NAME.LIB contains invalid OMF record, type 0x21 (possibly COFF)

The library is of the wrong type. Use coff2omf.exe, located in CBuilder/bin, to convert it to the correct type.

Example:
  • First copy the anyName.lib and coff2omf.exe to a temporary folder
  • Type:
coff2omf anyName.lib anyName.~lib
copy anyName.~lib anyName.lib
  • When prompted, do overwrite the old library file (keep a copy somewhere!!!).
  • Copy the anyName.lib to Cbuilder6/Lib (so it will be found without setting paths)
  • Delete the temporary folder.

[Linker Error] Unresolved external '__InitVCL' referenced from [..]

This error occurs, because you want to work in a console application, but you started a Builder application in the Console Wizard. Do 'File | New | Other | Console Wizard'. In this menu, uncheck 'Use VCL'. 'Console Application' should be checked, 'Multi Threaded' and 'Use CLX' should be unchecked.

[Linker Error] Unresolved external '__ExitVCL' referenced from [..]

This error occurs, because you want to work in a console application, but you started a Builder application in the Console Wizard. Do 'File | New | Other | Console Wizard'. In this menu, uncheck 'Use VCL'. 'Console Application' should be checked, 'Multi Threaded' and 'Use CLX' should be unchecked.

[Linker Error] Unresolved external '_Form2' referenced from [...]\UNIT1.OBJ

This error occurs when you have added a second TForm to your project (using 'File | Include Unit Hdr') but WITHOUT having done 'Project | Add to Project | Unit2.cpp'

[Linker Error] Unresolved external 'WinMain' referenced from [...]\CBUILDER6\LIB\C0W32.OBJ

This happens if you save the project and unit name under the same name in Builder.

[Linker Error] Unresolved external [from a VCL Object you #included but have not added to your project]

Some all-time favorites:

When using ShowMessage:
[Linker Error] Unresolved external '__fastcall Dialogs::ShowMessage(const System::AnsiString)' referenced from D:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\SEAGULL\UNITMAIN.OBJ


Any VCL Component:
[Linker Error] Unresolved external '__fastcall System::TObject::~TObject()' referenced from D:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\SEAGULL\UNITMAIN.OBJ


A  ?TImage:
[Linker Error] Unresolved external 'seagull::Extctrls::TImage::' referenced from D:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\SEAGULL\UNITMAIN.OBJ


How to solve this:

[Linker Fatal Error] Fatal: Expected a file name

This error occurs when you save your project in a folder with a 'strange' name, e.g. 'C:\C++'. This program has become useless, so cut out all code, 'Close All', start a new application, paste your code correctly and 'Save All' in a normal named folder, e.g. 'C', 'CPlusPlus', 'Programming'

[Linker Fatal Error] Fatal: unable to open file '[AnyName].bpi'

This error occurs because of the same reason: the person you opened a project from, has installed some Components on his computer, that you did not. The Project expects these Components to be present. To take away this expectation, do: 'Project | Options | (tab) Packages | (Groupbox) Runtime Packages', then fill in in the Edit box:

vcl;rtl;dbrtl;adortl;vcldb;vclx;bdertl;vcldbx;ibxpress;dsnap;cds;bdecds;qrpt;teeui;teedb;tee;dss;teeqr;visualclx;visualdbclx;dsnapcrba;dsnapcon;bcbsmp;vclie;xmlrtl;inet;inetdbbde;inetdbxpress;inetdb;nmfast;webdsnap;bcbie;websnap;soaprtl;dclocx;dbexpress;dbxcds;indy;bcb2kaxserver;


These are the packages standard in Builder. Another option is to manually remove all these packages you miss from the list.

[Linker Fatal Error] Unable to open file 'system.OBJ'

Try to Repair Builder, using the setup file in the CBUILDER6 directory, with the .MSI extension. This sometimes succeeds.

[Linker Fatal Error] Unable to open file 'CLASSES.OBJ'

This happens when you add CBuilder6\Lib\Debug\Vcl.LIB to your project. I did so, because I wanted to have an unresolved external error solved caused be a TImage.

[Linker Error] Fatal: Error detected (C:\1657). [Linker Error] Fatal: Access violation. Link terminated.

Close All, then reload project.

[Linker Error] Unresolved external '__fastcall Filectrl::SelectDirectory(System::AnsiString&, System::Set<Filectrl::TSelectDirOpt, 0, 2>, int)' referenced from ...\MAIN.OBJ

From Jonathan Arnold at http://groups.google.nl/group/borland.public.cppbuilder.ide/browse_thread/thread/b56ef9ee927a09bb/dbd09438d81a8767%23dbd09438d81a8767:

A posting from John Moore solves this longtime problem:
The problem is that for some reason, everything in filectrl.hpp is in
vclx50.lib.  There are 2 basic ways to fix this:
1)  Close your project, edit the .bpr file and add vclx50.lib to the
LIBRARIES and SPARELIBS lines:
    <LIBRARIES value="VCLX50.lib VCL50.lib"/>
    <SPARELIBS value="VCL50.lib VCLX50.lib"/>
2)  Add a DriveComboBox (or any other component in filectrl), in the Win 3.1
palette tab, to your form and then delete it.  A side effect of doing this
is that vclx50.lib is left in your .bpr file. 


Or from Denis Pyr at http://groups.google.nl/group/borland.public.cppbuilder.language/browse_thread/thread/74935b8f1ffa1ed0/a45d0bb500da7ca3%23a45d0bb500da7ca3

You can copy the filectrl.pas drom $(BUILDER)\Source\Vcl to your
project directory and add it to the project.
Important note: copy it first and then add it. 


And from Craig Farrell at http://groups.google.nl/group/borland.public.cppbuilder.language/browse_thread/thread/74935b8f1ffa1ed0/a45d0bb500da7ca3%23a45d0bb500da7ca3

You can usually resolve those type of linker errors by adding VCLX50.LIB
to the project ( Project | Add to Project | Browse to ..\Release or
..\Debug 
and add the .LIB). The issue is that the function you are using is a
Pascal
RTL function. In one case, it might be brought indirectly by a VCL
package
depending on those Pascal RTL externals. But the IDE doesn't place the
Pascal
RTL lib in your project by default. 


last edited (July 3, 2007) by bilderbikkel, Number of views: 23726, Current Rev: 11 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.