Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add stb to cmake build #32

Closed
kirhgoff opened this issue Jan 26, 2017 · 3 comments
Closed

Cannot add stb to cmake build #32

kirhgoff opened this issue Jan 26, 2017 · 3 comments

Comments

@kirhgoff
Copy link

Hello,

Thank you for your great project, started with it following OpenGL tutorial and it was very easy to jump to the coding. But I stumbled on textures part and would appreciate a help here. Glitter README.md does not contain any instructions how to add stb library to the build and I believe setting up a build is the most complicated part in C++ development.

What I did:

  1. Used stbi_load function to load image file in main .cpp (included stb header)
  2. CMakeLists.txt - added Glitter/Vendor/stb to inclide_directories
  3. CMakeLists.txt - added stb to target_link_libraries

Getting an error:

CMake Error at CMakeLists.txt:21 (add_subdirectory): The source directory /Users/klastovirya/Projects/opengl-sandbox/Glitter/Vendor/stb does not contain a CMakeLists.txt file.

And this is true - there are just headers and c file.

I tried another approach - I removed target link, added stb folder/*.c to vendor sources, still an error, now builder cannot find symbols for stb functions.

Would be very grateful for any advice. Cmake file is here https://github.com/kirhgoff/opengl-sandbox/blob/master/CMakeLists.txt

@kirhgoff
Copy link
Author

Seems that I managed to do that:

  1. added stb/*.h as vendor source
  2. added #define STB_IMAGE_IMPLEMENTATION to main.cpp

@Polytonic
Copy link
Owner

Hi there! You may find these four lines to be of help. 😄

You shouldn't need to modify the CMakeLists.txt file to use STB. It should just work out of the box as configured here ...

@kirhgoff
Copy link
Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants