Reputation: 109
I'm working with Python's ctypes to make calls into the Intel Processor Trace library (libipt) on Linux. One of the initialization functions in the library, pt_config_init(), is defined as a static inline function in the intel-pt.h header file. When I try to call this function from my Python code, it throws this error:
libipt.pt_config_init(byref(config))
File "/usr/lib64/python3.5/ctypes/__init__.py", line 355, in __getattr__
func = self.__getitem__(name)
File "/usr/lib64/python3.5/ctypes/__init__.py", line 360, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /lib64/libipt.so.1.4.0: undefined symbol: pt_config_init
This makes sense, as the function isn't compiled into the library but instead accessed by including the header file in the relevant C sources. Is there a way to call an inline function like this with ctypes, and if so, how? Any suggested workarounds if not?
Upvotes: 1
Views: 1083
Reputation: 1638
No it's not possible.
This function not only is not exported by your library, it could not exist at all!
When compiler decides it's worth inlining (keyword is only suggestion) function body is copy/pasted in all places where normally would be called when not defined inline.
Upvotes: 2