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:
Related
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.
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.
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.
I have been programming a game in c++ using the sfml library. However, I would like to adjust some of the code of that library, and use that altered code in my project.
So instead of linking the dll I would like to add the source code and then play with that source code. (e.g. for speed optimization).
I know that doing something like that is generally speaking a bad idea. Howeover, I want to learn by playing around a bit and trying different things.
So how would I add the sfml source code to my c++ project in MS visual studio. Note that I am a total noob. I already tried adding the sfml folder that I downloaded from git in the project properties page called "Additional Include Directories", but i am getting errors, of the form "Cannot open include file: 'SFML/Graphics/GLCheck.hpp': No such file or directory" so I guess that i have not yet done enough.
If you want to modify the source code in the library, all you'd have to do is just navigate to where you have SFML installed and go into the code files with a text editor and edit them.
Then, you could link the library to your VS project the same way you would normally but that library is now modified by you.
Seeing as you have a search directory issue already in VS, you must fix that first. Fix that and then go and modify the library's .hpp, .h, .cpp, whatever files in-place.
To fix the search issue.... I don't use VS for graphics, I use CodeBlocks so I am not sure about their GUI to link libraries and change search directories... but, find out where you installed SFML. Check your /usr/include/, it's probably there. Specify that path in the search directories. Just go and find where that GLCheck.hpp file is located. For Example: Say it's full path is /usr/include/SFML/Graphics/GLCheck.hpp... then /usr/include/SFML/Graphics/ or just /usr/include/ (VS might handle it recursively) needs to be in the list of SEARCH DIRECTORIES.
I'm a bit stuck trying to get box2D to compile and I think it's because I don't quite understand how Xcode handles its build directories.
Box2D is folder containing a set of header and source files (in various subdirectories, etc). I've added the Box2D folder to a coco touch static library project in Xcode and when I try to compile I get errors about header files not being found such as <Box2D/Common/b2BlockAllocator.h>.
I found that if I simply include the header with #include "b2BlockAllocator.h" it compiles fine and Xcode actually finds the file.
So I'm a bit stuck here, I'm assuming I need to find a way to get all includes to begin searching from the root project directory and not from the source files location but I'm not sure how I can do that in Xcode...
Any ideas?
<Box2D/Common/b2BlockAllocator.h> should be found in a directory called Box2D/Common. You said that Box2D contains a set of header and source files. Are some of these headers in a subdirectory of Box2D called Common, or are they all directly under Box2D? If it's the latter, then that's your problem.
OK I figured it out!
In the targets settings page look for 'header search paths' and add the root build directory of your project to it.