TinySoundFont icon indicating copy to clipboard operation
TinySoundFont copied to clipboard

Duplicate Symbols

Open MeijisIrlnd opened this issue 4 years ago • 4 comments

Hiya, this might be a dumb question, but I want to include tsf.h in a header file, then include that header in main, and its giving me 40 duplicate symbols when I do (I see you said to include it in one file, I've tried pragma onceing it etc etc and its still showing duplicates, any ways around this?

MeijisIrlnd avatar Mar 29 '20 13:03 MeijisIrlnd

Hi there Feel free to just include tsf.h in many places, but in one single C/C++ file you need to have

#define TSF_IMPLEMENTATION
#include "tsf.h"

in there. Placement doesn't really matter but it should be after all other #include directives. Make sure to remove the #pragma once because if you have it in a global header and then the TSF_IMPLEMENTATION define followed by a re-include it needs to allow multiple include'ing of the same file.

schellingb avatar Mar 29 '20 13:03 schellingb

cheers for your speedy reply, it's probably my xcode settings thanks for clarifying it isnt a one time include thing ahaha, will edit this if i get it sorted, thanks again!

MeijisIrlnd avatar Mar 29 '20 14:03 MeijisIrlnd

Yeah so super weird, no idea why this wouldnt work, here's the error, the include in my header and then that header being included in main (Also just realised that is just not how you spell creator) Screen Shot 2020-03-29 at 15 14 19 Screen Shot 2020-03-29 at 15 14 31 Screen Shot 2020-03-29 at 15 14 42

(EDIT: #define TSF_STATIC fixed the build, weird???

MeijisIrlnd avatar Mar 29 '20 14:03 MeijisIrlnd

Can't you try moving the #define TSF_IMPLEMENTATION and #include "tsf.h" below the line #include "SouncfontCreater.hpp"? Not sure if that solves linker errors though. And there is no #define TSF_IMPLEMENTATION anywhere else in all other c/h/cpp/hpp files?

If it's still not working, can you paste the whole build output and not just a screenshot?

#define TSF_STATIC might remove the errors for you but it's not really a great solution because you end up with multiple copies of the same function in the build output which would be avoided if it's resolved correctly.

schellingb avatar Mar 29 '20 15:03 schellingb