Can't init bgfx
I'm bgfx beginner and may I do something wrong. I tried to copy code from examples and paste it to the my mashine. By dynamic linking I get:
Program
received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
Program terminated with signal
SIGSEGV, Segmentation fault.
The program no longer exists.
Not implemented stop reason (assuming exception): exited-signalled
By static linking:
Linking...
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::begin()»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5107: неопределённая ссылка на «bx::HashCrc32::begin(bx::HashCrc32::Enum)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::write(void const*, int, bx::Error*)»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::begin()»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5107: неопределённая ссылка на «bx::HashCrc32::begin(bx::HashCrc32::Enum)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::write(void const*, int, bx::Error*)»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o):/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: далее есть ещё неопределённые ссылки на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::begin()»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5107: неопределённая ссылка на «bx::HashCrc32::begin(bx::HashCrc32::Enum)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin/libbimgRelease.a(image.o): в функции «bimg::HashWriter<bx::HashCrc32>::write(void const*, int, bx::Error*)»:
/home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
/usr/bin/ld: /home/aleksej/Programming/MyApp/bgfx/.build/projects/gmake-linux/../../../../bimg/src/image.cpp:5117: неопределённая ссылка на «bx::HashCrc32::add(void const*, int)»
collect2: ошибка: выполнение ld завершилось с кодом возврата 1
Error: linker exited with status 1
Error message in Russian means undefined reference in most cases.
In both cases the app terminates on the line:
bgfx_init_ctor(&init);
dub.json (static):
{
"authors": [
"WJ"
],
"copyright": "Copyright © 2020, ME",
"dependencies": {
"bindbc-bgfx": "~>0.5.0",
"bindbc-glfw": "~>0.10.1",
"bindbc-loader": "~>0.3.2"
},
"description": "The test app",
"lflags-linux": [
"-L/home/aleksej/Programming/MyApp/source/bgfx/bgfx/.build/linux64_gcc/bin"
],
"libs": [
"bgfxRelease",
"bxRelease",
"bimgRelease"
],
"libs-linux": [
"stdc++",
"GL",
"X11"
],
"license": "proprietary",
"name": "app",
"subConfigurations": {
"bindbc-bgfx": "static"
},
"targetPath": "./bin/$PLATFORM",
"targetType": "executable"
}
What's wrong?
Maybe it's an issue with the order of the libraries that are being linked? I haven't tried using this in any Unix systems, but try swapping the bxRelease and bimgRelease around in libs:
"libs": [
"bgfxRelease",
"bimgRelease",
"bxRelease"
],
Maybe it's an issue with the order of the libraries that are being linked? I haven't tried using this in any Unix systems, but try swapping the
bxReleaseandbimgReleasearound inlibs:"libs": [ "bgfxRelease", "bimgRelease", "bxRelease" ],
I forgot to write what I have got. Dynamic linking has worked. I remember the same case in my practice. I copied and pasted .so libs from .build folder to the lib folder (/lib) and it worked. Yep, it is a Linux feature. But statically linking as long as doesn't work. Mixing the order of libs doesn't get any success. Additionally, errors in the output say libs are loaded but something like a linker issue appears. The same issue may appear if you try to compile code and forget link headers to the linker.