Flix01 / imgui

Dear ImGui Addons Branch = plain unmodified dear imgui plus some extra addon.
https://github.com/Flix01/imgui/wiki/ImGui-Addons-Branch-Home
MIT License
395 stars 34 forks source link

multiple definition of `gImGuiUserEventCallback' #28

Closed traw closed 6 years ago

traw commented 7 years ago

I am using CMake to compile imgui with SDL-bindings, It give following error

../CMakeFiles/IMGUI_OBJS.dir/imgui-Flix01/imgui.cpp.o:(.bss+0x1f0): multiple definition of `gImGuiUserEventCallback'
CMakeFiles/Proj.dir/app.cpp.o:(.data+0xb0): first defined here
collect2: error: ld returned 1 exit status
src/CMakeFiles/Proj.dir/build.make:585: recipe for target 'bin/Proj' failed
make[2]: *** [bin/Proj] Error 1
CMakeFiles/Makefile2:196: recipe for target 'src/CMakeFiles/Proj.dir/all' failed
make[1]: *** [src/CMakeFiles/Chokidar.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

If I comment line number 20 of imguibindings.cpp

//ImImplVoidDelegateTakingVoidPtr gImGuiUserEventCallback = NULL;

it works fine. I think it's consequence of extern keyword.

Flix01 commented 7 years ago

This is a duplicate of https://github.com/Flix01/imgui/issues/22 (you should have reopened that).

Anyway, there's only only definition of ImImplVoidDelegateTakingVoidPtr gImGuiUserEventCallback = NULL;, and it's at line number 20 of imguibindings.cpp.

If you have multiple definitions, it means you have defined it somewhere else (for example in your file: app.cpp).

Can you try to: option (1): declare it extern in app.cpp, or option (2): just include imguibindings.h from app.cpp, removing the additional declaration of gImGuiUserEventCallback from it and see if it works ?

Otherwise you must have compiled imguibindings.cpp twice (maybe included from multiple cpp files). Can you check it please ?

traw commented 6 years ago

Thanks I'll look check that

traw commented 6 years ago

Thanks for pointing it out I just check I have defined it in my application.