mirror of
https://github.com/guilhermewerner/rust-ffi
synced 2025-06-15 05:14:18 +00:00
Add Python Example
This commit is contained in:
25
Examples/Python/Main.py
Normal file
25
Examples/Python/Main.py
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright (c) TribuFu. All Rights Reserved
|
||||
|
||||
import platform
|
||||
|
||||
from ctypes import *
|
||||
|
||||
# Windows
|
||||
|
||||
if platform.system() == "Windows":
|
||||
Library = cdll.LoadLibrary("./Binaries/debug/Library.dll")
|
||||
|
||||
# Linux
|
||||
|
||||
elif platform.system() == "Linux":
|
||||
Library = cdll.LoadLibrary("./Binaries/debug/libLibrary.so")
|
||||
# Mac
|
||||
|
||||
elif platform.system() == "Darwin":
|
||||
Library = cdll.LoadLibrary("./Binaries/debug/libLibrary.dylib")
|
||||
|
||||
Library.Hello.restype = c_char_p
|
||||
|
||||
data = c_char_p("Python".encode('utf-8'))
|
||||
|
||||
print(Library.Hello(data))
|
Reference in New Issue
Block a user