Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug] [C-API]: build-errors of multiple declaration of global variables when including multiple "openvino.h" #28801

Open
3 tasks done
xygnal opened this issue Feb 4, 2025 · 1 comment · May be fixed by #28877
Open
3 tasks done
Assignees
Labels
bug Something isn't working category: C API OpenVINO C API bindings support_request

Comments

@xygnal
Copy link

xygnal commented Feb 4, 2025

OpenVINO Version

Master branch

Operating System

Ubuntu 20.04 (LTS)

Device used for inference

GPU

Framework

None

Model used

No response

Issue description

I wrote the C codes of the real-time video inference using OPENVino.
I includes <openvino/c/openvino.h> in many files,
and I get the build-errors of the multiple declaration of global variables.

I found that the cause of errors. (And I have avoided the errors at my side)
Global variables in API are declared without "extern" when using C compiler.

src/bindings/c/include/openvino/c/ov_common.h,

WITH C compiler, not static library, and LINUX,

  • line 36, # define OPENVINO_C_API_EXTERN
  • line 56, # define OPENVINO_C_VAR(...) OPENVINO_C_API_EXTERN attribute((visibility("default"))) VA_ARGS

WITH C compiler, global variables in API shall be defined with "extern".
So, how about modifying the ov_common.h like the below?

#ifdef __cplusplus
#define OPENVINO_C_VAR_EXTERN extern "C"
#else
#define OPENVINO_C_VAR_EXTERN extern
#endif
...
#define OPENVINO_C_VAR(...) OPENVINO_C_VAR_EXTERN ... ... ...

Step-by-step reproduction

No response

Relevant log output

Issue submission checklist

  • I'm reporting an issue. It's not a question.
  • I checked the problem with the documentation, FAQ, open issues, Stack Overflow, etc., and have not found a solution.
  • There is reproducer code and related data files such as images, videos, models, etc.
@xygnal xygnal added bug Something isn't working support_request labels Feb 4, 2025
@ilya-lavrenov ilya-lavrenov changed the title [Bug]: build-errors of multiple declaration of global variables when including multiple "openvino.h" [Bug] [C-API]: build-errors of multiple declaration of global variables when including multiple "openvino.h" Feb 4, 2025
@praasz
Copy link
Contributor

praasz commented Feb 7, 2025

@xygnal Thank you for reporting the issue and suggestion.

Here is a fix:

@ilya-lavrenov ilya-lavrenov added the category: C API OpenVINO C API bindings label Feb 8, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working category: C API OpenVINO C API bindings support_request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants