Hi!!
i'm trying to add python 3.9 source to my plugins. test.c
#include <Python.h>
int main()
{
PyObject* pInt;
Py_Initialize();
PyRun_SimpleString("print('Hello World from Embedded Python!!!')");
Py_Finalize();
printf("\nPress any key to exit...\n");
if(!_getch()) _getch();
return 0;
}
But when i compile i have an error including python
CC test.c
test.c:3:10: fatal error: Python.h: No such file or directory
3 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:106: ../../plugins/test.so] Error 1
i research a little about it on stackoverflow and im seeying to pass the flags into plugins makefile like this
Makefile: Makefile.in
@$(MAKE) -C ../.. src/plugins/Makefile
.SECONDEXPANSION:
../../plugins/%@
[email protected]: %.c $(ALL_H) $$(shell ls %/* 2>/dev/null)
@echo " CC $<"
@$(CC) $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @
[email protected] @
[email protected] @
[email protected] -I/usr/include/python3.9 -Wno-unused-result -Wsign-compare -g -ffile-prefix-map=/build/python3.9-FZ7wim/python3.9-3.9.5=. -flto=auto -ffat-lto-objects -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall @
[email protected] @
[email protected] -L/usr/lib/python3.9/config-3.9-x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lcrypt -lpthread -ldl -lutil -lm -lm @
[email protected] @
[email protected] @
[email protected] -o
[email protected] $<
../../plugins/
[email protected]@: HPMHOOKINGTYPE = LOGIN
../../plugins/
[email protected]@: HPMHOOKINGTYPE = CHAR
../../plugins/
[email protected]@: HPMHOOKINGTYPE = MAP
../../plugins/HPMHooking_%@
[email protected]: HPMHooking.c $(ALL_H) $$(shell ls HPMHooking/*_%* HPMHooking/*_common* 2>/dev/null)
@echo " CC $< ($(HPMHOOKINGTYPE))"
@$(CC) -DHPMHOOKING_$(HPMHOOKINGTYPE) $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @
[email protected] @
[email protected] @
[email protected] -I/usr/include/python3.9 -Wno-unused-result -Wsign-compare -g -ffile-prefix-map=/build/python3.9-FZ7wim/python3.9-3.9.5=. -flto=auto -ffat-lto-objects -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall @
[email protected] @
[email protected] -L/usr/lib/python3.9/config-3.9-x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lcrypt -lpthread -ldl -lutil -lm -lm @
[email protected] -o
[email protected] $<
And when i compile with flags i got this error, like the python 3.9 is included now, but the linker doesnt work.
Could anyone help me how to solve this and add python to my plugins?
Thank you so much
usr/bin/ld: /tmp/test.so.Yc5jF3.ltrans0.ltrans.o: in function `main':
/home/ubuntu/hercules/src/plugins/test.c:9: undefined reference to `Py_Initialize'
/usr/bin/ld: /home/ubuntu/hercules/src/plugins/test.c:11: undefined reference to `PyRun_SimpleStringFlags'
/usr/bin/ld: /home/ubuntu/hercules/src/plugins/test.c:13: undefined reference to `Py_Finalize'
/usr/bin/ld: /home/ubuntu/hercules/src/plugins/test.c:16: undefined reference to `_getch'
/usr/bin/ld: /home/ubuntu/hercules/src/plugins/test.c:16: undefined reference to `_getch'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:106: ../../plugins/test.so] Error 1
make[1]: Leaving directory '/home/ubuntu/hercules/src/plugins'
make: *** [Makefile:132: plugins] Error 2