Hello, I am trying to use Berkeley DB XML from withing Squeak. I already found out how to call C functions, but I got stuck on "Error : can't find function address" when calling a function in a C++ shared library. So I first looked up some info on the Squeak wiki and found this: http://minnow.cc.gatech.edu/squeak/3735. I used nm from mingw on the libdbxml22.lib and got a lot of some information I do not exactly understand. An example:
libdbxml22.dll: 00000000 I .idata$4 00000000 I .idata$5 00000000 I .idata$6 00000000 T .text 00000000 T ?abort@XmlTransaction@DbXml@@QAEXXZ 00000000 I _imp_?abort@XmlTransaction@DbXml@@QAEXXZ U _IMPORT_DESCRIPTOR_libdbxml22
libdbxml22.dll: 00000000 I .idata$4 00000000 I .idata$5 00000000 I .idata$6 00000000 T .text 00000000 T ?add@XmlResults@DbXml@@QAEXABVXmlValue@2@@Z 00000000 I _imp_?add@XmlResults@DbXml@@QAEXABVXmlValue@2@@Z U _IMPORT_DESCRIPTOR_libdbxml22
Any pointers to some resources how should I continue are appreciated.
--Petr
A very good article is here:
http://en.wikipedia.org/wiki/Name_mangling
The FFI doesn't do name mangling so for calling C++ functions so you either need to provide the mangled name or provide a wrapper function (via extern "C").
Cheers, - Andreas
Petr wrote:
Hello, I am trying to use Berkeley DB XML from withing Squeak. I already found out how to call C functions, but I got stuck on "Error : can't find function address" when calling a function in a C++ shared library. So I first looked up some info on the Squeak wiki and found this: http://minnow.cc.gatech.edu/squeak/3735. I used nm from mingw on the libdbxml22.lib and got a lot of some information I do not exactly understand. An example:
libdbxml22.dll: 00000000 I .idata$4 00000000 I .idata$5 00000000 I .idata$6 00000000 T .text 00000000 T ?abort@XmlTransaction@DbXml@@QAEXXZ 00000000 I _imp_?abort@XmlTransaction@DbXml@@QAEXXZ U _IMPORT_DESCRIPTOR_libdbxml22
libdbxml22.dll: 00000000 I .idata$4 00000000 I .idata$5 00000000 I .idata$6 00000000 T .text 00000000 T ?add@XmlResults@DbXml@@QAEXABVXmlValue@2@@Z 00000000 I _imp_?add@XmlResults@DbXml@@QAEXABVXmlValue@2@@Z U _IMPORT_DESCRIPTOR_libdbxml22
Any pointers to some resources how should I continue are appreciated.
--Petr
Hello again! So I found out how to get the function names and I can successfully call them. As it is for me sufficient to run my program under windows, I am going to use the mangled names, without a C wrapper. However, I have another problem. How do I get values from functions, which return multiple values using a pointer? For example:
void DbXml::dbxml_version(int *majorp, int *minorp, int *patchp)
--Petr
Andreas Raab wrote:
A very good article is here:
http://en.wikipedia.org/wiki/Name_mangling
The FFI doesn't do name mangling so for calling C++ functions so you either need to provide the mangled name or provide a wrapper function (via extern "C").
Cheers,
- Andreas
Petr wrote:
Hello, I am trying to use Berkeley DB XML from withing Squeak. I already found out how to call C functions, but I got stuck on "Error : can't find function address" when calling a function in a C++ shared library. So I first looked up some info on the Squeak wiki and found this: http://minnow.cc.gatech.edu/squeak/3735. I used nm from mingw on the libdbxml22.lib and got a lot of some information I do not exactly understand. An example:
libdbxml22.dll: 00000000 I .idata$4 00000000 I .idata$5 00000000 I .idata$6 00000000 T .text 00000000 T ?abort@XmlTransaction@DbXml@@QAEXXZ 00000000 I _imp_?abort@XmlTransaction@DbXml@@QAEXXZ U _IMPORT_DESCRIPTOR_libdbxml22
libdbxml22.dll: 00000000 I .idata$4 00000000 I .idata$5 00000000 I .idata$6 00000000 T .text 00000000 T ?add@XmlResults@DbXml@@QAEXABVXmlValue@2@@Z 00000000 I _imp_?add@XmlResults@DbXml@@QAEXABVXmlValue@2@@Z U _IMPORT_DESCRIPTOR_libdbxml22
Any pointers to some resources how should I continue are appreciated.
--Petr
You create memory locations that the function can store into, like here:
majorp := IntegerArray new: 1. minorp := IntegerArray new: 1. patchp := IntegerArray new: 1.
self dbxmlVersion: majorp with: minorp with: patch
major := majorp at: 1. minor := minorp at: 1. patch := patchp at: 1.
(the above assumes that the arguments in your function are declared as long* which I presume they are)
Cheers, - Andreas
Petr wrote:
Hello again! So I found out how to get the function names and I can successfully call them. As it is for me sufficient to run my program under windows, I am going to use the mangled names, without a C wrapper. However, I have another problem. How do I get values from functions, which return multiple values using a pointer? For example:
void DbXml::dbxml_version(int *majorp, int *minorp, int *patchp)
--Petr
Andreas Raab wrote:
A very good article is here:
http://en.wikipedia.org/wiki/Name_mangling
The FFI doesn't do name mangling so for calling C++ functions so you either need to provide the mangled name or provide a wrapper function (via extern "C").
Cheers,
- Andreas
Petr wrote:
Hello, I am trying to use Berkeley DB XML from withing Squeak. I already found out how to call C functions, but I got stuck on "Error : can't find function address" when calling a function in a C++ shared library. So I first looked up some info on the Squeak wiki and found this: http://minnow.cc.gatech.edu/squeak/3735. I used nm from mingw on the libdbxml22.lib and got a lot of some information I do not exactly understand. An example:
libdbxml22.dll: 00000000 I .idata$4 00000000 I .idata$5 00000000 I .idata$6 00000000 T .text 00000000 T ?abort@XmlTransaction@DbXml@@QAEXXZ 00000000 I _imp_?abort@XmlTransaction@DbXml@@QAEXXZ U _IMPORT_DESCRIPTOR_libdbxml22
libdbxml22.dll: 00000000 I .idata$4 00000000 I .idata$5 00000000 I .idata$6 00000000 T .text 00000000 T ?add@XmlResults@DbXml@@QAEXABVXmlValue@2@@Z 00000000 I _imp_?add@XmlResults@DbXml@@QAEXABVXmlValue@2@@Z U _IMPORT_DESCRIPTOR_libdbxml22
Any pointers to some resources how should I continue are appreciated.
--Petr
squeak-dev@lists.squeakfoundation.org