I can build the Vulkan demos using the cmake, and I ran the code and it works.
However, I am trying to create a simpler set of demos that simplifies initial coding effort.
Assuming I can get the following to work, the idea is to factor out all code for a class of demo, and shrink the size of a hello world. Currently “hello triangle” is 1300 lines, which is crazy.
All the support code is in base/ so I create a library. For each file I compile with:
g++ -std=c++17 -g -I . -I../external -I../external/tinygltf -I../external/ktx/include -DVK_USE_PLATFORM_XCB_KHR -c VulkanUIOverlay.cpp
Then I build a library:
ar rcs libbase.a VulkanAndroid.o VulkanDevice.o VulkanRaytracingSample.o VulkanTools.o VulkanBuffer.o vulkanexamplebase.o VulkanSwapChain.o VulkanUIOverlay.o VulkanDebug.o VulkanglTFModel.o VulkanTexture.o
Then I try to compile the triangle demo with:
g++ -Wall -g -o trianglevulkan13 -I base trianglevulkan13.cpp -L. -lvulkan -lbase -lxcb
It compiles with a couple of warnings about sign problems, but nothing that I changed.
When I run, it crashes on line 918:
vulkanExample = new VulkanExample():
vulkanExample->initVulkan();
vulkanExample->setupWindow();
the pointer vulkanExample looks fine but the source code isn’t available. So now I tried to move all the code into my project so it would be visible. All the objects in the archive are compiled with debugging.
Temporarily I just have a makefile, I am building on linux (Popos)
DEBUG := -g
INC := -I . -I../external -I../external/tinygltf -I../external/ktx/include -I../external/imgui
VK := -DVK_USE_PLATFORM_XCB_KHR
CXX := g++ -std=c++17 $(DEBUG) $(INC) $(VK)
COMP := $(CXX) -c
OBJ := VulkanAndroid.o VulkanDevice.o VulkanRaytracingSample.o \
VulkanTools.o VulkanBuffer.o vulkanexamplebase.o \
VulkanSwapChain.o VulkanUIOverlay.o VulkanDebug.o \
VulkanglTFModel.o VulkanTexture.o \
imgui.o imgui_widgets.o
libbase.a: $(OBJ)
ar rcs libbase.a $(OBJ)
.cpp.o:
$(COMP) $<
clean:
rm *.o
Now I’m getting linker errors
undefined reference to `ImDrawList::PathArcTo(ImVec2 const&, float, float, float, int)'
basically, all the imgui symbols are not being found, despite the fact that I can see them in the archive.
nm base/libbase.a | grep ImDrawList
000000000000a595 t _ZL13SetupDrawDataP8ImVectorIP10ImDrawListEP10ImDrawData
000000000000a378 t _ZL19AddWindowToDrawDataP8ImVectorIP10ImDrawListEP11ImGuiWindow
000000000000a1c2 t _ZL21AddDrawListToDrawDataP8ImVectorIP10ImDrawListES1_
0000000000000000 W _ZN10ImDrawList10PathLineToERK6ImVec2
0000000000000000 W _ZN10ImDrawList10PathStrokeEjbf
...