digitalmars.D.learn - optlink and weak symbols
- Ellery Newcomer (9/9) Oct 16 2012 I am interfacing with some C code [python.dll], which has some structs
- Jacob Carlborg (6/15) Oct 16 2012 You need to declare the variable as "extern" if it's defined in the C co...
- Ellery Newcomer (2/5) Oct 17 2012 nice tip, but adding extern doesn't change link behavior at all.
- Jacob Carlborg (5/6) Oct 17 2012 Hmm, are you linking with the DLL (the import library) ? In not, you
- Regan Heath (5/9) Oct 18 2012 LoadLibrary[Ex]
- Ellery Newcomer (4/8) Oct 18 2012 I am using python27_digitalmars.lib, which is generated from
- Jacob Carlborg (9/12) Oct 18 2012 Ok. Do you know how the corresponding C code would look like? Maybe you
- Ellery Newcomer (5/15) Oct 18 2012 ha HA!
- Jacob Carlborg (4/7) Oct 18 2012 Hehe, high five :)
I am interfacing with some C code [python.dll], which has some structs declared like so: PyTypeObject PyType_Type; I wish to be able to link to PyType_Type like so: extern(C) __gshared PyTypeObject PyType_Type; in linux, I can do exactly that, but optlink is generating a new memory location for PyType_Type. strings output suggests that my lib file contains the symbol PyType_Type. Is this sort of thing supposed to work?
Oct 16 2012
On 2012-10-17 07:07, Ellery Newcomer wrote:I am interfacing with some C code [python.dll], which has some structs declared like so: PyTypeObject PyType_Type; I wish to be able to link to PyType_Type like so: extern(C) __gshared PyTypeObject PyType_Type; in linux, I can do exactly that, but optlink is generating a new memory location for PyType_Type. strings output suggests that my lib file contains the symbol PyType_Type. Is this sort of thing supposed to work?You need to declare the variable as "extern" if it's defined in the C code: extern(C) extern __gshared PyTypeObject PyType_Type; http://dlang.org/interfaceToC.html#C%20Globals -- /Jacob Carlborg
Oct 16 2012
On 10/16/2012 11:16 PM, Jacob Carlborg wrote:You need to declare the variable as "extern" if it's defined in the C code: extern(C) extern __gshared PyTypeObject PyType_Type; http://dlang.org/interfaceToC.html#C%20Globalsnice tip, but adding extern doesn't change link behavior at all.
Oct 17 2012
On 2012-10-18 05:12, Ellery Newcomer wrote:nice tip, but adding extern doesn't change link behavior at all.Hmm, are you linking with the DLL (the import library) ? In not, you need to use dlopen, or what the corresponding Windows function is. -- /Jacob Carlborg
Oct 17 2012
On Thu, 18 Oct 2012 07:41:16 +0100, Jacob Carlborg <doob me.com> wrote:On 2012-10-18 05:12, Ellery Newcomer wrote:LoadLibrary[Ex] R -- Using Opera's revolutionary email client: http://www.opera.com/mail/nice tip, but adding extern doesn't change link behavior at all.Hmm, are you linking with the DLL (the import library) ? In not, you need to use dlopen, or what the corresponding Windows function is.
Oct 18 2012
On 10/17/2012 11:41 PM, Jacob Carlborg wrote:On 2012-10-18 05:12, Ellery Newcomer wrote:I am using python27_digitalmars.lib, which is generated from libs\python27.lib with coffimplib, and it is linking my executables with python.dll.nice tip, but adding extern doesn't change link behavior at all.Hmm, are you linking with the DLL (the import library) ? In not, you need to use dlopen, or what the corresponding Windows function is.
Oct 18 2012
On 2012-10-18 13:55, Ellery Newcomer wrote:I am using python27_digitalmars.lib, which is generated from libs\python27.lib with coffimplib, and it is linking my executables with python.dll.Ok. Do you know how the corresponding C code would look like? Maybe you need to use the "export" attribute. It's the same as "__declspec(dllimport)", have a look: http://dlang.org/htomodule.html If that doesn't work then I'm out of suggestions, Windows is not my primary platform. -- /Jacob Carlborg
Oct 18 2012
On 10/18/2012 11:36 AM, Jacob Carlborg wrote:On 2012-10-18 13:55, Ellery Newcomer wrote:ha HA! extern(C) extern export PyTypeObject PyType_Type; seems to do the trick (I'm using a boiled down case just now)! High five to the [non-me] non-windows dev!I am using python27_digitalmars.lib, which is generated from libs\python27.lib with coffimplib, and it is linking my executables with python.dll.Ok. Do you know how the corresponding C code would look like? Maybe you need to use the "export" attribute. It's the same as "__declspec(dllimport)", have a look: http://dlang.org/htomodule.html If that doesn't work then I'm out of suggestions, Windows is not my primary platform.
Oct 18 2012
On 2012-10-19 02:30, Ellery Newcomer wrote:extern(C) extern export PyTypeObject PyType_Type; seems to do the trick (I'm using a boiled down case just now)! High five to the [non-me] non-windows dev!Hehe, high five :) -- /Jacob Carlborg
Oct 18 2012