- Chris Wallace
- PowerBuilder
- Thursday, 4 August 2022 09:12 PM UTC
I am using eclipse, not Visual Studio, to create a .dll file in C++. I have simplified the code down to this:
My header file tagsigs.h
#include <iostream>
#include "windows.h"
#ifndef TAGSIG_H_
#define TAGSIG_H_
extern "C" {
int __deckspec(dllexport) WINAPI testFunc(void);
}
#endif
My tagsigs.cpp file
#include "tagsigs.h"
using namespace std;
int __deckspec(dllexport) WINAPI testFunc(void){
return (26);
}
I compile as a shared library using MinGW. I get my .dll file using the Release, not Debug, build configuration. I tested my libTS.dll file using
dumpbin /EXPORTS libTS.dll
ordinal hint RVA Name
1 0 00001380 testFunc
This showed that the function name was not mangled and that it was exported.
I put libTS.dll into my PowerBuilder source directory where all the .pbl's and .dll's for the libraries I have created in Powerbuilder reside.
Here is my Global External Function declaration:
FUNCTION int testFunc() LIBRARY "libTS.dll" alias for "testFunc"
I did a Full Build.
But when I call testFunc from a powerbuilder script I get the error "Bad runtime function reference".
int xx
xx = testFunc()
MessageBox("Did It Work?", string(xx))
I have used global external functions before from the kernel32.dll and user32.dll libraries, but I've never provided my own .dll before. I don't know how to compile any differently for my .dll and I don't know how to declare or call any differently inside of PowerBuilder. Has anyone had success with shared library .dll files created through Eclipse and used inside PowerBuilder as external functions?
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.