GoaLitiuM / bindbc-bgfx

Dynamic and static D bindings for bgfx
Boost Software License 1.0
21 stars 1 forks source link

Can't get sample code in readme.md to work #4

Closed dsobiera closed 4 years ago

dsobiera commented 4 years ago

I am new to bgfx and am trying the D bindings for it. I am just trying to get the sample app given in the readme.md for the bindings to run to verify a good install. I am running bgfx on Ubuntu Linux.

I am using the instructions from https://github.com/GoaLitiuM/bindbc-bgfx/blob/master/readme.md

I added the subconfigurations in my dub.json because I am trying to do static linking

"subConfigurations": { "bindbc-bgfx": "static" }

"libs": { "bgfxRelease", "bxRelease", "bimgRelease" }

I added the lflag so it could find the .a files :

"lflags": [
    "-L/home/user1/src/d/helloBgfx/bgfx/bgfx/.build/linux64_gcc/bin"
],

and the source code (as supplied by the readme):


import bindbc.bgfx;

// commented out because trying to do static link // loadBgfx(); // required with dynamically linked bgfx

bgfx_init_t init; bgfx_init_ctor(&init);

bgfx_init(&init); bgfx_reset(1280, 720, BGFX_RESET_NONE, init.resolution.format);

bgfx_shutdown();

// commented out because trying to do static link // unloadBgfx(); // optional, only with dynamically linked bgfx


When I try to do a dub, I get (on linking)...

Performing "debug" build using dmd for x86_64. bindbc-bgfx 0.4.0+108: target for configuration "static" is up to date. bindbc-loader 0.3.1: target for configuration "noBC" is up to date. hellobgfx ~master: building configuration "application"... Linking... /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/linux64_gcc/bin/libbgfxRelease.a(renderer_vk.o): in function bgfx::vk::RendererContextVK::submit(bgfx::Frame*, bgfx::ClearQuad&, bgfx::TextVideoMemBlitter&)': /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:5914: undefined reference tocxa_guard_acquire' /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:5914: undefined reference to __cxa_guard_release' /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6609: undefined reference tocxa_guard_acquire' /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6609: undefined reference to __cxa_guard_release' /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6608: undefined reference tocxa_guard_acquire' /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6608: undefined reference to __cxa_guard_release' /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6658: undefined reference tocxa_guard_acquire' /usr/bin/ld: /home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../src/renderer_vk.cpp:6658: undefined reference to `__cxa_guard_release'

and loads and loads of undefineds

Any idea what might be going wrong?

dsobiera commented 4 years ago

I got past those references (and some others) by having my lflags as:


"lflags": [
    "-L/home/dsobiera/src/d/helloBgfx/bgfx/bgfx/.build/linux64_gcc/bin",
    "-lstdc++",
    "-lGL",
    "-lX11"
],

Now I am getting:

/home/user1/src/d/helloBgfx/bgfx/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: undefined reference to `bx::HashCrc32::add(void const*, int)'

as my last reference to try to fix

dsobiera commented 4 years ago

I got the linking to work

Here is my relevant pieces of my dub.json:


"lflags": [
    "-L/home/user1/src/d/helloBgfx/bgfx/bgfx/.build/linux64_gcc/bin"
],
"subConfigurations": {
    "bindbc-bgfx": "static"
},
"libs": [
    "bgfxRelease",
    "bxRelease",
    "bimgRelease",
    "stdc++",
    "GL",
    "X11"
],

Closing the issue as user error fixed but documented for anyone else in this situation.

GoaLitiuM commented 4 years ago

Thank you, I've updated the readme with additional libraries to be linked against when using static libraries.