Cannot open file 'SDL2.lib' and Cannot open file 'uctrtd.lib' - c++

I'm trying to follow this tutorial to get SDL working. I've followed the steps he outlined:
In my properties under VC++ Directories I have:
Include Directories
C:\SDL2-2.0.4\include;
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt;
$(IncludePath)
Library Directories
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt;
C:\SDL2-2.0.4\lib;
$(LibraryPath)
Under Linker > General I have:
Additional Library Directories
%(AdditionalLibraryDirectories)
I also have SDL2.dll placed in E:\Dev\cpp\SDL Setup\MyProject\Debug
When I have it like this I get the error Cannot open file 'SDL2.lib' but if I set the directory to the SDL lib (I.E. C:\SDL2-2.0.4\lib\x64) it no longer displays the error but then shows the error Cannot open file 'uctrtd.lib'.
I'm not sure if that error is a step in the right direction. Any help would be greatly appreciated.

From your post, it is evident that LIB files are present at:
C:\SDL2-2.0.4\lib\x64;
and not at:
C:\SDL2-2.0.4\lib;
So, you must use the x64 path to get the lib. It is also visible that .LIB for 64-bit are present in x64 folder, and there must be something for 32-bit linking (in C:\SDL2-2.0.4\lib itself) - for you 32-bit build.
Please fix it gradually, calmly and in step-by-step manner.
The error you are later getting for uctrtd.lib is probably because you messed up standard LIB paths. Bring the original LIB paths back, and append this library's LIB path.

Related

Linking a library and still fatal error LNK1104: cannot open file 'OpenVolumeMesh.lib'

I really did not want to post on something possibly asked a zillion times, but this is very desperate.
I have a solution named HexEx containing 6 projects. 3 of them do not build due to not finding this lib.
The process I follow:
step 1) Configuration properties>general>configuration type set to .exe
step 2) VC++ directories: Added the path where the .lib is (doubled checked the path is correct through the cmd and checked the name is correct (indeed the name is OpenVolumeMesh.lib although the .lib does not appear in windows)).
I added the path in executable directories and library directories.
step 2.5) VC++ directories: Added also include path used to create the OpenVolumeMesh.lib
step 3) In linker >general I added the same path to >Additional Library Directories.
step 4) In linker, once more in >Input I added the library (OpenVolumeMesh.lib) to Additional dependencies.
The error I get is:
3>LINK : fatal error LNK1104: cannot open file 'OpenVolumeMesh.lib'
in 3 out of the 6 projects, I suppose the ones needing it.
Another attempt I tried (and this is probably stupid) was to add #pragma comment(lib,"OpenVolumeMesh.lib") in every .c or c++ file containing code.
The .lib was created by building a previous project of mine. All of this is done in VS 12 2013 x64.
From what I read there must also be some .dll put in windows system32 folder some times? Might this be the problem?
Any suggestions?

(C/C++) libjpeg, missing "Release.obj" file

I downloaded jpeglib-9a. In Visual studio (2012) command prompt I typed this:
nmake /f makefile.vc setup-v10
It created several files and one of them was named "jpeg.sln" which I opened in visual studio (updated to 2012 version) and built. After that, I made new project, included this folder "D:\Data\jpeg-9a" and added this folder "D:\Data\jpeg-9a\Release" to linker.
And when I tried to compile my project, this error appeared:
1>LINK : fatal error LNK1181: cannot open input file 'D:\Data\jpeg-9a\Release.obj'
I was looking for that file but couldn't find it anywhere. I also tried compile that library again but "Release.obj" is still missing.
This is the tutorial which I was following
http://www.dahlsys.com/misc/compiling_ijg_libjpeg/index.html
So is there any way how to create that file ?
Thank you.
(if you need additional information, ask me)
SOLVED: ... I cant read properly ...
Thank you bogdan
You don't need to create that file.
The linker is interpreting the D:\Data\jpeg-9a\Release directory name as an input .obj file name. Most likely, this is happening because you added the directory name in the wrong place in the linker configuration property pages. My guess is that you added it under Linker -> Input -> Additional Dependencies; that's not the right place for a directory - that property is supposed to contain a list of .obj and .lib files to be given as input to the linker.
You need to add the directory under Linker -> General -> Additional Library Directories.

Error while using Boost with Visual Studio 2008

I am using Boost with Visual Studio 2008 and I have put the path to boost directory in configuration for the project in C++/General/"Additional Include Directories" and in Linker/General/"Additional Library Directories". (as it says here: http://www.boost.org/doc/libs/1_36_0/more/getting_started/windows.html#build-from-the-visual-studio-ide)
When I build my program, I get an error:
fatal error C1083: Cannot open include file: 'boost/python.hpp': No such file or directory
I have checked if the file exists, and it is on the path.
I would be grateful if anyone can solve this problem.
The boost include path is C:\Program Files\boost\boost_1_36_0\boost.
Linker path is C:\Program Files\boost\boost_1_36_0\lib.
The file python.hpp exists on the include path.
Where is the file located, and which include path did you specify? (And how is the file #include'd)
There's a mismatch between some of these But it's impossible to say what's wrong when you haven't shown what you actually did.
Edit:
Given the paths you mentioned in comments, the problem is that they don't add up.
If the include path is C:\Program Files\boost\boost_1_36_0\boost, and you then try to include 'boost/python.hpp", the compiler searches for this file in the include path, which means it looks for C:\Program Files\boost\boost_1_36_0\boost\boost\python.hpp, which doesn't exist.
The include path should be set to C:\Program Files\boost\boost_1_36_0 instead.
How do you include it? You should write something like this:
#include <boost/python.hpp>
Note that Additional Include Directories settings are differs in Release and Debug configurations. You should make them the same.
If boost placed to C:\Program Files\boost\boost_1_36_0\ you should set path to C:\Program Files\boost\boost_1_36_0\ without boost in the end.

Mysterious relative path library dependency

After loading an existing MFC application in Visual Studio 2008, I am left with one linking error:
LINK : fatal error LNK1104: cannot open file '..\..\xpressmp\lib\xprm_rt.lib'
I have looked "everywhere", but I can't figure out where the relative path is set. The lib file is located in C:\xpressmp\lib, and I have added this directory both under Tools-Options->Projects and Solutions->VC++Directories->Library files and Project->Properties->Linker->Additional Library Directories. I also searched all files in the project to no avail.
I have the library file (xprm_rt.lib) listed under Additional Dependencies for both Debug and Release. I also tried adding the path there, but that did not help. I cannot find any #pragma comment-directives.
About the LNK1104, the file clearly does not exist in the location that the linker is searching. But I can't see why it is searching there (..\..\...) as I have not specified any relative paths.
Any help appreciated :-)
UPDATE:
In the project .vcproj file, I found the following xml:
<File RelativePath="..\..\XpressMP\lib\xprm_rt.lib"></File>
<File RelativePath="..\..\XpressMP\lib\xprs.lib"></File>
After deleting these lines (where were they set?), I was able to link successfully. Thanks for your help, it seems the relative library path was indeed being appended "automatically" by VS.
Thanks both of you, I think it was Nick that put me on the right track.
In the project properties, look under Configuration Properties -> Linker -> Input -> Additional Dependencies, for each of your project's configurations (Debug, Release, etc). Also, look for #pragma comment(lib, ...) directives in the code.
As you've added the C:\xpressmp\lib folder to the library search path in VC++ Directories, check that only the library file name is specified under Additional Dependencies, and this does not include the path (i.e, xprm_rt.lib, not ..\..\xpressmp\lib\xprm_rt.lib).
Also, have you tried each of the solutions in the LNK1104 error documentation?
It sounds like one of a couple possibilities to me:
The library itself is setting the lib include path via a #pragma comment(lib, ...) directive; search library headers to see if that's the case
You have a project for the library included in your solution which your main project is dependent on, and the relative library path is being appended automatically by VC; check the command line property page for the main project to see if that's the case
That's what I can think of which could cause the error; hope it helps.
Thanks for answering so swiftly!
I have the library file (xprm_rt.lib) listed under Additional Dependencies for both Debug and Release. I also tried adding the path there, but that did not help. I cannot find any #pragma comment-directives.
About the LNK1104, the file clearly does not exist in the location that the linker is searching. But I can't see why it is searching there (..\..\...)

How do I resolve LNK1104 error with Boost Filesystem Library in MSCV?

I am having trouble getting my project to link to the Boost (version 1.37.0) Filesystem lib file in Microsoft Visual C++ 2008 Express Edition. The Filesystem library is not a header-only library. I have been following the Getting Started on Windows guide posted on the official boost web page. Here are the steps I have taken:
I used bjam to build the complete set of lib files using:
bjam --build-dir="C:\Program Files\boost\build-boost" --toolset=msvc --build-type=complete
I copied the /libs directory (located in C:\Program Files\boost\build-boost\boost\bin.v2) to C:\Program Files\boost\boost_1_37_0\libs.
In Visual C++, under Project > Properties > Additional Library Directories I added these paths:
C:\Program Files\boost\boost_1_37_0\libs
C:\Program Files\boost\boost_1_37_0\libs\filesystem\build\msvc-9.0express\debug\link-static\threading-multi
I added the second one out of desperation. It is the exact directory where libboost_system-vc90-mt-gd-1_37.lib resides.
In Configuration Properties > C/C++ > General > Additional Include Directories I added the following path:
C:\Program Files\boost\boost_1_37_0
Then, to put the icing on the cake, under Tools > Options VC++ Directories > Library files, I added the same directories mentioned in step 3.
Despite all this, when I build my project I get the following error:
fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-gd-1_37.lib'
Additionally, here is the code that I am attempting to compile as well as a screen shot of the aformentioned directory where the (assumedly correct) lib file resides:
#include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations
#include <iostream> // for std::cout
using boost::filesystem; // for ease of tutorial presentation;
// a namespace alias is preferred practice in real code
using namespace std;
int main()
{
cout << "Hello, world!" << endl;
return 0;
}
Ferruccio's answer contains most of the insight. However, Pukku made me realize my mistake. I am posting my own answer to give a full explanation. As Ferruccio explained, Filesystem relies on two libraries. For me, these are:
libboost_system-vc90-mt-gd-1_37.lib
libboost_filesystem-vc90-mt-gd-1_37.lib
I must not have noticed that when I supplied the directory for libboost_filesystem-vc90-mt-gd-1_37.lib, the error output changed from
fatal error LNK1104: cannot open file 'libboost_filesystem-vc90-mt-gd-1_37.lib'
to
fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-gd-1_37.lib'
Causing me to think that the error was persisting. This lead me to post some rather inaccurate information. Also, after reading that Filesystem requires two libraries, I now see the significance of the keyword stage for the bjam command. Supplying
bjam --build-dir="C:\Program Files\boost\build-boost" --toolset=msvc --build-type=complete stage
Causes bjam to place an additional directory, aptly named stage, in the boost_1_37_0 directory. This folder contains a folder named /lib, which has copies of all of the lib files in one place. This is convenient for Visual C++ because you can supply it with this single directory and it will take care of all of the dependencies.
boost::filesystem is dependent on boost::system, so you need both paths.
Part of the problem is you're using the boost libs out of the build directories instead of the install directory (the boost build process should create both). The install/lib directory has all the libs so you only need to specify one path.
The boost build process builds each library in its own directory. At the end it copies all those .lib files into one common lib directory.
Since you didn't specify an install directory as part of your build command (with --prefix=...), I believe the default is C:\Boost. Check to see if that directory is there and if so use C:\boost\include\ boost-1_37 for your include path and C:\boost\lib for your library path.
Last answer is right.
But you should find boost config file $BOOST\config\user.hpp and
uncomment this directive #define BOOST_ALL_DYN_LINK.
Now it begin use dynamic link with boost and it should works.
I think the real original problem is related to the default boost build process on windows which expects static linking of a library which will have a name beginning libboost_sytem<etc..>. The macro you need is
#define BOOST_SYSTEM_DYN_LINK
which makes ensures that the Boost.System library is dynamically linked. The dynamic library name is boost_system<etc...> as apposed the the static library libboost_sytem<etc...>
The bjam command line should have built all versions of all libraries. Still, when you build with
bjam --build-dir="C:\Program Files\boost\build-boost" --toolset=msvc --build-type=complete stage
(note the stage at the end) all libraries are copied to a common libs/ folder, so that MSVC's autolinking feature works when you only add this libs/ folder to your library path.
I do not know if bjam without stage still copies all those files to a single folder. If not, execute such a stage build to do this. If they are, well, sorry, configuration seems correct, maybe a minor typing error somewhere?
The error you have posted complains about file libboost_system-vc90-mt-gd-1_37.lib, but in the directory you have only libboost_filesystem-vc90-mt-gd-1_37.lib, right?
Look for libboost_system-vc90-mt-gd-1_37.lib. If you find it, add the corresponding directory to the library search path. If you don't find it, see if you have boost_system-vc90-mt-gd-1_37.lib instead (like I do), and try copying that to the desired filename.
I had this same problem, what you need to do is add the "lib" directory under the top level boost folder to the library path in Visual C++.
This most definitely solved the issue for me.