www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - binding to C++

reply drug <drug2004 bk.ru> writes:
Trying to bind to cpp code I stop at some moment having undefined 
reference to some cpp function. But objdump -Ct cpplibrary.so shows me 
that this cpp function exists in the library. linker message about cpp 
function is _identical_ to objdump message so I don't know where is the 
difference. For example linker says:
`undefined reference to 
`Namespace::StructName::method_name(Namespace::Otherstruct const*)`
And ojbdump called by command:
```
objdump -Ct libLibrary.so | method_name
```
shows the following:
```
0000000000026ed0  w    F .text  0000000000000025 
Namespace::StructName::method_name(Namespace::Otherstruct const*)
```
That is two outputs are identical.
Could someone help what to do to investigate the problem?
Thanks in advance
May 26 2017
next sibling parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Friday, 26 May 2017 at 15:17:08 UTC, drug wrote:
 Trying to bind to cpp code I stop at some moment having 
 undefined reference to some cpp function. But objdump -Ct 
 cpplibrary.so shows me that this cpp function exists in the 
 library. linker message about cpp function is _identical_ to 
 objdump message so I don't know where is the difference. For 
 example linker says:
 `undefined reference to 
 `Namespace::StructName::method_name(Namespace::Otherstruct 
 const*)`
 And ojbdump called by command:
 ```
 objdump -Ct libLibrary.so | method_name
 ```
 shows the following:
 ```
 0000000000026ed0  w    F .text  0000000000000025 
 Namespace::StructName::method_name(Namespace::Otherstruct 
 const*)
 ```
 That is two outputs are identical.
 Could someone help what to do to investigate the problem?
 Thanks in advance
Thats weird. DMD may have got the mangling wrong. Could you post the exact mangling (i.e. non-demangled)? And if DMD has got it wrong and its just the one function you could just `pragma(mangle, ...);` it.
May 26 2017
parent drug <drug2004 bk.ru> writes:
27.05.2017 02:44, Nicholas Wilson пишет:
 Thats weird. DMD may have got the mangling wrong. Could you post the
 exact mangling (i.e. non-demangled)? And if DMD has got it wrong and its
 just the one function you could just `pragma(mangle, ...);` it.
I use pragma(mangle, "...") (how I forget about it?) and it works now, so probable DMD have got the mangling wrong. Trying to reduce case, but code isn't trivial nether D nor C++ side...
May 29 2017
prev sibling next sibling parent Mike B Johnson <Mikey Ikes.com> writes:
On Friday, 26 May 2017 at 15:17:08 UTC, drug wrote:
 Trying to bind to cpp code I stop at some moment having 
 undefined reference to some cpp function. But objdump -Ct 
 cpplibrary.so shows me that this cpp function exists in the 
 library. linker message about cpp function is _identical_ to 
 objdump message so I don't know where is the difference. For 
 example linker says:
 `undefined reference to 
 `Namespace::StructName::method_name(Namespace::Otherstruct 
 const*)`
 And ojbdump called by command:
 ```
 objdump -Ct libLibrary.so | method_name
 ```
 shows the following:
 ```
 0000000000026ed0  w    F .text  0000000000000025 
 Namespace::StructName::method_name(Namespace::Otherstruct 
 const*)
 ```
 That is two outputs are identical.
 Could someone help what to do to investigate the problem?
 Thanks in advance
Hi, Welcome to D! Hi, Welcome to D!
May 26 2017
prev sibling parent Oleksii <al.skidan gmail.com> writes:
On Friday, 26 May 2017 at 15:17:08 UTC, drug wrote:
 Trying to bind to cpp code I stop at some moment having 
 undefined reference to some cpp function. But objdump -Ct 
 cpplibrary.so shows me that this cpp function exists in the 
 library. linker message about cpp function is _identical_ to 
 objdump message so I don't know where is the difference. For 
 example linker says:
 `undefined reference to 
 `Namespace::StructName::method_name(Namespace::Otherstruct 
 const*)`
 And ojbdump called by command:
 ```
 objdump -Ct libLibrary.so | method_name
 ```
 shows the following:
 ```
 0000000000026ed0  w    F .text  0000000000000025 
 Namespace::StructName::method_name(Namespace::Otherstruct 
 const*)
 ```
 That is two outputs are identical.
 Could someone help what to do to investigate the problem?
 Thanks in advance
If you were compiling C++ code, you could get such error if method_name was declared const in the library, and you tried to link it as non-const. == Library == struct StructName { void method_name(...) const { ... } }; == Your Code == struct StructName { void method_name(...); /* NOTE: no const here */ }; Don't know if that is the issue in your case.
May 30 2017