DLL

User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Maurizio,

Try it this way:

c:\vce\bin\link /IMPLIB:rchglobe.dll /OUT:rchglobe.lib
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Antonio Linares wrote:Maurizio,

Try it this way:

c:\vce\bin\link /IMPLIB:rchglobe.dll /OUT:rchglobe.lib
This is the result:
Microsoft (R) Incremental Linker Version 6.24.3077
Copyright (C) Microsoft Corporation. All rights reserved.

LINK : warning LNK4001: no object files specified; libraries used
LINK : warning LNK4068: /MACHINE not specified; defaulting to X86
LINK : fatal error LNK1561: entry point must be defined
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

The above was wrong. This should be the right way:

c:\vce\bin\lib /list:rchglobe.def rchglobe.dll

c:\vce\bin\lib /def:rchglobe.def /out:rchglobe.lib /machine:arm /subsystem:windowsce
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

To create the DEF file, better use Borland:

impdef.exe rchglobe.def rchglobe.dll

and then use Microsoft lib as explained
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Antonio Linares wrote:To create the DEF file, better use Borland:

impdef.exe rchglobe.def rchglobe.dll

and then use Microsoft lib as explained
Ok, the lib is created (but it was with my command too).

Maurizio please try it.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

ops, I missed your command
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Antonio Linares wrote:Enrico,

ops, I missed your command
No problem. My command doesn't work anyway. The lib is created but errors out when is linked to the application.

EMG
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Post by Maurizio »

Thank Antonio and Enrico

Now I have the LIB , and I cann link it without problem .

I try this function

#pragma BEGINDUMP

#include <hbapi.h>

HB_FUNC( RCHSENDDATA )
{
hb_retnl( RCHSendData( hb_parc( 1 ), hb_parc( 2 ) ) );
}

#pragma ENDDUMP

But I have this error :

RCH.obj : error LNK2019: unresolved external symbol "int __cdecl RCHOpen(void)" (?RCHOpen@@YAHXZ) referenced in function "void __cdecl HB_FUN_RCHOpen(void)" (?HB_FUN_RCHOpen@@YAXXZ)
RCH.exe : fatal error LNK1120: 1 unresolved externals
//---------------------------------------------------------------------------
I Try this function

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
int RCHOpen( void );

HB_FUNC( RCHOpen )
{
hb_retnl( RCHOpen() );
}

#pragma ENDDUMP



Creating library RCH.lib and object RCH.exp
RCH.obj : error LNK2019: unresolved external symbol "int __cdecl RCHOpen(void)" (?RCHOpen@@YAHXZ) referenced in function "void __cdecl HB_FUN_RCHOpen(void)" (?HB_FUN_RCHOpen@@YAXXZ)
RCH.exe : fatal error LNK1120: 1 unresolved externals

What is my error ?

Regards MAurizio
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

It seems a name-mangling problem as if the lib was compiled in C++.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Maurizio,

You have to include this in your code before your HB_FUNC()s:

Code: Select all

extern "C" {
LONG RCHSendData( LPSTR, LPSTR );
LONG RCHOpen( void );
LONG RCHClose( void );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Post by Maurizio »

Thank Antonio
Now I have this error

RCH.prg(317) : error C2556: 'int __cdecl RCHOpen(void)' : overloaded function di
ffers only by return type from 'long __cdecl RCHOpen(void)'
RCH.prg(309) : see declaration of 'RCHOpen'
RCH.prg(317) : error C2371: 'RCHOpen' : redefinition; different basic types
RCH.prg(309) : see declaration of 'RCHOpen'
RCH.prg(324) : error C2556: 'int __cdecl RCHOpen(void)' : overloaded function di
ffers only by return type from 'long __cdecl RCHOpen(void)'
RCH.prg(309) : see declaration of 'RCHOpen'
NMAKE : fatal error U1077: 'c:\vce\bin\clarm' : return code '0x2'
---------------------------------------------------------------------------
This is the source

#pragma BEGINDUMP
#include <Windows.h>
#include <hbapi.h>
extern "C" {
LONG RCHSendData( LPSTR, LPSTR );
LONG RCHOpen( void );
LONG RCHClose( void );
}
HB_FUNC(RCHSENDDATA)
{
hb_retnl(RCHSendData(hb_parc(1),hb_parc(2)));
}

int RCHOpen( void );

HB_FUNC( RCHOpen )
{
hb_retnl( RCHOpen() );
}

int RCHOpen( void );
HB_FUNC( RCHOClose )
{
hb_retnl( RCHOpen() );
}
#pragma ENDDUMP
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Maurizio,

Remove these lines from your code:

Code: Select all

// int RCHOpen( void );  this!

HB_FUNC( RCHOpen ) 
{ 
hb_retnl( RCHOpen() ); 
} 

// int RCHOpen( void ); this!

HB_FUNC( RCHOClose ) 
{ 
hb_retnl( RCHOpen() ); 
} 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

BTW,

This is wrong:

HB_FUNC( RCHOClose )
{
hb_retnl( RCHOpen() );
}

it should be

HB_FUNC( RCHClose )
{
hb_retnl( RCHClose() );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Finally, please use uppercase for names HB_FUNC ( ...Uppercase!... )

i.e.:

HB_FUNC( RCHCLOSE )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Maurizio
Posts: 705
Joined: Mon Oct 10, 2005 1:29 pm
Contact:

Post by Maurizio »

:D Wow !!
Finally, thanks to your help the link to the LIB works.

Many, many thanks to Antonio and Enrico for your assistance.

The strange thing is that when I linked the LIB and inserted the code to
call the functions in the LIB, the calls to the DLL now works.
This might explain the reason why the calls to the DLL did not work before?

Maurizio
Post Reply