objectbox-c icon indicating copy to clipboard operation
objectbox-c copied to clipboard

flatbuffers.h does not found when compiling

Open monhi opened this issue 2 years ago • 4 comments

:rotating_light: First, please check:

  • existing issues,
  • Docs https://cpp.objectbox.io/

Describe the bug When I add include and lib to the project in windows and using Visual Studio 2013 to compile it I get an error which says it could not find "flatbuffers/flatbuffers.h"

Basic info (please complete the following information):

  • ObjectBox version: [e.g. 0.18.0-windows-x64, latest version?]
  • C or C++ version: [e.g. C++11, Visual Studio 2013]
  • Reproducibility: [always]
  • OS: [Windows 10]

To Reproduce Steps to reproduce the behavior: Just try to compile the code in a Visual C++ project. Expected behavior A clear and concise description of what you expected to happen. Just I would like it to compile. Code If applicable, add code to help explain your problem.

  • Include affected entity code.
  • Please remove any unnecessary or confidential parts.
  • At best, link to or attach a project with a failing test.

Logs, stack traces If applicable, add relevant logs, or a stack trace.

Additional context Add any other context about the problem here.

  • Is there anything special about your code?
  • May transactions or multi-threading play a role?
  • Did you find any workarounds to prevent the issue?

monhi avatar Jan 25 '23 08:01 monhi

To help efficiently, may I ask you to provide additional information about your setup and the location of the compiler error you are getting? For future issues, please clean up the unused text from the issue template to make it more readable. Thanks!

greenrobot avatar Jan 25 '23 12:01 greenrobot

Please download my analyzer application from following link and try to compile it with Visual Studio 2013 or 2015 or higher. https://github.com/monhi/Online-Crypto-Analyzer I just tried to add lib and include path to the project in Debug mode and add following file to the main file. #include "./include/objectbox.hpp" Then I try to compile the project and get for following line:

#ifndef OBX_DISABLE_FLATBUFFERS // FlatBuffers is required to put data; you can disable it until have the include file. #include "flatbuffers/flatbuffers.h" #endif

which says flatbuffers.h does not found. I expect to see the above file in the include path.

to neglect the error I just comment out above include line and then try to compile the code and find other syntax errors. But for now, Please let me know if it works without flatbuffers or not. If we are supposed to add flatbuffers to make it run, isn't it better to add it to the project?

Best wishes,

monhi avatar Jan 25 '23 14:01 monhi

OK, so if your setup also includes ObjectBox generator, you want to have Flatbuffers. If you want you can go with the version in the external/flatbuffers directory. You need to setup your compiler to use that directory for includes.

Btw, there is some existing documentation here: https://cpp.objectbox.io/installation#flatbuffers-optional

  • [x] But yes, we should add some details to that documentation. Updated docs: https://cpp.objectbox.io/installation#flatbuffers

greenrobot avatar Jan 25 '23 17:01 greenrobot

Let me test and inform you tomorrow

monhi avatar Jan 25 '23 18:01 monhi