oatpp / oatpp-starter

Oatpp simple-API starter project
https://oatpp.io/
Apache License 2.0
72 stars 35 forks source link

How to integrate with other projects? #15

Open mochechan opened 3 years ago

mochechan commented 3 years ago

I'm attempting to integrate OATPP with my project, but no success so far. The reason should be that I'm not familiar with OATPP.

My evaluations are described as follows:

Evaluation 1: in the test/ folder

Insert #include "xalpr.hpp" here.

In the function int main() , insert the code:

  xalpr XALPR;
  XALPR.init();
  XALPR.recognize("");

Where the xlapr is a class. The result fits my expectation. It seems that the CMakeLists.txt has necessary modifications.

Evaluation 2: in the src/controller/ folder

With corresponding to the Evaluation 1, the CMakeLists.txt has some necessary modifications. Insert #include "xalpr.hpp" here.

In the constructor MyController, insert the code:

  xalpr XALPR;
  XALPR.init();
  XALPR.recognize("");

When make, the following errors appear:

In file included from /home/xalpr/src/controller/MyController.cpp:1:
/home/xalpr/src/controller/MyController.hpp: In constructor ‘MyController::MyController(std::shared_ptr<oatpp::data::mapping::ObjectMapper>&)’:
/home/xalpr/src/controller/MyController.hpp:37:5: error: ‘xalpr’ was not declared in this scope
   37 |     xalpr XALPR;
      |     ^~~~~
/home/xalpr/src/controller/MyController.hpp:38:5: error: ‘XALPR’ was not declared in this scope
   38 |     XALPR.init();
      |     ^~~~~
make[2]: *** [CMakeFiles/my-project-lib.dir/build.make:76: CMakeFiles/my-project-lib.dir/src/controller/MyController.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:113: CMakeFiles/my-project-lib.dir/all] Error 2
make: *** [Makefile:101: all] Error 2

Note: Please ignore line numbers due to the code has some modifications. Question: How to solve this problem?

Evaluation 3: in the src/controller/ folder

Pending due to the Evaluation 2 is not yet solved. The goal is that each ENDPOINT can call the function XALPR.recognize(""). Helpful tips are welcome. Thanks a lot.