Closed traw closed 7 years ago
Your command-line refers to main.cpp. However when I use this command-line:
/.../addons_examples$ g++ -g -o main2_sdl ../../imgui.cpp ../../imgui_draw.cpp main2.cpp -I"../../" -D"IMGUI_INCLUDE_IMGUI_USER_H" -D"IMGUI_INCLUDE_IMGUI_USER_INL" `sdl2-config --cflags` -D"IMGUI_USE_SDL2_BINDING" -L"/usr/lib/x86_64-linux-gnu" `sdl2-config --libs` -lX11 -lm -lGL
/.../addons_examples$ ./main2_sdl
Then it works. The reason is probably that, technically, when compiling more than one source file together in a single command line, it's better to keep them in order (that is to compile main2.cpp last): otherwise it might happen that a static variable needs another static variable that's not defined yet (I guess the linker is not smart enough...). In any case my command-line should work. It's not an error in the source code.
P.S. I must admit that this is the first time I see this happen (and of course when using any of the provided project files for Linux it does not happen because each source file is compiled separately and linked at the end). It seems that the emscripten compiler is not affected by the cpp file order too.
It's even possible that this is a bug of g++... We should try using clang++ and see...
Actually it seems that what you've discovered affects clang and emscripten as well! I've made some modifications to README_FIRST.txt to explain that the source file order is important.
Except
main2
all other examples given in _addonexamples works. I am using following command to compile all the examples. I'm using Ubuntu 16.04LTS.Crash log: