所以,我有一个c ++项目,我希望可视化(实时),所以我正在寻找一个渲染引擎,并找到了bgfx。
我不经常写c ++的东西,使用第三方项目似乎难以置信,但也许我只是做错了什么,希望你能把我推向正确的方向。
我的第一次尝试是在linux上,我克隆了bgfx.cmake并按照自述文件,然后我使用make install
将库安装到“/ usr / local / include”。
这似乎最初起作用,因为我的IDE(CLion)在使用#import
时识别出bgfx。
然后我试着让HelloWorld示例工作。我最终将bgfx examples文件夹复制到我的项目的子文件夹“thirdparty”下,因为所有示例都高度使用了“examples / common”文件夹。
我认为我的CMakeLists.txt出了问题,因为当我尝试运行项目时,我的IDE可以解析并自动完成所有内容时出现编译错误:
Unresolved references 'entry::runApp(entry::AppI*, int, char**)'
在线ENTRY_IMPLEMENT_MAIN(ExampleClass)
,其中ENTRY_IMPLEMENT_MAIN是bgfx定义的宏(here)。
经过几个烦人的时间后,我决定从头开始:
我在第三方文件夹中创建了一个带有子文件“thirdparty”的项目“bgfx_test”,我克隆了bgfx.cmake项目,并将add_subdirectory("thirdparty/bgfx.cmake")
添加到我的CMakeLists.txt中
我再次创建了一个main.cpp,我从bgfx示例中添加了ExampleHelloWorld类。
我把它改成了一个空的update()方法,所以我不需要示例中的logo.h和screeshot.png文件。我把包括改为:
#include "thirdparty/bgfx.cmake/bgfx/examples/common/common.h"
#include "thirdparty/bgfx.cmake/bgfx/examples/common/bgfx_utils.h"
同样的错误,我的IDE自动完成所有内容,但编译器说:
Nicht definierter Verweis auf 'entry::runApp(entry::AppI*, int, char**)'
(未解决的参考)
如果有人可以帮助我,那将是非常棒的
我的文件夹结构:
project-root
main.cpp
CMakeLists.txt
thirdparty
bgfx.cmake (clone of the repo mentioned above)
我的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")
之后,我试图用fips设置它,在我添加了几个符号链接到依赖项后工作
(比如将libXinerama.so
链接到libXinerama.so.1
,因为fips在末尾无法找到'.1')
所以现在我可以运行这些示例甚至在Windows上设置项目 - 至少对于示例而言。
但我真的不想在“bgfx / exampels”文件夹中写我的应用程序
但即使以这种方式设置,我也无法让它在它之外工作
编辑
因为它似乎不够清楚:
我的问题:
看一个CMakeLists.txt就是一个很小的例子,或者只是告诉我我的错误
编辑2(27.05.2017):
我加了之后
target_link_libraries(bgfx_test bx)
target_link_libraries(bgfx_test bgfx)
target_link_libraries(bgfx_test bimg)
到我的CMakeLists.txt我得到下一个错误:
/ usr / bin / ld:thirdparty / bgfx.cmake / libbgfxd.a(glcontext_glx.cpp.o):对符号'XFree'的未定义引用
//usr/lib/x86_64-linux-gnu/libX11.so.6:添加符号时出错:命令行中缺少DSO
谷歌产生的唯一有用的命中是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)