app.cxx 738 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "Python.h"
  2. #include <iostream>
  3. #include "lib.h"
  4. // cython function
  5. #include "cy_cxxtest_api.h"
  6. int main(int argc, char** argv)
  7. {
  8. std::cout << "::: cxx-app\n";
  9. Py_Initialize();
  10. if (!Py_IsInitialized()) {
  11. std::cerr << ":: could not initialize python interpreter !\n";
  12. return 1;
  13. } else {
  14. std::cout << ":: python initialized\n";
  15. }
  16. PyEval_InitThreads();
  17. if (!PyEval_ThreadsInitialized()) {
  18. std::cerr << ":: could not init GIL !\n";
  19. return 1;
  20. }
  21. if (import_cy_cxxtest()) {
  22. std::cerr << "** could not import 'cy_cxxtest' module !\n";
  23. return 1;
  24. } else {
  25. std::cout << "::: successfully imported 'cy_cxxtest'\n";
  26. }
  27. cy_hello();
  28. std::cout << "::: cxx-app [done]\n";
  29. return 0;
  30. }