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.
Related
I have two projects in an eclipse workspace and one will add the include path for the boost libraries and one will not.
both projects use -std=c++11 I have included the include path in the c++ settings for both projects and it will not show up in the Includes section of one of the project. I have no idea where to look to resolve this issue.
I can include other include paths and they work as one would expect. I think it must have something to do with the boost libraries but I have no idea what to look for.
Any suggestions would be appreciated.
I just created a new project and copied all of the files over and it works perfectly, it must have been some problem with the project. Sorry for the bother.
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.
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.
I know many have asked this question, but following the things suggested hasn't seemed to work for me. So I thought I'd ask for help, as I'm obviously missing something.
I've spent the past couple days writing some code that uses the boost library that allows me to open text files, translate the text into a usable data format, and save the data as a text file when I'm done with it. I built it specifically to be extendable to deal with different datatypes (specifically any object or class I make down the line) so that I could link to it as a library in my project as I do other libraries.
However, even after compiling it into a lib and adding the directory of the lib to the "Additional Include Directories", I get an unresolved external error whenever I try to include one of the header files in the library. I've also tried putting the direct path to it under Additional Dependencies (as well as just the library name with the path to the directory set in Additional Include Directories and Additional Library Directories. I also tried it with only one of those on at a time and it still failed).
Is there something I'm missing? How can I compile this code I'd like to reuse and link to it in new projects without copying the cpp and h files into my solution every time? Would a DLL work better/easier? If so, how would I go about compiling it as a dll and linking to it?
Thanks for reading this wall of text. Any help you could provide would be great.
Ok. While it's not the exact solution I was going for, I managed to figure this out. For anyone running into this problem, there's a wonderful tutorial that explains how to make DLL files and make use of them (at least on windows, don't have any computers using an alternate OS set up yet to test the DLL on). You can find it here.
http://programmingexamples.wikidot.com/blog:1
The gist of the problem is you need to also keep a copy of the .h file handy to include in your project. (what I did is created a directory on my C drive that holds the libraries I'm making, and in that I have a folder for the .lib files and a folder for the .h files.) Either import the .h file directly into your project directory or add it to your project properties (C++ -> General -> Additional Include Directories ). Make sure for that, you're linking to the directory, not the file itself. In the linker, you need to add your .lib file to the Additional Dependencies section (Linker -> Input -> Additional Dependencies). You can put the whole path here, or you can just put the file name, then tell the program where to find the directory it's in (add the path to the directory to Linker -> General -> Additional Library Directories)
Hope this helps anyone else who managed to miss something that everyone else seems to understand instinctually :P
It's pretty easy to use a library in VC++ 2008 if you create a project for it and build it alongside the other projects in your solution, but what if the library has too complex of a build process and must be compiled separately via makefile?
My library is like that, and while I've had no problem compiling it on the command line, I have no clue what to do with the resulting header files and .lib file. I've put them all in one directory and added its path to my main project's Additional Include Directories, so it finds the header files just fine. I've also added the relevant info to Additional Library Directories and Additional Dependencies.
Perhaps there's another setting I'm forgetting to set besides these three? I'd appreciate all the help I can get. Thanks.
EDIT Here are the syntax errors I'm getting:
http://pastebin.com/m72ece684
Okay, based on those errors, it has nothing to do with finding your .lib files, it's choking on the header files.
Edit:
It looks like somewhere in windows.h, there is a macro definition for X942_DH_PARAMETERS which is breaking your dl_group.h.
Instead of putting your botan headers at top, but windows.h at top, and then right before you #include the botan headers add this line:
#undef X942_DH_PARAMETERS
Or as I just discovered, that macro is defined in wincrypt.h, and if you add NOCRYPT to your preprocessor definitions it won't include that file. Since you're using a third party crypto library you probably don't need wincrypt.
While I can't exactly say what your problem is I can offer some advice as to how to find a solution. I suggest creating a simple library that contains a single method and a single class, build it, and then try to successfully link it to your project. Once you get that done on a smaller scale, try repeating the steps with your original library.
For msvc compiler you can add
#pragma comment(lib, "MYLIBNAME.lib")
in your header. This will automatically make the linker look for "MYLIBNAME.lib" in the "Additional Library Directories".
If no longer an error occures
Can't find header ...
Can't find MYLIBNAME.lib
the problem is probably related to some other stuff like wrong C runtime, debug release mismatch, ...
P.S.: If the lib is in the solution tree just setting the dependency on the lib, will cause VS to add the targetpath to the libfolder and the libname to the libraries.