0

I'm using openGL with CLion on OSX and am trying to add textures to some objects.

I believe my CMake list is correct however when creating a texture using

myTexture = SOIL_load_OGL_texture(
            "gfx/crate.png",
            SOIL_LOAD_AUTO,
            SOIL_CREATE_NEW_ID,
            SOIL_FLAG_MIPMAPS | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
    );

I am getting the following errors:

Undefined symbols for architecture x86_64:
"_SOIL_load_OGL_texture", referenced from:
Scene::Scene(Input*) in Scene.cpp.o
ld: symbol(s) not found for architecture x86_64

I've been searching online because I was under the impression it was my CMake list that was set up incorrectly (its my first project using CMake so i'm quiet new to it).

I've tried moving the crate.png file around in the directory as I wasn't sure if it was in the correct place.

The path for it is: CLionProjects/GraphicsProgramming/gfx/crate.png

This is what my CMake list looks like:

cmake_minimum_required(VERSION 3.8)
project(GraphicsProgramming5)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.8")

INCLUDE_DIRECTORIES (/System/Library/Frameworks ${SOIL_INCLUDE_DIRS})

find_library(SOIL_LIBRARY SOIL.lib)
FIND_LIBRARY(GLUT_LIBRARY GLUT)
FIND_LIBRARY(OpenGL_LIBRARY OpenGL)

MARK_AS_ADVANCED (
GLUT_LIBRARY'
            OpenGL_LIBRARY)

SET(EXTRA_LIBS ${GLUT_LIBRARY} ${OpenGL_LIBRARY} ${SOIL_LIBRARY})

set(SOURCE_FILES main.cpp Input.cpp Input.h Scene.cpp Scene.h Vector3.cpp Vector3.h)

add_executable(GraphicsProgramming5 ${SOURCE_FILES})
target_link_libraries(GraphicsProgramming5 ${GLUT_LIBRARY} ${OpenGL_LIBRARY} ${CMAKE_SOURCE_DIR}/libSOIL.a)

I'd like to know where i'm going wrong.

As always, any help appreciated.

Updated the code in the CMake list and now receiving this error:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
SOIL_LIBRARY
    linked by target "GraphicsProgramming_Lab3" in directory /Users/me/CLionProjects/GraphicsProgramming_Lab5
L.K
  • 33
  • 6
  • `find_library(SOIL.lib REQUIRED)` has no sence: there is no *REQUIRED* option for `find_library` command, so it searches a library with name "REQUIRED" and store path to it to variable named `SOIL.lib`. If you want to find `SOIL.lib` library file and store path to it in `SOIL_LIB` variable, use `find_library(SOIL_LIB SOIL.lib)`. See [documentation](https://cmake.org/cmake/help/v3.9/command/find_library.html) for `find_library` command. – Tsyvarev Oct 05 '17 at 18:10
  • I've changed this however it's still giving me the same error. Anything else you can see that I've did wrong in the CMake file? – L.K Oct 05 '17 at 18:50
  • Hmm, actually you may use `find_library(SOIL_LIBRARY SOIL.lib)`, as you use `${SOIL_LIBRARY}` for link with the library. If this doesn't work, [edit] your question with updated code. – Tsyvarev Oct 05 '17 at 20:45
  • Added the new error message at the bottom of the main post (this is now an error in the CMake list). – L.K Oct 05 '17 at 22:10
  • Well, now the error means that CMake hasn't found "SOIL.lib" library. Check that such file exists, and hint CMake about its location. – Tsyvarev Oct 05 '17 at 22:25
  • How exactly do I go about hinting where it is? The file does exist inside the project directory, in the same space as all the .h and .cpp files are. In CLion under the 'project' window it lists all the files inside and it does have SOIL.h and SOIL.lib there however they are slightly greyed out. This is its path: `/Users/me/CLionProjects/GraphicsProgramming5` – L.K Oct 05 '17 at 23:08
  • Why do you use `find_library` if you already know the library's location? Just use full library path for linking: `${CMAKE_SOURCE_DIR}/SOIL.lib`. – Tsyvarev Oct 06 '17 at 07:29
  • It's now giving the this error: `warning: ignoring file ../SOIL.lib, file was built for archive which is not the architecture being linked (x86_64): ../SOIL.lib`. However the CMake debug seems happy with it. The above error is when I try to run the program. – L.K Oct 06 '17 at 11:18
  • Wait, you're on OSX? While the file extensions are merely a convention, the convention on OSX would be `.a` for a static library and `.so`/`.dylib` for a shared library. `.lib` would be the common convention for Windows. Are you sure you're linking against the OSX library? – legalize Oct 09 '17 at 16:44
  • ok so i've been using the .lib from my class example (we use windows in labs). I've downloaded the soil.a from soils website - the file is libSOIL.a (im assuming this is the right one?). I'll update the CMake code in my original post as it's still not compiling. – L.K Oct 15 '17 at 17:19
  • I should also note that i'm getting the following error in my compiler: make[3]: *** No rule to make target `/Users/Me/CLionProjects/GraphicsProgramming5}/libSOIL.a', needed by `GraphicsProgramming5'. Stop. make[2]: *** [CMakeFiles/GraphicsProgramming5.dir/all] Error 2 make[1]: *** [CMakeFiles/GraphicsProgramming5.dir/rule] Error 2 make: *** [GraphicsProgramming5] Error 2 – L.K Oct 15 '17 at 22:54

0 Answers0