I have a Visual C++ project that uses both CUDA and Boost. I have the following environment variables pointing to different libraries:
BOOST64_Lib = c:\boost\1_57_0\lib64-msvc-11.0
CUDA_LIB_PATH = c:\program files (x86)\NVidia\GPU Computing Toolkit\CUDA\v6.5\lib\x64
My VC++ Directories setting includes the following libraries:
$(BOOST64_Lib);$(CUDA_LIB_PATH);$(LibraryPath)
When I compile the project, I get an error saying cudart.lib can't be found. If I move $(CUDA_LIB_PATH) to the beginning of the VC++ Library directories, I get an error saying msvcprtd.lib cannot be found.
msvcprtd.lib exists in the proper place (VC\lib\amd64 under Visual Studio 2012). cudart.lib obviously exists in the CUDA library folder.
I'm using Visual Studio 2013, and the specific project is compiled with the Visual Studio 2012 (v110) Platform Toolset.
I must be missing something really small, that makes the linker complain about different libraries based on the order of library folders, but I can't find what that is.
Either set
CUDA_LIB_PATH = "c:\program files (x86)\NVidia\GPU Computing Toolkit\CUDA\v6.5\lib\x64"
or
LibraryPath = $(BOOST64_Lib);'$(CUDA_LIB_PATH)';$(LibraryPath)
To get informative build log set Tools / Options / Projects And Solutions / Build and Run/MSBuild output verbosity to Normal.
Related
Having installed VS 2019 on my PC, and opening up a new project, i get 408 errors that all say it cannot open various source .h files, such as errno.h, float.h, corecrt.h, etc. or 'the global scope has no "acosf" 'I had just installed visual studio and have no clue how it works, and have not done anything other than install it and open up a new project.
Possibly useful information:
It was not installed in the default location, but on the D: drive
visual studio works fine when I open it with unity to edit scripts for my unity projects, but when opening it from its desktop icon or from the start menu, i get the errors
Unity was installed before i installed Visual studio and appears to be using a different version of visual studio somewhere else on my PC, but i cant find where it is, hence me installing it myself
The project is a C++ project
I have already tried repairing visual studio and reinstalling it, but it did not work.
I had the same issue (here), the problem is that for some reason, MSVS is not adding the Windows Universal CRT SDK to the include and library paths (this SDK has the header files for things like "float.h" and so on).
To add it to your project, you need to add the include and lib paths in the Project settings.
In my case they were:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt <- header path
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64 <- library path
(you can find it by searching for "float.h", and "ucrtd.lib", but be careful not to use the path for Linux headers).
You can add these paths at: Project Properties -> C/C++ -> General -> Additional Include Directories (add header path here)
and then Project Properties -> Linker -> General -> Additional Library directories (add library path here).
I suggest you could to check the version of Windows SDK in visual studio installer. And then set the appropriate version of windows sdk in the property -> General -> windows SDK version.
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
I have a visual studio 2012 c++ project.
I recently uninstalled it and installed visual studio 2015 and upgraded the project.
When i am building the project, getting error as shown below:
Error LNK2019 unresolved external symbol _memcmp referenced in function
Moreover i have not used anywhere in my code memcmp fucntion.
I used the linker verbose function and could see below in output file:
Found _memcmp
Referenced in MyC++Project.obj
Referenced in libcpmtd.lib(xstrcoll.obj)
Loaded libvcruntimed.lib(__memcmp_.obj)
Two questions here
1.even though i have not used memcmp in my code why i am getting that linker error?
2.why is memcmp being loaded as __memcmp_.obj
I have the following settings also in my project:
1.C++-->Code generation-->Runtime Library is set to /MTd
2.Linker-->Ignore All default libraries is set to nothing
I have tried all the project settings but everything in vain.
I have issue only with this memcmp function which i have not used.
I have used mamcpy and memset and do not have issue with those
Explicitly add vcruntime.lib or other appropriate version of CRT Library to linker parameters (additional dependencies).
When you use memcmp explicitly it is probably handled as intrinsic function and is compiled as inline function.
Try to add vcruntime.lib and ucrt.lib to your additional dependencies. ===> properties->Linker->Input->Additional Dependencies
Sample path of 'vcruntime.lib': "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\vcruntime.lib"
Sample path of 'ucrt.lib' : "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x86\ucrt.lib"
My environment: VS2017 (v141)
I've run into this same problem with a legacy Visual C++ 6.0 nmake file with Visual Studio 2015.
This blog article, Introducing the Universal CRT, describes how the Visual Studio 2015 runtime has been split into more than one library. The runtime is now "split the CRT into two logical parts: The VCRuntime, which contained the compiler support functionality required for things like process startup and exception handling, and a “stable” part that contained all of the purely library parts of the CRT" to allow for easier updates.
So long as you do not link with the /nodefaultlib option, all of the
correct library files will be found when you link your project. If you
link with the /nodefaultlib option, you will need to link several
extra libraries when you link. For example, whereas you previously
might have just linked msvcrt.lib in order to use the CRT DLL, you
will now also need to link vcruntime.lib and ucrt.lib. Here is a table
that shows which libraries you will need to link for each “flavor” of
the libraries:
Release DLLs (/MD ): msvcrt.lib vcruntime.lib ucrt.lib
Debug DLLs (/MDd): msvcrtd.lib vcruntimed.lib ucrtd.lib
Release Static (/MT ): libcmt.lib libvcruntime.lib libucrt.lib
Debug Static (/MTd): libcmtd.lib libvcruntimed.lib libucrtd.lib
See also the Microsoft documentation C runtime (CRT) and C++ Standard Library (STL) .lib files which describes details about the libraries.
See also Microsoft C/C++ change history 2003 - 2015.
This is what I have done:
Download the 1.54 zip file from the boost website
Extracted/copied it to C:\Program Files (x86)\Boost
Inside Visual Studio I have set the include libraries to: C:\Program Files (x86)\Boost\boost_1_54_0\boost_1_54_0\
(This seems to work fine for getting the compiler to accept the libraries)
Now the bit i'm having problems with- linker:
Inside Visual Studio I have set the linker include directories to: C:\Program Files (x86)\Boost\boost_1_54_0\boost_1_54_0\libs\
When I compile my project I get:
fatal error LNK1104: cannot open file 'libboost_date_time-iw-mt-sgd-1_54.lib'
EDIT Have built the boost binaries using the answer below. However I now have these files:
libboost_date_time-vc110-1_54.lib
libboost_date_time-vc110-gd-1_54.lib
libboost_date_time-vc110-mt-1_54.lib
libboost_date_time-vc110-mt-gd-1_54.lib
libboost_date_time-vc110-mt-s-1_54.lib
libboost_date_time-vc110-mt-sgd-1_54.lib
libboost_date_time-vc110-s-1_54.lib
libboost_date_time-vc110-sgd-1_54.lib
but still no
'libboost_date_time-iw-mt-sgd-1_54.lib'
EDIT: Think I have found the problem:
http://lists.boost.org/Archives/boost/2004/08/70114.php
OK, here's the problem: originally we had one Intel toolset:
"intel-win32" which created the library suffix "iw" (note no version
number!), and this is what the auto-link header currently searches
for.
However people have started adding versioned Intel toolsets, which
means that we now produce an ad-hoc mixture of library names, some
with compiler-version suffixes and some without, the autolink code
could handle either form, but as it's not psychic it can't handle
both :-(
Solution is to #define BOOST_ALL_NO_LIB
On a 64bit system you should build boost in Program Files, not Program Files(x86) the boost automatic library include does not handle the redirection correctly. Alternatively you can manually manage the library inclusion... but I would highly recommend against it.
Also a reminder that you need to build boost in all the flavors and bitnesses you are going to use. See How to use Boost in Visual Studio 2010 for a good example of how to do so.
In an administrator visual studio command prompt go to the boost directory
run bootstrap.bat
run b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64
wait for b2 to finish building
EDIT:
As it turns out the iw in that library refers to the intel compiler... to use that with boost and visual studio you'll need to follow the directions from Intel.
I'm using Boost C++ Libraries v1.47 to serialize an class (I used the installer and selected everything and for VS2010).
But I get a error from my Visual Studio 2010 linker "Lnk1104 Can not open libboost_serialization-vc100-mt-gd-1_47.lib". I set up the "c:\program files\boost\boost_1_47" for my includes and "c:\program files\boost\boost_1_47\lib" for my libs. I don't know what's going wrong.
Update
I don't know why but if I put the lib files from the boost directory to "c:\program files\Microsoft Visual Studio 10.0\VC\lib" everything work fine. Boost load the lib files
somehow dynamical.
If you cannot find the file on your computer with the windows searcher just ask anybody else who uses boost to give you a copy of that file (libboost_serialization-vc100-mt-gd-1_47.lib).
My friend from work used to have the same trouble after having installed boost, there was just not the file in the boost folder. At the same time I picked up the file successfully so we copied it to the right directory on his computer.
For some reason precompiled libs in the installer are named on format "boost-module-vc100..." and headers specify library name as "libboost_module-vc100...". So you should specify library name in project settings to make it linked correctly.
I solved this issue by compiling all boost libraries by myself. With modern PC it won't take too long to do.
to resolve this problem,
go to properties -> Linker -> General -> Additional Library Directories
Enter the path of boost:
Boost-path\stage\lib