C ++库中的重复定义

时间:2016-05-19 19:28:08

标签: c++ compiler-errors

我尝试使用DNG SDK和LibRaw(可以使用DNG SDK)构建库。当我构建两者时,我得到一系列重复的定义错误:

In file included from libraw.h:43:0,
                 from imageprocessor.cpp:4:
libraw_internal.h:178:8: error: previous definition of 'class tiff_tag'
 struct tiff_tag {
        ^
In file included from imageprocessor.cpp:5:0: 
dng_image_writer.h: In constructor 'tag_data_ptr::tag_data_ptr(uint16, uint16, uint32, const void*)':
dng_image_writer.h:144:17: error: no matching function for call to 'tiff_tag::tiff_tag(uint16&, uint16&, uint32&)'
    , fData (data)
                 ^
dng_image_writer.h:144:17: note: candidates are:
In file included from libraw.h:43:0,
                 from imageprocessor.cpp:4:
libraw_internal.h:178:8: note: tiff_tag::tiff_tag()
 struct tiff_tag {
        ^
libraw_internal.h:178:8: note:   candidate expects 0 arguments, 3 provided
libraw_internal.h:178:8: note: constexpr tiff_tag::tiff_tag(const tiff_tag&)
libraw_internal.h:178:8: note:   candidate expects 1 argument, 3 provided
libraw_internal.h:178:8: note: constexpr tiff_tag::tiff_tag(tiff_tag&&)
libraw_internal.h:178:8: note:   candidate expects 1 argument, 3 provided

我的代码还没有使用DNG,只需添加:

#include <dng_image_writer.h>

足以产生错误。 C ++不是我的强项,有没有办法管理这些冲突而不修改任何一个库?

冲突声明:

dng_image_writer.h:144:

tag_data_ptr (uint16 code,
                      uint16 type,
                      uint32 count,
                      const void *data)

            :   tiff_tag (code, type, count)

            ,   fData (data)

            {
            }

libraw_internal.h:178

struct tiff_tag {
  ushort tag, type;
  int count;
  union { char c[4]; short s[2]; int i; } val;
};

编辑添加DNG:tiff_tag声明

class tiff_tag
    {

    protected:

        uint16 fCode;

        uint16 fType;

        uint32 fCount;

    protected:

        tiff_tag (uint16 code,
                  uint16 type,
                  uint32 count)

            :   fCode  (code)
            ,   fType  (type)
            ,   fCount (count)

            {
            }

    public:

        virtual ~tiff_tag ()
            {
            }

        uint16 Code () const
            {
            return fCode;
            }

        uint16 Type () const
            {
            return fType;
            }

        uint32 Count () const
            {
            return fCount;
            }

        void SetCount (uint32 count)
            {
            fCount = count;
            }

        uint32 Size () const
            {
            return TagTypeSize (Type ()) * Count ();
            }

        virtual void Put (dng_stream &stream) const = 0;

    private:

        // Hidden copy constructor and assignment operator.

        tiff_tag (const tiff_tag &tag);

        tiff_tag & operator= (const tiff_tag &tag);

    };

如果有任何其他代码有用,请告诉我。感谢。

0 个答案:

没有答案