oatpp / example-crud

A complete example of a "CRUD" service (UserService) built with Oat++.
https://oatpp.io/
Apache License 2.0
100 stars 63 forks source link

what(): [oatpp::swagger::Resources::loadFromFile(...)]: Can't load file. Please make sure you specified full path to oatpp-swagger/res folder #12

Closed BaseMax closed 3 years ago

BaseMax commented 3 years ago
[max@workstation build]$ cmake ..
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/max/Projects/Git/example-crud/build

[max@workstation build]$ make
[ 12%] Building CXX object CMakeFiles/crud-lib.dir/src/service/UserService.cpp.o
[ 25%] Building CXX object CMakeFiles/crud-lib.dir/src/ErrorHandler.cpp.o
[ 37%] Linking CXX static library libcrud-lib.a
[ 37%] Built target crud-lib
[ 50%] Building CXX object CMakeFiles/crud-test.dir/test/tests.cpp.o
[ 62%] Building CXX object CMakeFiles/crud-test.dir/test/UserControllerTest.cpp.o
[ 75%] Linking CXX executable crud-test
[ 75%] Built target crud-test
[ 87%] Building CXX object CMakeFiles/crud-exe.dir/src/App.cpp.o
[100%] Linking CXX executable crud-exe
[100%] Built target crud-exe

[max@workstation build]$ ls
CMakeCache.txt  CMakeFiles  cmake_install.cmake  crud-exe  crud-test  CTestTestfile.cmake  libcrud-lib.a  Makefile
[max@workstation build]$ ./crud-exe 
 E |2021-06-05 18:40:28 1622902228689958| oatpp::swagger::Resources::loadFromFile():Can't load file '/usr/include//../bin/oatpp-swagger/res/favicon-16x16.png'
terminate called after throwing an instance of 'std::runtime_error'
  what():  [oatpp::swagger::Resources::loadFromFile(...)]: Can't load file. Please make sure you specified full path to oatpp-swagger/res folder
Aborted (core dumped)

[max@workstation build]$ ./crud-test 
 I |2021-06-05 18:40:35 1622902235246731| TEST[UserControllerTest]:START...
 I |2021-06-05 18:40:35 1622902235246904| TEST[UserControllerTest]:DB-File='/home/max/Projects/Git/example-crud/test-db.sqlite'
 D |2021-06-05 18:40:35 1622902235278150| UserDb:Migration - OK. Version=1.
 D |2021-06-05 18:40:35 1622902235279239| ClientServerTestRunner:Running server on port 0. Timeout 600000000(micro)
 D |2021-06-05 18:40:35 1622902235305233| ClientServerTestRunner:Finished with time 25979(micro). Stopping server...
 I |2021-06-05 18:40:36 1622902236348958| TEST[UserControllerTest]:FINISHED - success!
 I |2021-06-05 18:40:36 1622902236349018| TEST[UserControllerTest]:1102052(micro), 430(objs)

Environment:
objectsCount = 0
objectsCreated = 430

[max@workstation build]$ ./crud-exe 
 E |2021-06-05 18:40:40 1622902240143130| oatpp::swagger::Resources::loadFromFile():Can't load file '/usr/include//../bin/oatpp-swagger/res/favicon-16x16.png'
terminate called after throwing an instance of 'std::runtime_error'
  what():  [oatpp::swagger::Resources::loadFromFile(...)]: Can't load file. Please make sure you specified full path to oatpp-swagger/res folder
Aborted (core dumped)
[max@workstation build]$ pwd
/home/max/Projects/Git/example-crud/build
BaseMax commented 3 years ago

I guess it will solve by apply a minor change at CMakeLists.txt file of example projects. I tested it on the https://github.com/oatpp/example-postgresql project:

-DOATPP_SWAGGER_RES_PATH="${oatpp-swagger_INCLUDE_DIRS}/../bin/oatpp-swagger/res"

to:

-DOATPP_SWAGGER_RES_PATH="/usr/local/include/oatpp-1.2.5/bin/oatpp-swagger/res"
lganzzzo commented 3 years ago

Thanks for posting the answer!