Troubles switching from VC++ Directories to User Macros for Boost - c++

Good day,
I have previously successfully used boost in Visual Studio 2010 by using Include and Library Directory paths under VC++ Directories in project settings. However not long ago I have been forced to switch to using "User Macros" to do the linking due to a new lecturer where I study.
I had no issues moving my other libraries to using User Macros, I simply used the same include and library path when creating the macros. Boost however is not playing so nice. While having the boost folder linked under VC++ Directories it worked as it should, but when I try moving the include and library paths to User Macros, Visual Studio refuses to recognize the path and I'm getting the following normal error:
error C1083: Cannot open include file: 'boost/filesystem.hpp': No such file or directory
When I move back to using VC++ Directories it works again.
Is there any simple explanation why boost doesn't want to be linked with macros, while all my other libs are totally fine with it? The other libraries include DevIL, SDL, glew, glm and assimp as of now.

I seem to have found the solution. I had to add my boost macro names under "Project settings - C/C++ - Additional Include Directories" and "project settings - linker - Additional Library Directories".
Somehow the other macros I have made have appeared in those two lists automatically, and I'm not sure why the boost macros were not added automatically too. Now it's working as it should though, so I'll just go with it like this.

Related

How can I install and use C++ libraries on eclipse?

I want to use libosmium library. Could someone please tell me how do I set up this library after I download it?
All I need to know is the standard way of installing external libraries. I can't really find very clear instructions online.
I'm coding with C++ using the eclipse IDE version 4.18.0.
For includes: right click on your project and go to Properties>>C/C++ Build>>Settings>>GCC C++ Compiler >> Includes
you must add the include path for the external library (where the header reside). This information is needed by the Eclipse indexer (code completion etc.) and the compiler
For libraries: right click on your project and go to Properties>>C/C++ Build>>Settings>>GCC C++ Linker >> Libraries you must add the library search path (option -L) and the library you want to link against (option -l). This info is needed for the linker.
Source: http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_add_an_external_library_to_my_C.2B.2B_project.3F
Eclipse-CDT Setting Pictures
Include path settings:
Library & library search path settings
You can also use pkg-config plug in
https://marketplace.eclipse.org/content/pkg-config-support-eclipse-cdt
Here is a link to a similar question with answers: Problems importing libraries to my c++ project, how to fix this?
As specified in the other answer, you can usually add a library by looking at the project properties:
Properties>>C/C++ Build>>Settings>>GCC C++ Compiler>>Includes
However if you're using a makefile project, the Makefile itself must know about the location of libraries. In this case, in order to avoid an "Unresolved inclusion" warning in the header, you may also want to tell eclipse where the header files are. This way the autocomplete & "Open Declaration" will work. This is found in:
Properties>>C++ General>>Preprocessor Includes Paths, Macros etc.
In my case I couldn't figure out how to add a custom configuration and updated the default configuration. I added a path for the Android NDK under the GNU C++ -> CTD User Setting Entries

How to include SFML source code into my visual studio 2017 c++ project and compile

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.

VS 2015 VC++ Static Library Include Path Broken

I'm having a bit of a problem combining a static library into another static library in my VC++ VS 2015 solution. I'm able to get the library itself to build and go through the Librarian just fine, but when I try adding the include path I am unable to use #include <MyFile.hpp>, it simply fails with a 'File not found' error.
I have confirmed the include path is valid and tried it in the following different formats:
$(SolutionDir)lib\include
..\lib\include
\\?\$(SolutionDir)lib\include (not sure if this still helps with anything)
I've also tried adding these include paths to the Include Directories values inside the project's VC++ Directories properties, as well as the Additional Include Directories values inside the project's C/C++ properties. Furthermore, the library has been added as a project reference.
What's interesting to me is that I am including a DLL in exactly the same fashion, and I do not have this problem with that specific library. The only difference between the two is that one is a DLL and the other a LIB, and obviously there is a different path between the two (though they are both in the same $(SolutionDir)lib base path).
I have worked around the issue by changing my include directive to be #include "../../lib/include/MyFile.hpp", which has caused the build to work perfectly fine with no other changes. Still, I'm pretty stumped as to why this LIB wouldn't behave the same way as the DLL project for the include directories.

How do I include Boost libraries?

I'm trying to incorporate the Boost libraries into my program, specifically lexical_cast and geometry. I include them using #include"boost/boost/geometry.hpp" and #include"boost/boost/lexical_cast/lexical_cast_old.hpp".
When I run the code I get the fatal error "Cannot open include file: 'boost/geometry/geometry.hpp': No such file or directory" which leads me to another .hpp file in the Boost library which includes another library, but uses #include<...> instead of #include"...".
When I replace it for "..." the error for this one goes, but it is replaced with the next library included using #include<...> instead of #include"...".
I feel like this could lead me down a rabbit hole of replacing nearly all instances of #include<...> with #include"..." which would take ages. Is there a setting I can change or a piece of code I could include that would sort this out?
Or could I just get rid of all the other unnecessary libraries and change the ones I need (I know that, that would still be a lot as they seem to rely on each other).
I have Boost library version 1.58.0.
First you should read about the difference between #include "filepath" and #include <filepath> here.
Personally, I'm working with Boost from Visual Studio as follows:
Go to Project properties → C/C++ → General → Additional Include Directories, and add a path to the boost library root (in my case C:\Program Files (x86)\Boost_1_53).
Include a .hpp file in your sources, like #include <boost/lexical_cast/lexical_cast_old.hpp>
If you're using non headers-only libraries you should also add path to Boost libraries in Project properties → Linker → General → Additional Libraries Directories.
In Visual Studio 2012, right-click on your project and select "Properties".
In the properties dialog, select "Configuration Properties" and then "VC++ Directories".
You will need to add the Boost include path to the "Include Directories" list.
If you're using all header-only libraries then you're done. Otherwise, you will need to add the Boost library path to "Library Directories".
For example:
Boost library - c:\boost\boost_1_58_0 (run booststrap.bat and b2 as administrator).
Add strings $(THIRD_PARTY)\boost\boost_1_58_0\include and $(THIRD_PARTY)\boost\boost_1_58_0\ to VC++ Directories → Include Directories

cannot open file 'SDL2.lib'

I am trying to open sdl2 in my project on Visual C++ 2012 but i keep getting this error:
error LNK1104: cannot open file 'SDL2.lib'
I added the additional libraries and include folder but no luck..
I added the link to the libraries through the linker but i get the same error..
what should i do?
I'm referencing VS 2010, but I've read before that some people have had errors when using the VC++ Directories in their project properties as opposed to the Linker->General->Additional Library Directories.
Unfortunately, there really isn't much more to do besides making sure the directories are linked properly. There really is only one answer to this question. It also may depend on the download of SDL you chose, are you donwloading the Development Library as opposed to the binary?
Watch this video https://www.youtube.com/watch?v=or1dAmUO8k0.
In summary, you want to add the path include folder here: (configuration properties> C/C++ > General> Additional Include Directories),
and add the path of the lib folder here: (configuration properties> Linker > General> Additional Library Directories)
and finally, link .lib file in: linker > input > Additional Dependencies.
It seems like you didn't add your library directory path in VC++ Directories/Library Directories.. You have to link your library directory path (Where you have save you libraries of SDL) in your program. After adding, it will definitely work
I would like to add for others experiencing this problem that its an easy mistake if you are using the Development Library to link to the lib folder. SDL needs you link to either the x86 or x64 folder in the lib folder.
If you run or compile your program before you make those required changes of SDL then you will get this error always.. so first add a c++ file then make those changes and then write something and try to run ..this time it will never give this error
It seems like VS can't find the lib files. There are two ways you can do this. One is to configure the appropriate directories in VS as TwinkleBearDev's article shows. Another is to put the libraries directly where VS would look for them, as my article shows. I don't know if the folders for VS2012 are the same though - might be slightly different.