So, I've got a c++ project where i want to visualize stuff (in realtime), so i was looking for a rendering engine, and found bgfx.
I don't write often c++ stuff, and using thirdparty projects seems unbelievable laborious, but maybe i just do everything wrong and hopefully you can push me into the right direction.
My first try was on linux, i cloned bgfx.cmake and followed the readme, then i
used make install
which installed the librarys to "/usr/local/include".
this seemed to work at first, because my IDE (CLion) recognized bgfx when using #import
.
Then i tried to make the HelloWorld example work. i ended up with copying the bgfx examples folder into my project under a subfolder "thirdparty", because all the examples make highly use of the "examples/common" folder.
and i think i made something wrong with my CMakeLists.txt because while my IDE can resolve and autocomplete everything i get a compiler error when I try to run the project:
Unresolved references 'entry::runApp(entry::AppI*, int, char**)'
on the line ENTRY_IMPLEMENT_MAIN(ExampleClass)
where ENTRY_IMPLEMENT_MAIN is a bgfx defined macro (here).
after a few annoying hours i decided to start from scratch:
i made a project "bgfx_test" with subfolder "thirdparty" in the thirdparty folder i cloned the bgfx.cmake project, and added add_subdirectory("thirdparty/bgfx.cmake")
into my CMakeLists.txt
i again made a main.cpp where i added the ExampleHelloWorld class from the bgfx examples.
i changed it to have a empty update() method, so i did not need the logo.h and screeshot.png file from the example. and i changed the includes to:
#include "thirdparty/bgfx.cmake/bgfx/examples/common/common.h"
#include "thirdparty/bgfx.cmake/bgfx/examples/common/bgfx_utils.h"
the same error again, my IDE autocompletes everything but the compiler says:
Nicht definierter Verweis auf 'entry::runApp(entry::AppI*, int, char**)'
(unresolved reference)
if someone could help me with this, that would be awesome
my folder structure:
project-root
main.cpp
CMakeLists.txt
thirdparty
bgfx.cmake (clone of the repo mentioned above)
my CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
project(bgfx_test)
set(CMAKE_CXX_STANDARD 14)
set(SOURCE_FILES main.cpp)
add_executable(bgfx_test ${SOURCE_FILES})
add_subdirectory("thirdparty/bgfx.cmake")
after that i tried to set it up with fips which worked after i added a few symlinks to the dependencies
(stuff like linking libXinerama.so
to libXinerama.so.1
because fips could not find it with the '.1' at the end)
so now i can run the examples and even setting up the project on windows worked - at least for the examples.
but i'd really like to not write my application in the "bgfx/exampels" folder
but i cant get it to work outside of it, even when setting up this way
edit
since it seemed not to be clear enough:
My questions:
it would be wonderful to see a CMakeLists.txt for a tiny example, or just tell me whats wrong with mine
edit 2 (27.05.2017):
after i added
target_link_libraries(bgfx_test bx)
target_link_libraries(bgfx_test bgfx)
target_link_libraries(bgfx_test bimg)
to my CMakeLists.txt i get the next error:
/usr/bin/ld: thirdparty/bgfx.cmake/libbgfxd.a(glcontext_glx.cpp.o): undefined reference to symbol 'XFree'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
where the only useful hit google produces is this but it is unanswered :/
it worked with this CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
project(bgfx_test)
set(CMAKE_CXX_STANDARD 14)
set(SOURCE_FILES main.cpp)
add_subdirectory("thirdparty/bgfx.cmake")
add_executable(bgfx_test ${SOURCE_FILES} )
target_link_libraries(bgfx_test bgfx example-common)