I can't access GLM - c++

I downloaded GLM from the site. First of all, I can't unzip the file, as it didn't come in .zip format. I used a zip unarchiver and it still did not produce an unzipped file. Regardless, I tried including a header search path but Xcode has this weird Debug/Release path. Don't know which to access, but I tried putting the path to the glm files on both Debug and Release. Still did not let me use glm files. Lastly, I tried putting the glm files directly into the project files, and it still did not let me use the files in glm.
I looked at other posts on stack for the same problem, and they all said to include it into the header search path, but their format is different from mine. Idk, just need some really clear directions on this as everything is out of order.

Related

Assets path with SDL2 library

I'm trying to load image with IMG_Load() function from SDL.
I saw from tutorials that they doesn't need full path for asset files.
But when I try to do that, it doesn't work.
My solution is include full path of those files, but I found that is clunky. Especially when I try to collaborate with my friend, it's hard to synchronize source files since we use different file paths.
May I ask what is typical way to collaborate between programmers when they have different setup, different file paths? I think that I need to simplify the file path for asset.
I tried to add include directories for compiler, but it only work with header files, not for asset files.
Relative paths are relative to the current working directory. On Windows, when starting a program from the exporer with a double-click, it matches the location of the .exe, but this isn't always the case, e.g. when running from some IDEs.
Use SDL_GetBasePath() to get the directory where the .exe is located. Prepend it to your asset paths.

Xcode can't find or include SDL2

I have recently downloaded SDL2 and am trying to install it. I created a small test program consisting of a .cpp and a .h file.
I have put SDL2.frameworks inside of /Library/Frameworks and then made sure that it was added to General->Frameworks and Libraries and tried to #include <SDL2/SDL.h>. file not found.
I made sure to go to the build settings->Search Paths->Framework Search Paths to add /Library/Frameworks (it was already listed next to the setting but I readded it to the dropdown). I also added /Library/Frameworks/SDL2.framework to the Header Search Paths. file not found.
I tried to include <SDL2/SDL.h>, <SDL/SDL.h>, <SDL.h>, "SDL2/SDL.h", "SDL/SDL.h" and "SDL.h". none of these files were found.
For the header search path, it should be set to FRAMEWORK_DIRCTORY/SDL2.framework/Headers/, or you can use FRAMEWORK_DIRCTORY/SDL2.framework and turn on recursive search.
Then you should be able to use it with just #include <SDL.h>.
Edit:
After some investigation, seems like my original answer was more of a workaround. The proper way of including SDL library in your code should be using just #include <SDL2/SDL.h>, however it wasn't working.
The reason of that is when compiling the code, Xcode would attempt to copy the library to the product folder, so the compiled executable can have easy access to it. However, for some reason, Xcode copied the framework without the header folder (the reason is probably that Xcode is moving towards using Swift only, which doesn't really have a "header" thing).
By default, when you try to run the code, and it sees there is a SDL2.framework folder located in the product folder, it would use that framework, even if it doesn't have the header folder located in it. But since it doesn't actually have the header folder in it, it doesn't actually run.
To solve it, the easiest way is to remove it from the Targets/Build Phases/Embed Frameworks.
By default when you add a framework to your project, it would also be added here. By removing it from the Embed Frameworks, it won't copy the framework to product folder. And it will only attempt to search SDL framework from whatever you have put in the Build Settings/Framework Search Path.
In the same time, you won't need to have anything for Build Settings/Header Search Path, as it will look for Headers folders in your frameworks first.
And with you code, you can just use #include <SDL2/SDL.h>.
Even better, you can add the framework to Build Phases/Copy Files, and set the Destination to Frameworks, empty the Subpath, and potentially uncheck Copy only when installing, for better cross device usabilities.

C++ zlibstatic library in VS2019

I'm in the process of learning C++ and I'm halfway through one of my courses so I figured I would try to do something to challenge myself and I'm getting stuck on what I'm trying to do. Long story short I'm trying to parse some info from a file inside of a zip folder.
I followed this post here to understand what to do but I'm missing something that is not quite ovvious to me: How to use zlib library in visual studio 2017?
I'm using VS2019
I researched the libzip and zlib libraries online and realized that I need to get the zlibstatic.lib into my project. I've read through the above posts and I thought I set my paths and folders correctly, but I'm getting an error not being able to source the file.
enter image description here
enter image description here
Thanks for any advice in advance! I hope everyone is staying safe!
Cheers!
MattG
Well you can see that there is no file called zlib.h in the directory you specified. I don't know zlib but usually the header files are in a searate directory. Often it's called include something or other.
Bottom line, in the 'Additional Include Directories' setting you need to specify the folder containing zlib.h, not zlibstatic.lib.
I'm guessing you will also need to add zlibstatic.lib to the Linker/Input/Additional Dependencies setting. It's not enough just to specify the directory where the library is, you have to name it as well.

How do you create a proper 'include' directory?

So, we have all seen (some of you guys might have even made) professional libraries which have proper include directories which contain all the header files you need to use the library. An example would be the OpenCV library include folder which I have attached.
When we release libraries, what we do is just zip the headers for the lib and ask the recipient to extract them to somewhere convenient, which is, to be honest, quite fine. However, I would like to make an 'include' directory with all relevant headers if possible because I feel that my distribution can be organized better that way. How can we go about doing that?
You can just create a folder for all neccessary headers and specify path considering that folder when include them in code.
You can also specify that folder in preferences of your project, for example Visual Studio or Eclipse allow it, so you shouldn't write full path for those includes.

Attempting to include a Library in Xcode, file not found

I'm trying to create a program that uses a lot of linear algebra and OpenGL, and a colleague of mine recommended that I use the Eigen library to make things a lot simpler. After downloading and extracting the library off of Eigen's official website and I clicked on the project, found the "Link Binary with Libraries" option, went into to the folder that resulted from the unarchiving (eigen-eigen-bdd17ee3b1b3), and then found the Eigen folder. This folder contains all of the header files.
The library showed up on the sidebar, and when I go into the correct sub-folder the header files were all there too. According to the Eigen website, you only need the header files for the includes to work, but no matter how I set up the filepath in the include statement, even if what I can physically see what I'm including on the sidebar, XCode tells me it can't find the file. I'm using an older version of XCode 4. Any advice?
Sounds like you are missing header search paths: