NO

Author Topic: Borland Library  (Read 9658 times)

rcobb

  • Guest
Borland Library
« on: August 10, 2006, 01:35:10 pm »
Howdy,

I've just discovered Pelles C, and I'm very impressed.  This is probably a simple question, but I haven't been able to find it in my searches so far.

I'm trying to port a Borland C (5.0) Windows GUI application, and the Borland custom controls (BWCC) are giving me a fit.  I was hoping I could simply copy over the header and library files, but I get extensive errors when compiling the header.  Here's an example of a snippet from BWCC.h and a couple of the error messages:

-------------------------------------------------
#define BSS_ALIGNMASK 0x0300L

/*
#if defined( __cplusplus )
extern "C" {
#endif  /* __cplusplus */

extern HGLOBAL BWCCAPI SpecialLoadDialog   <==error #2001: Syntax error; found '__stdcall' expecting ';'.
                                           <== (same line) warning #2099: Missing type specifier.
(

  HINSTANCE   hResMod,
  LPCSTR      lpResName,
  DLGPROC     fpDlgProc
);
-------------------------------------------------
I've tried every combination of compiler flags I could think of, but to no avail.

Thanks,

Richard

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1888
Borland Library
« Reply #1 on: August 10, 2006, 01:55:09 pm »
Check the definition of BWCCAPI, and maybe also HGLOBAL. Probably the position of __stdcall is incorrect. I.e.
Code: [Select]
#define  BWCCAPI __stdcall int   //incorrect
#define  BWCCAPI int __stdcall   //correct

If you still have problems please post the header where BWCCAPI and HGLOBAL are defined.

rcobb

  • Guest
re: Borland Library
« Reply #2 on: August 10, 2006, 02:37:28 pm »
Here's what I was able to track down:
------------------------
<winnt.h>
typedef void *PVOID;    

#ifdef STRICT
typedef void *HANDLE;
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
#else
typedef PVOID HANDLE;
#define DECLARE_HANDLE(name) typedef HANDLE name
#endif

<windef.h>
typedef HANDLE              HGLOBAL;


<bwcc.h>
#define BWCCAPI FAR EXPORT PASCAL

------------------------------------
I'm attaching the BWCC.h file as well.

Thanks,

Richard

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1888
Borland Library
« Reply #3 on: August 10, 2006, 03:27:47 pm »
I modified the offending points in the definition file.
You'll find attached the modified version of bwcc.h, each modification is explained by a comment.
Let me know if it works.

rcobb

  • Guest
re: Borland Library
« Reply #4 on: August 10, 2006, 04:02:51 pm »
Yeah, that did it - thanks!!

I'm still sorting through some other things, but I think I can solve most of those.  This one is baffling me though - using the resource compiler, I get the error message "Unrecognized or misplaced token: , "  on the line marked with <##### below.  I included the definition for the dialog preceeding it, which the compiler seems to approve of.  I can't see the difference in the format.  I don't know whether the error message is referring to a misplaced comma, or if that is a separator for a token that is not printable.  I tried deleting all the spaces and retyping (in case there was a hidden control character), but no good.

Any clues?

Thanks again,

Richard
--------------------------

TITLEAXES DIALOG 17, 21, 145, 177
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_3DLOOK
CLASS "bordlg"
CAPTION "Titles and Axis Labels"
{
 CONTROL "", IDMAINTITLETEXT, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 11, 22, 124, 12
 CONTROL "", IDSUBTITLETEXT, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 11, 52, 124, 12
 CONTROL "", IDXAXISTEXT, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 11, 96, 124, 12
 CONTROL "", IDYAXISTEXT, "EDIT", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 11, 126, 124, 12
 CONTROL "Button", IDOK, "BorBtn", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 25, 152, 32, 20
 CONTROL "Button", IDCANCEL, "BorBtn", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 87, 152, 32, 20
 CONTROL "Main Title", IDMAINTITLELABEL, "BorStatic", SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP, 46, 12, 44, 8
 CONTROL "Sub-Title", IDSUBTITLELABEL, "BorStatic", SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP, 46, 40, 44, 8
 CONTROL "", 405, "BorShade", 32774 | WS_CHILD | WS_VISIBLE, 7, 7, 131, 62
 CONTROL "Y-Axis Label (Polar Radius)", IDYAXISLABEL, "BorStatic", SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP, 26, 116, 94, 8
 CONTROL "X-Axis Label (Polar Angle)", IDXAXISLABEL, "BorStatic", SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP, 28, 86, 86, 8
 CONTROL "", 415, "BorShade", 32774 | WS_CHILD | WS_VISIBLE, 7, 81, 131, 62
}

CURSOR DIALOG 26, 18, 117, 95    <#####
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
CLASS "bordlg"
CAPTION "Data Cursor Setup"
{
 CONTROL "Button", IDOK, "BorBtn", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 20, 68, 32, 20
 CONTROL "", IDDATASETLIST, "COMBOBOX", CBS_DROPDOWNLIST | WS_CHILD | WS_VSCROLL |WS_VISIBLE | WS_TABSTOP, 12, 45, 94, 55
 CONTROL "Active Data Set Selection:", 102, "BorStatic", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 17, 35, 86, 8
 CONTROL "", 108, "BorShade", 32774 | WS_CHILD | WS_VISIBLE, 7, 6, 102, 54

rcobb

  • Guest
re: Borland Library
« Reply #5 on: August 10, 2006, 04:09:48 pm »
Never mind - I just figured out the Resource compiler problem - apparently the name of the dialog, "cursor", was a reserved name which was not being interpreted properly.  When I renamed it the problem went away.

Richard

rcobb

  • Guest
re: Borland Library
« Reply #6 on: August 22, 2006, 12:07:25 am »
Well, I got through all the comiler issues with the BWCC header and function calls.  Now I'm stuck at the linking phase - I get the message: "POLINK: fatal error: Corrupt library: '.\bwcc32.lib'."

I'm guessing the .lib file format is not compatible, but do I have any options left?

I've attached the bwcc32 lib and dll files in case they can provide any insight.

Thanks again,

Richard

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1965
Borland Library
« Reply #7 on: August 22, 2006, 04:43:45 am »
polib.exe bwcc32.dll /out:bwcc32.lib
May the source be with you

rcobb

  • Guest
re: Borland Library
« Reply #8 on: August 22, 2006, 01:24:20 pm »
Thanks to everyone for all the help.  I was able to create the library and I included it in the linker options list.  I no longer get an error message about a corrupt library, but the linker cannot seem to find the routines to link to.  Example:

POLINK: error: Unresolved external symbol '_BWCCRegister'.

Yet polink shows the routine to be listed in the library:

C:\PellesCProjects\output\temp>polib /list bwcc32.lib
bwcc32.dll:__IMPORT_DESCRIPTOR_bwcc32
bwcc32.dll:__NULL_IMPORT_DESCRIPTOR
<snip>
bwcc32.dll:BWCCRegister

I've tried going through the various compiler and linker options flags, but haven't been able to find any that made a difference.  I also tried adding bwcc32.dll to the "DLL files with delayed loading" option line with no effect.

With the verbose flag on for the linker, I get messages that the library is being searched, but no listing of routines in the library is shown, as it is for the other libs:

Searching C:\Program Files\PellesC\Lib\bwcc32.lib
Searching C:\Program Files\PellesC\Lib\Win\kernel32.lib
    Found __imp__ExitProcess@4
        kernel32.lib(KERNEL32.dll)

I tried using the polib /explode option, but it creates a bwcc32.dll file and then gives the error message:

C:\PellesCProjects\output\temp>polib /explode ..\bwcc32.lib
POLIB: fatal error: The file exists.

Although the only file in the folder is the newly created bwcc32.dll file.

Thanks again,

Richard

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1888
Borland Library
« Reply #9 on: August 23, 2006, 12:07:11 pm »
Richard, maybe the calling convention is not correct.
You have to look which symbol your library require and how they are reported in the export section of the library.
Try to recompile your code with __stdcall and __cdecl.
Or post the dll to look at it (better if you post a sample project).

EDIT:
 :oops: I haven't seen you already posted the lib and dll!

I'll take a look asap.
Please could you post a sample application using the library with your project so I can have a look at settings?

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1888
Borland Library
« Reply #10 on: August 25, 2006, 09:51:14 pm »
PellesC polib permits to convert an OMF (borland format library) to standard PE format.
Use:
Code: [Select]
polib.exe bwcc32.lib /out:bwcc32-PE.lib
Then use the bwcc32-PE.lib library for linking (or delete the original omf library and rename the new to bwcc32.lib).

rcobb

  • Guest
Borland Library
« Reply #11 on: August 28, 2006, 02:57:18 am »
Quote
I'll take a look asap.
Please could you post a sample application using the library with your project so I can have a look at settings?


OK, I hacked the program down to the bare essentials.  I'm not sure it is even running code at this point, but it illustrates the link problem, which are these two errors:

POLINK: error: Unresolved external symbol '_BWCCRegister'.
POLINK: error: Unresolved external symbol '_BWCCMessageBox'.
POLINK: fatal error: 2 unresolved external(s).

I ran polink on both bwcc32.dll (out to bwcc32dll.lib) and bwcc32.lib (out to bwcc32lib.lib ) and I'm now including both in the link list.  The zip file has everything in the project folder.

Thanks for taking a look!

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1888
Borland Library
« Reply #12 on: August 28, 2006, 02:09:24 pm »
I rebuilt the import library by creating a def file. Command:
Code: [Select]
polib /DEF:bwcc32.def /MACHINE:IX86 /out:bwcc32-def.lib
Now you can link with no errors.
Anyway your sample doesn't seem to work.
Make your trials and good luck  :mrgreen: .

P.S. When debugging is useful to null the optimization, so they are none in the project.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1965
Borland Library
« Reply #13 on: August 28, 2006, 02:38:51 pm »
Small working example for Frankie's lib:

Code: [Select]

#include <windows.h>
#include "bwcc.h"

#pragma lib "BWCC32-def.lib"

int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{

BWCCRegister (hInstance);
BWCCMessageBox(0,"this is a test message","TEST TITLE",MB_OK);
}
May the source be with you

rcobb

  • Guest
re: Borland Library
« Reply #14 on: August 28, 2006, 02:39:47 pm »
What were the contents of the .def file?

Thanks,

Richard