So, I was trying to run a basic cpp function in python so I could make my python code a bit faster, but when I run my code I get an error that I have not ben able to find anything on google for how to fix.
How would I fix this error in my specific situation?
Error
File "/home/runner/PengineRemake/PenginePlusPlus/__init__.py", line 12, in e
cfn.hello_world(x)
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__
func = self.__getitem__(name)
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/ctypes/__init__.py", line 391, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: ./library.so: undefined symbol: hello_world
main.py
import PenginePlusPlus as p
p.cfn.hello_world()
PenginePlusPlus/init.py
import os
name = "PenginePlusPlus"
os.system("g++ -shared -c -fPIC "+name+"/main.cpp -o main.o")
os.system("g++ -shared -Wl,-soname,library.so -o library.so main.o")
import ctypes
cfn=ctypes.CDLL('./library.so')
PenginePlusPlus/main.cpp
#include <iostream>
using namespace std;
int hello_world(){
cout << "Hello World!";
return 1;
}