包括CMake项目中的SOIL2库

问题描述 投票:0回答:2

我正在尝试在我的C ++ OpenGL项目中包括SOIL2。

到目前为止,我已经>>

  • [从https://github.com/SpartanJ/SOIL2下载库
  • 通过运行premake 4和make进行构建。
  • 将src / SOIL2 /目录复制到/ usr / local / include
  • 尝试将libsoil2-debug.a添加到/ usr / local / lib
  • 遵循各种方法在CMake中包含库的方法
  • 平台是MacOS(Catalina)我还是CMake的新手,所以我很确定这就是我的问题所在。

此刻,我的CMakeLists文件看起来像这样:

cmake_minimum_required(VERSION 3.8)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 99)
set(This ComputerGraphicsProgramming)
project(${This} CXX C)

file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE SOIL2_SOURCES /usr/local/include/SOIL2/*.c)
add_executable(${This} ${SOURCES} ${HEADERS})

include_directories(
  include
  lib
  /usr/local/include
)
link_directories(
  /usr/local/include
  /usr/local/include/SOIL2
)

find_package(OpenGL REQUIRED)
find_package(glfw3 REQUIRED)
find_package(glew REQUIRED)
find_package(glm REQUIRED)
find_library(soil2-debug REQUIRED)

target_link_libraries(${This}
  GLEW::GLEW
  ${OPENGL_LIBRARIES} glfw
  soil2-debug
)

Texture.hpp,我包含SOIL的文件,看起来像这样:

#include <GL/glew.h>
#include <SOIL2/SOIL2.h>
#include <string>

class Texture
{
  public:
    Texture(std::string filename);
    ~Texture();

  private:
    unsigned int m_ID;
};

这些是我运行make时的错误:

$ make
[  9%] Linking CXX executable ComputerGraphicsProgramming
ld: library not found for -lsoil2-debug
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [ComputerGraphicsProgramming] Error 1
make[1]: *** [CMakeFiles/ComputerGraphicsProgramming.dir/all] Error 2
make: *** [all] Error 2

任何帮助表示赞赏!

我正在尝试在我的C ++ OpenGL项目中包含SOIL2。到目前为止,我已经从https://github.com/SpartanJ/SOIL2下载了该库,它是通过运行premake 4和make构建的。复制了src / SOIL2 / ...

c++ opengl cmake soil
2个回答
0
投票

似乎找不到libsoil2-debug.a。尝试将/ usr / local / lib添加到CMAKE_PREFIX_PATH


0
投票

最后使用以下CMakeLists文件构建了项目。感谢您的答复!

© www.soinside.com 2019 - 2024. All rights reserved.