我试图交叉编译一个OpenGLES2.0示例HelloTriangle,使用VisualGDB对运行Raspbian lite的RaspberryPi 3进行编译。
我想我可以在libbrcmEGL.so文件中正确地包含库libbrcmGLESv2.soCMakeLists.txt
因为不是给我这些错误:

c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -lLIBGLES
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -lLIBEGL`

它给了我这些错误
make[2]: *** No rule to make target `libbrcmEGL.so', needed by `HelloTriangle'.  Stop.`

这是我的CMakeLists文件:
cmake_minimum_required(VERSION 2.7)
project(HelloTriangle)
set(LIBRARIES_FROM_REFERENCES "")
add_executable(HelloTriangle HelloTriangle.cpp esShapes.c esTransform.c esUtil.c esShader.c)
include_directories(include)
target_link_libraries(HelloTriangle ${CMAKE_BINARY_DIR}/libbrcmGLESv2.so ${CMAKE_BINARY_DIR}/libbrcmEGL.so "${LIBRARIES_FROM_REFERENCES}")

我不明白它还需要什么才能成为目标。查看堆栈溢出,我看到了要添加的建议
LINK_DIRECTORIES(/opt/vc/lib/)

我也试过了
target_link_libraries(HelloTriangle /opt/vc/lib/libbrcmGLESv2.so /opt/vc/lib/libbrcmEGL.so "${LIBRARIES_FROM_REFERENCES}")

我还检查了sysroot中的以下库:
C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot

我还是犯了同样的错误:
我需要一些帮助来找出我的CMakeLists.txt中缺少什么

最佳答案

更改为target_link_libraries(HelloTriangle ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbrcmGLESv2.so ${CMAKE_CURRENT_SOURCE_DIR}/lib/libbrcmEGL.so "${LIBRARIES_FROM_REFERENCES}")并编译

10-07 22:47