charlietangora / gif-h

Simple C++ one-header library for the creation of animated GIFs from image data.
The Unlicense
497 stars 98 forks source link

Qt project: multiple definition of `XXX` #11

Closed sonichy closed 5 years ago

sonichy commented 5 years ago
error: multiple definition of `GifIMax(int, int)'
error: multiple definition of `GifIMin(int, int)'
error: multiple definition of `GifIAbs(int)'
......
rversteegen commented 5 years ago

gif.h is a header-only library. It must be included in only one .cpp file.

(Would be nice if you could set a #define before including it to get only function declarations, not implementations. I would need that, except I'm using an autogenerated header file for another language anyway.)

sonichy commented 5 years ago

Split the gif.h to gif.h(declaration) and gif.cpp(implementation) solved this problem !

//gif.h
#ifndef gif_h
#define gif_h
int GifIMax(int l, int r);
......
#endif

//gif.cpp
#include "gif.h"
int GifIMax(int l, int r) { return l>r?l:r; }
......

https://github.com/sonichy/HTYScreenRecorder