Gu.
Gu.

Reputation: 1957

Unsatisfied forward or external declaration, with new C++ obj-files

I downloaded a free Delphi component for working with BZip2-archives: http://www.torry.net/vcl/compress/other/BZip21.05.zip (More experienced unit AbBzip2.pas component Abbrevia http://sourceforge.net/projects/tpabbrevia/files/) - they are very similar.

The components work well.

Problem:

  1. I see that version *.obj files BZip2 libraries in components - are old - 1.0.5 of 10 December 2007. Decided to update the obj-files into new ones.

  2. I going and download the latest version BZip2 - 1.0.6 - http://www.bzip.org/downloads.html

  3. Unpack the source BZip2 archive into a folder c:\BZip2Src

  4. Run "Open the command line VS2012 x86 Native Tools" (% comspec% / k "" C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ VC \ vcvarsall.bat "" x86)

  5. In console, I go to the c:\BZip2Src (Cd /d c:\BZip2Src)

  6. Compile the project as described in the makefile.msc (#usage: nmake.exe -f makefile.msc) and get new *.obj files. Along the way, getting a working programm bzip2.exe.

  7. Copy the new *.obj instead of the old blocksort.obj, huffman.., compress.., decompress.., bzlib.. in folder component for Delphi.

  8. Run Delphi, trying to recompile components.

Get the error "[dcc32 Error] AbBzip2.pas (215): E2065 Unsatisfied forward or external declaration: 'BZ2_hbMakeCodeLengths'" and other similar ones.

or for bzip2.bas - [dcc32 Error] BZip2.pas(171): E2065 Unsatisfied forward or external declaration: '_BZ2_hbMakeCodeLengths'

...
{$L huffman.obj}
{$L compress.obj}
{$L decompress.obj}
{$L bzlib.obj}

{ $L crctable.obj}
{ $L randtable.obj}

{$IFDEF LFS}
uses
  Windows;
{$ENDIF}

procedure _BZ2_hbMakeCodeLengths; external; // **ERROR LINE** 
procedure _BZ2_blockSort; external;  // if i replace on "BZ2_blockSort" (without "_"), i get error "[dcc32 Error] BZip2.pas(710): E2065 Unsatisfied forward or external declaration: 'bz_internal_error'"
procedure _BZ2_hbCreateDecodeTables; external;
...

I can not point out all of the options compiler without any modifications in C++ command line?

Did not work with C + +, help compile correctly *.obj files.

Upvotes: 0

Views: 914

Answers (1)

David Heffernan
David Heffernan

Reputation: 612934

The Pascal files are designed to be used with .obj files that are compiled in a very specific way. You cannot compile using the bzip2 makefile. You need to compile the files in the specific way that is compatible with the Delphi library.

Take a look at Abbrevia. In the sourceforge repo we have this:

bzip2 SDK v1.0.6

Original download available from http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz

Compile 32-bit with
  bcc32 -q -c -u- -w-8004 -w-8008 -w-8057 -w-8066 -w-8068 -DBZ_NO_STDIO *.c

Compile 64-bit with
  cl -c -nologo -GS- -Z7 -wd4068 -Gs32768 -DBZ_NO_STDIO *.c

So this tells you that 32 bit Abbrevia is designed to be used with bcc32 compiled object files (using that specific command line). Perhaps you can get it to work with cl also. And certainly Craig has managed to do so for his 64 bit builds.

In your question you state that the bzip2 files used in Abbrevia are out of date, and that you want to use 1.0.6. Well, that statement is not true. You've clearly got an out of date version of Abbrevia.

You should pull the latest version of Abbrevia from the sourceforge repo and this comes with .obj files for bzip2 1.0.6. Exactly what you are looking for. If you wish to make some modifications to the bzip2 source code files, you can do so and re-compile them using the command line above.

Upvotes: 3

Related Questions