1 year ago
#103435
anuj
C++ bgfx file wont compile in fedora 35
I am trying to make a purple window with glfw and bgfx as just a starting point for my game engine but the file wont compile.
I am using the g++ compiler for it. I just learning bgfx since yesterday and don't know what to do. The compiler statement is:
g++ app.cpp -o src/app -lglfw3 -lGL -lX11 -lGLU
and my code is
#include <bgfx_engine/containers/include/bgfx/bgfx.h>
#include <bgfx_engine/containers/include/bgfx/platform.h>
#include <GLFW/glfw3.h>
#define GLFW_EXPOSE_NATIVE_X11
#include <GLFW/glfw3native.h>
#define WNDW_WIDTH 1600
#define WNDW_HEIGHT 900
int main(void)
{
bgfx::init();
glfwInit();
GLFWwindow* window = glfwCreateWindow(WNDW_WIDTH, WNDW_HEIGHT, "Hello, bgfx!",NULL ,NULL)
bgfx::PlatformData pd;
pd.ndt = glfwGetX11Display();
pd.nwh = (void*)glfwGetX11Window(window);
bgfx::Init bgfxInit;
bgfxInit.type = bgfx::RendererType::Count ;//auto choose a renderer
bgfxInit.resolution.width = WNDW_WIDTH;
bgfxInit.resolution.height = WNDW_HEIGHT;
bgfxInit.resolution.reset = BGFX_RESET_VSYNC;
bgfx::init(bgfxInit);
bgfx::setViewClear(0,BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH,0x443355FF,1.0f,0);
bgfx::setViewRect(0, 0, 0, WNDW_WIDTH, WNDW_HEIGHT);
unsigned int counter = 0;
while (true)
{
bgfx::frame();
counter++;
}
return 0;
}
and it shows the error:
/usr/bin/ld: /tmp/ccQWzYSO.o: in function `main':
app.cpp:(.text+0x16): undefined reference to `bgfx::Init::Init()'
/usr/bin/ld: app.cpp:(.text+0x25): undefined reference to `bgfx::init(bgfx::Init const&)'
/usr/bin/ld: app.cpp:(.text+0x5c): undefined reference to `bgfx::PlatformData::PlatformData()'
/usr/bin/ld: app.cpp:(.text+0x8a): undefined reference to `bgfx::Init::Init()'
/usr/bin/ld: app.cpp:(.text+0xc1): undefined reference to `bgfx::init(bgfx::Init const&)'
/usr/bin/ld: app.cpp:(.text+0xe4): undefined reference to `bgfx::setViewClear(unsigned short, unsigned short, unsigned int, float, unsigned char)'
/usr/bin/ld: app.cpp:(.text+0x103): undefined reference to `bgfx::setViewRect(unsigned short, unsigned short, unsigned short, unsigned short, unsigned short)'
/usr/bin/ld: app.cpp:(.text+0x114): undefined reference to `bgfx::frame(bool)'
collect2: error: ld returned 1 exit status
thank you
c++
linux
compilation
bgfx
0 Answers
Your Answer