Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error calling external function %s

1,175 views
Skip to first unread message

MaryGail Broussard

unread,
May 6, 2009, 9:35:46 PM5/6/09
to
Hi,

I have a PowerBuilder 10.5.2 application running on Windows XP. I am trying to
call a homegrown C++ DLL from PowerBuilder. I must be doing something wrong but
I have tried to follow all of the steps to make this work which include:

//c++ definition
extern "C" short far pascal ef_print_pdfs()

// .def file for C++ function
LIBRARY ef_pdfutils.dll
EXPORTS ef_print_pdfs = _ef_print_pdfs@0

// Powerbuilder declaration
FUNCTION int ef_print_pdfs() LIBRARY "ef_pdfutils.dll" alias for
"ef_print_pdfs;Ansi"

// Function called from PowerBuilder
int li_status
li_status = ef_print_pdfs()

But when I run the app, I get "Error calling external function %s at line..." at
the function call.

I am pulling my hair out scouring the Web for answers - no luck. I made sure
that the DLL was in my PATH variable and I also verified that the DLL exported
my function by using DUMPBIN which showed:
.
.
.
ordinal hint RVA name

1 0 00002240 ef_print_pdfs = _ef_print_pdfs@0

Does anyone have any idea what I can do to fix this? Thanks so much for any
help you can provide!

MG
---== Posted via the PFCGuide Web Newsreader ==---
http://www.pfcguide.com/_newsgroups/group_list.asp

Arthur Hefti

unread,
May 6, 2009, 11:24:39 PM5/6/09
to
You're sure you're C DLL ist ansi and not unicode? Did you try to call it
without the alias?

Arthur

"MaryGail Broussard" <mg@theITEdge> wrote in message
news:4a023af2$1@forums-1-dub...

Dmitri

unread,
May 7, 2009, 2:21:03 AM5/7/09
to
MaryGail Broussard wrote:

> I have a PowerBuilder 10.5.2 application running on Windows XP. I am trying to
> call a homegrown C++ DLL from PowerBuilder. I must be doing something wrong but
> I have tried to follow all of the steps to make this work which include:
>
> //c++ definition
> extern "C" short far pascal ef_print_pdfs()

I'm not a C guru by any stretch of imagination ;), however I'd try the
following:

extern "C" long WINAPI ef_print_pdfs();

> // Powerbuilder declaration
> FUNCTION int ef_print_pdfs() LIBRARY "ef_pdfutils.dll" alias for
> "ef_print_pdfs;Ansi"

FUNCTION Long ef_print_pdfs() LIBRARY "ef_pdfutils.dll" alias for
"ef_print_pdfs"

Dmitri.

Clive Collie

unread,
May 7, 2009, 5:54:13 AM5/7/09
to
Also I would change the DEF file to just

EXPORTS ef_print_pdfs
There is no Ansi/Unicode problems here because there are no string variables
being passed sp you don't need the alias part.

"Dmitri" <NOdi...@mail15.com> wrote in message
news:4a027dcf$1@forums-1-dub...

MaryGail

unread,
May 7, 2009, 9:49:37 AM5/7/09
to
On 7 May 2009 02:54:13 -0700,
in sybase.public.powerbuilder.general

Thanks for replying. Unfortunately, neither suggestion worked. My PB
declaration now looks like:

FUNCTION Long ef_print_pdfs() LIBRARY "ef_pdfutils.dll" alias for
"ef_print_pdfs"

My .DEF file now looks like:
LIBRARY ef_pdfutils.dll
EXPORTS ef_print_pdfs

I get the same error. I just don't get it. I'm not an experienced C++
programmer. Could my DLL be the problem? I can see that it's been exported by
using the "dumpbin" utility but could there be something wrong on the C++ side?
Or does the PB error message "Error calling external function %s..." really mean
that it never made it into the DLL at all?

MaryGail

Clive Collie

unread,
May 7, 2009, 10:06:35 AM5/7/09
to
Did you change the function prototype and definition:

extern "C" long WINAPI ef_print_pdfs(void);

long WINAPI ef_print_pdfs(void)
{
...
}

I find the reason these things go wrong is to do with function signature
(i.e. what parameters go in and out of the function) and calling convention
(the winapi bit)


"MaryGail" <m...@theITEdge.com> wrote in message
news:4a02e6f1$1@forums-1-dub...

Jerry Siegel [TeamSybase]

unread,
May 7, 2009, 11:51:20 AM5/7/09
to
This article on compiling C++ to be used by PB may help:
http://www.sybase.com/detail?id=47626

--
Report Bugs: http://case-express.sybase.com/cx/welcome.do
Product Enhancement Requests:
http://my.isug.com/cgi-bin/1/c/submit_enhancement

"MaryGail Broussard" <mg@theITEdge> wrote in message
news:4a023af2$1@forums-1-dub...

MaryGail

unread,
May 7, 2009, 11:23:25 AM5/7/09
to
On 7 May 2009 07:06:35 -0700,

in sybase.public.powerbuilder.general
Clive Collie <clive_doesn...@dillistone.com> wrote:
>Did you change the function prototype and definition:
>
>extern "C" long WINAPI ef_print_pdfs(void);
>
>long WINAPI ef_print_pdfs(void)
>{
>....

I had not changed the function prototype and definition so I changed it like you
suggested. I still get the same error:-(
MaryGail

Arthur Hefti

unread,
May 7, 2009, 11:29:07 AM5/7/09
to
Has the DLL some dependencies that can't be found?

Arthur

"MaryGail" <m...@theITEdge.com> wrote in message news:4a02fced@forums-1-dub...

MaryGail

unread,
May 7, 2009, 5:09:03 PM5/7/09
to
On 7 May 2009 08:51:20 -0700,
in sybase.public.powerbuilder.general
Thanks so much for the help but I had already found that link and followed the
directions. I think I'm going to write a simpler DLL and try that. Thanks for
all the help. I will be posting back after I succeed (I hope!) or fail.

MG
MaryGail

Dave Hauze

unread,
May 8, 2009, 4:07:38 PM5/8/09
to
Mary, have you considered PBNI?

--
Dave Hauze


"MaryGail" <m...@theITEdge.com> wrote in message

news:4a034def$1@forums-1-dub...

c...@live.ca

unread,
May 19, 2009, 7:19:09 PM5/19/09
to
On May 7, 6:49 am, "MaryGail" <m...@theITEdge.com> wrote:
> On 7 May 2009 02:54:13 -0700,
>  in sybase.public.powerbuilder.general
>
>
>
>
>
> Clive Collie <clive_doesnt_like_s...@dillistone.com> wrote:
> >Also I would change the DEF file to just
>
> >EXPORTS ef_print_pdfs
> >There is no Ansi/Unicode problems here because there are nostringvariables
> >being passed sp you don't need the alias part.
>
> >"Dmitri" <NOdimS...@mail15.com> wrote in message

> >news:4a027dcf$1@forums-1-dub...
> >> MaryGail Broussard wrote:
>
> >>> I have a PowerBuilder 10.5.2 application running on Windows XP.  I am
> >>> trying to
> >>> call a homegrown C++ DLL from PowerBuilder.  I must be doing something
> >>> wrong but
> >>> I have tried to follow all of the steps to make this work which include:
>
> >>> //c++ definition
> >>> extern "C" short far pascal ef_print_pdfs()
>
> >> I'm not a C guru by any stretch of imagination ;), however I'd try the
> >> following:
>
> >> extern "C" long WINAPI ef_print_pdfs();
>
> >>> // Powerbuilder declaration
> >>>FUNCTIONint ef_print_pdfs() LIBRARY "ef_pdfutils.dll" alias for
> >>> "ef_print_pdfs;Ansi"
>
> >>FUNCTIONLong ef_print_pdfs() LIBRARY "ef_pdfutils.dll" alias for

> >> "ef_print_pdfs"
>
> >> Dmitri.
>
> Thanks for replying.  Unfortunately, neither suggestion worked.  My PB
> declaration now looks like:
>
> FUNCTIONLong ef_print_pdfs() LIBRARY "ef_pdfutils.dll" alias for

> "ef_print_pdfs"
>
> My .DEF file now looks like:
> LIBRARY ef_pdfutils.dll
> EXPORTS ef_print_pdfs
>
> I get the same error.  I just don't get it.  I'm not an experienced C++
> programmer.  Could my DLL be the problem?  I can see that it's been exported by
> using the "dumpbin" utility but could there be something wrong on the C++ side?
> Or does the PB error message "Error callingexternalfunction%s..." really mean

> that it never made it into the DLL at all?
>
> MaryGail- Hide quoted text -
>
> - Show quoted text -


1. In your C++ .DEF file, try using the @1 ordinal at the end :
ie
LIBRARY ef_pdfutils.dll
EXPORTS ef_print_pdfs @1

Andy

Message has been deleted
0 new messages