Search code examples
c++zbar

Can't resolve type `zbar_image_t`


#include <iostream>
#include <zbar.h>

class BarcodeManager {
private:
    int32_t verbose;
    zbar_image_t *img;
};

zbar_image_t defined in zbar.h as below:

struct zbar_image_s;
/** opaque image object. */
typedef struct zbar_image_s zbar_image_t;

I included the header file zbar.h, and include_directories(${CMAKE_SOURCE_DIR}/include) in CMakeLists.txt .

ZBar is an open source software suite, and i download at https://github.com/ZBar/ZBar/archive/0.10.tar.gz

CLion reminds me

Can't resolve type zbar_image_t

And error when I make

error: ‘zbar_image_t’ does not name a type

I turn on verbose options with set(CMAKE_VERBOSE_MAKEFILE ON) in CMakeLists.txt, and saw -I/home/kgbook/koala -I/home/kgbook/koala/include.

koala is a C++ project.

It seems that all header file included normally.


Solution

  • I resolved myself.

    I analysis the zbar.h, and found it.

    #ifdef __cplusplus
    
    /** C++ namespace for library interfaces */
    namespace zbar {
        extern "C" {
    #endif
    

    koala project use C++, so using namespace zba; before using.