I'm trying to include SOIL2 in my C++ OpenGL project.
So far I've
- downloaded the library from https://github.com/SpartanJ/SOIL2
- built it by running premake 4 and make.
- copied the src/SOIL2/ directory to /usr/local/include
- tried adding libsoil2-debug.a to /usr/local/lib
- followed various examples of ways to include libraries with CMake
Platform is MacOS (Catalina) I'm still new to CMake, so I'm pretty sure that's where my problem is.
At the moment, my CMakeLists file looks like this:
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, the file where I'm including SOIL, looks like this:
#include <GL/glew.h>
#include <SOIL2/SOIL2.h>
#include <string>
class Texture
{
public:
Texture(std::string filename);
~Texture();
private:
unsigned int m_ID;
};
And these are my errors when I run 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
Any help appreciated!