Linker library error in visual studio - c++

Running visual studio 2010 writing an openGL program in C++
I'm getting this error, and can't for the life of me figure out why
fatal error LNK1104: cannot open file 'Image_Loading/nvImage.lib'
The file is in the correct place, and nvImage.lib is present in the additional dependencies of the linker, any ideas??

The folder "Image_Loading" is probably not in your library search path. Include files has a different search path, so even if its find the includes, the folder might be missing from the libary search path.
you should either add the folder to the LIB enviromental variable, or add /LIBPATH:folder to the command line of the linker.

Related

Boost Library cannot get to work in C++, Include directories not working

I recently tried to install boost libraries in C++ 14, and I added it's include paths like:
Solution Explorer > Project Name > Property Pages > VC++ Directories > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost"
I tried to compile after adding this:
#include <boost\variant.hpp>
In Error List window, I can see E1696 - cannot open source file "boost\variant.hpp" and I can't compile like before.
Then I tried with adding a backslash like "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\", still didn't work.
I also read this post and explicitly specified it's directory, but even didn't work.
Again, I read this post and did exactly same what is in given answer (as I already built project several times) , but still no success.
However, if I include a library like:
#include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp"
Now compiler recognizes it, but now I can see more than 100 errors in Error List window, those errors are pointed to header files of boost libraries, not in my project file which has variant.hpp included.
All those errors are E1696 - cannot open source file "boost\<libraryname.hpp>" or E1696 - cannot open source file "boost\<subdirs>\<some other files included in libraryname.hpp>"
So, if I remove the line #include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp" from my project's header file, all errors disappear suddenly and project compiles fine! no any single error now!
I want boost to work anyway, so I can use it in projects, but I can't manually edit all those header files and change <boost\... to original locations.
Please help me to get rid of this issue.
make sure you download and install the correct boost version. Installing it in the visual studio directories is possible, but not advised. I suggest you use one of the packages from here. Assuming you use visual studio 2017 and you are developing for 64bit, this could perhaps be the correct package for you.
make sure you do both: adding the include search path and the library search path to your visual studio.
The include search path should point to the boost-installation root directory (the one that contains the Jamroot file and a boost subdirectory). The library search path should point to the correct library subfolder within the boost installation. This is one of the subfolders that start with lib64-msvc-**.* (or lib32-msvc-* if you're developing for 32bit).
The default install path of the binary boost package above will install it into C:\local\boost_<boost version>. Make sure you use the paths from this installation directory and follow the instructions here.
Example:
Include search path: C:\local\boost_1_64_0
Library search path: C:\local\boost_1_64_0\lib64-msvc-14.1

Error LNK1104 cannot open file ';.obj'

Error LNK1104 cannot open file ';.obj' project1
D:\project1\source\project1\project1\LINK 1
I'm using visual studio 2015 and openframeworks, I'm fairly new to the c++ language.
I couldn't find a line of code which refers to this file.
Has anyone had a similar error or does know any tips to find the cause of this error?
The build-process has two main step:
compile
link
In the compiling stage the obj files are built from the source file. In the linking step these obj files are "concatenated" resolving unresolved references and builds the final output (static/dynamic library or an executable).
Your error is a linker error which says that one of the compiled file cannot be found. This can happen when:
the compilation is failed (check the previous errors if any)
the compilation is skipped for the specified source file for some reason (this can happen when the whole project is excluded from the build process or you specified that it should save the preprocessed file only).
Do you have any other error messages or warnings? Please check if you're actually building the specified project (and the actual source file as well). As a first step, you can check it in the Build -> Configuration Manager. Look at the checkbox in the "Build" column.
How are you setting your input paths for the Linker? For C/C++, I have found for Visual Studio the location listed below is NOT the correct way to reference library files during the compiler-linking stage (at least in Community Version 2017). I had a project folder called 'lib' which contained all my .lib files. Originally I had specified a value like (which was wrong):
Linker --> General --> Additional Library Directories: $(ProjectDir)lib;%(AdditionalDependencies)
I was getting error messages like:
error LNK1104: cannot open file 'lib.obj'
I figured out this was the correct way to specify the library directories:
VC++ Directories --> Library Directories
In my case, my value was:
VC++ Directories --> Library Directories: $(ProjectDir)lib;$(LibraryPath)
I had built a static library, say TempLibrary.lib. I was linking this library with my application and got the above error in VS2015. The problem was, that I was mentioning only the name of the library and I missed the extension. i.e, I had added only the name "TempLibrary" in the
Linker->Input->Additional Dependencies.
After I had added the extension (.lib) to the name, the linker issue got resolved. i.e, TempLibrary.lib

How to use libpng in Visual Studio?

I am using boost generic image library and it requires libpng. I built libpng and obtained the files libpng.lib, zlib.lib and libpngd.lib. When I tried to compile my project, Visual Studio gives a fatal error
fatal error LNK1120: 21 unresolved externals
with a bunch of unresolved external symbols like _png_set_sig_bytes and _png_read_row. What's going on here and how to solve it?
From MSDN:
https://msdn.microsoft.com/en-us/library/ba1z7822.aspx?f=255&MSPPError=-2147217396
To add .lib files as linker input in the development environment
Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
Click the Linker folder.
Click the Input property page.
Modify the Additional Dependencies property.
You must do this; explicitly specifying "libpng.lib", "zlib.lib" and "libpngd.lib" in your .exe's link command.
So this is coming from a complete simple minded moron so maybe this'll be helpful....it took me a little while to grasp. Basically, you're downloading the source code. That means, that you have to be the one to compile the source code.
Windows can compile programs that are written in C in the command prompt. You have to build the program, and it spits out a .dll or a .lib file. That or those are the files that you link to visual studio application.
You set dependencies to the header files which is usually like the source codes root folder or wherever all those .h files are.
You then set the linker to link to the .dll or .lib file(s). In Boost C++'s case, you need to link to a 'lib' folder.
I think what you need is to go over and completely grasp the basics. Here's a link from Microsoft on how Windows can compile C programs from the command prompt:
https://learn.microsoft.com/en-us/cpp/build/walkthrough-compile-a-c-program-on-the-command-line?view=vs-2019

cannot open file 'libboost_log-vc120-mt-1_58.lib' in VS 2013 C++ project

I am attempting to compile a project in visual studio 2013 that is using boost 1.58.
I am receiving this error:
Error 3 error LNK1104: cannot open file 'libboost_log-vc120-mt-1_58.lib'
This entry is in my VC++/General/Library Directories
$(BOOSTDIR)\lib\x64
the value of my BOOSTDIR directory is
C:\Projects\boost_1_58_0
I have verified that the path C:\Projects\boost_1_58_0\lib\x64 has the "libboost_log-vc120-mt-1_58.lib" file.
What could I be missing?
I resolved the issue by rebuilding boost and then adding the new lib location as follows:
Add $(BOOSTDIR)\libs;$(BOOSTDIR)\stage\lib; to Additional Libraries
Add $(BOOSTDIR) to Additional Include Directories
I'm guessing there was a compiler mis-match between my project and whatever boost was built with (even though my coworker told me it was built using the same compiler). Or it could have been the path was wrong or missing.

How to link to a library

Visual Studio 2010.
My library is in a folder called "lib" which is in the project folder.
I had added the library to Properties>Linker>Input>Additional Directories, and have tried various things in Properties>Linker>General>Additional Library Directories but none work (have tried ../lib, $(SolutionDir)../lib, lib, and same with an additional slash at the end).
I also tried just having it in the project folder which didn't work either. (With $(SolutionDir) in Additional Library Directories or blank)
I always get this linker error: LINK : fatal error LNK1104: cannot open file 'cyclone_d.lib' or LINK : fatal error LNK1104: cannot open file 'cyclone.lib' if trying to build a release version.
If anybody has any ideas about what I need to do that would be fantastic.