Including a dependency in VS2010 - Visual Leak Detector - visual-studio-2010

I'm trying to use Visual Leak Detector 1.9h beta in a Visual C++ project on Visual Studio 2010. When I build and run my project I get the following error:
The program can't start because
vld.dll is missing from your computer.
Try reinstalling the program to fid
this problem.
The README that comes with VLD states for Visual C++ 8 and 9:
Go to Tools ->
Options -> Projects and Solutions ->
VC++ Directories. Select "Include
files" from the "Show Directories For"
drop-down menu. Add the include
subdirectory from the Visual Leak
Detector installation directory. Move
it to the bottom of the list. Then
select "Library files" from the
drop-down menu and add the lib
subdirectory from the Visual Leak
Detector installation directory.
Again, move it to the bottom of the
list.
The menus suggested is deprecated in VS2010. What would be the equivalent for VS2010?
I tried the following without success:
Right click on the project \ properties \ Configuration Properties \ C\C++ \ General \ Additional Include Directories -> add ";C:\Program Files (x86)\Visual Leak Detector\include"
Right click on the project \ properties \ Configuration Properties \ Linker \ General \ Additional Library Directories -> add ";C:\Program Files (x86)\Visual Leak Detector\lib\vld.lib"
but as you can guess, it didn't work...

The error message you got isn't fixable with any of the settings you're browsing through. It is a straight-forward runtime error, Windows just cannot find the DLL that the tool needs.
First thing you need to do is find out where the installer put the vld.dll file. You are clearly running a 64-bit operating system. First look in c:\windows\system32, move it to c:\windows\syswow64 if you find it there so that 32-bit programs can find the DLL. Also check if the installer messed with the system environment PATH variable (Control Panel + System, Advanced), you may have to restart Visual Studio to make the change effective. Adding the install directory to this variable would be another solution. The last ditch make-it-work effort is to copy vld.dll into your build directory.

Related

FreeGLUT 3.0.0 Visual Studio solution?

Where is the Visual Studio solution for FreeGLUT 3.0.0? I know the 2.8.1 has one, but 3.0.0 does not. I would really like to use the latest version.
Use the included CMakeLists.txt to create a Visual Studio solution:
How to build freeglut with CMake on Windows (MS Visual Studio)
Download CMake (http://www.cmake.org/cmake/resources/software.html).
Get one of the releases from the binary distribution section.
Run the CMake installer, install wherever you like.
Launch CMake via Start > Program Files > CMake 2.8 > CMake (GUI)
(note that the shortcut put by the installer on your desktop does NOT
point to the CMake GUI program!)
In the "Where is the source code" box, type or browse to the root
directory of your freeglut source (so that's /freeglut, not
/freeglut/src).
In the "Where to build the binaries" box, type or browse to any
folder you like - this will be where the Visual Studio solution will be
generated. This folder does not have to exist yet.
Hit the Configure button near the bottom of the window.
Pick your target compiler, make sure that its installed on your
system of course!
Answer Ok when asked if you want to create the build directory.
Wait for the configure process to finish.
The screen will now have some configuration options on it, for
instance specifying whether you want to build static and/or shared
libraries (see below for a complete list). When you've selected your
options, click the Configure button again.
The Generate button at the bottom will now be enabled. Click Generate.
The build files will now be generated in the location you picked.
You can now navigate to the build directory you specified in step 5.
Open the freeglut.sln file that was generated in your build directory,
and compile as usual

How to compile Boost on Windows 10 with Visual Studio

I'm working on a new project which requires Boost's regex library. I was able to use the no-compile headers, but needed some of the binaries which require being compiled. Boost's documentation for compiling in Visual Studio wasn't very helpful (resulted in several errors) and I've seen a fair number of people online having these same problems, but it took a lot of Googling to get them all, so I've included detailed steps below to help anyone with the same issues.
I'm running Windows 10 preview and Visual Studio 11 (2012), but the steps should work for other versions as well.
Step 1 - Set up a developer command prompt in Visual Studio
You will need this to compile the binaries. The VS Command window (Ctrl+W,A) didn't seem to work.
1. In VS , select "Tools" at the top, then select "External Tools" and enter the following:
-Title: "VS2013 Native Tools-Command Prompt" (your choice)
-Command: C:\Windows\System32\cmd.exe
-Arguments: /k "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat" (make sure to use the correct path to your version of VS)
-Initial Directory: Select as suits your needs (if you'll use boost a bunch, I'd select the folder where you dropped boost)
2. Click OK. Now you have command prompt access under the same "Tools" menu, where it will show up as a new option.
Source: https://stackoverflow.com/questions/21476588/where-is-developer-command-prompt-for-vs2013
Step 2 - Run Bootstrap.bat from VS developer command prompt
1. Navigate to your Boost folder (mine is C:\Program Files\boost\boost_1_58_0)
2. Run `.\Bootstrap.bat` which results in the following error:
> 'cl' is not recognized as an internal or external command"
Cl.exe is is a tool that controls the Microsoft C and C++ compilers and linker. This error is because cl.exe is not in your path environment variable; it isn't automatically added when you install VS. Check by running the following:
-In PowerShell - `($env:path).replace(';',"`n")` (easy to read)
-In cmd.exe - `echo %path%` (harder to read)
4. Add cl.exe to your path by adding its parent folder "C:\Program Files (x86)\Microsoft Visual Studio [your version]\VC\bin"
-Hit Win+X -> System -> Advanced System Settings -> Environment Variables -> Select "Path" under System Variables (in bottom pane) -> Edit -> paste the following to the end: ";C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin" (don't forget the semicolon on the front)
-Test by opening a new command prompt or PowerShell window and type `cl.exe -?`
Step 3 - Re-run bootstrap with cl.exe in your path
You may be missing some environment variables for Visual Studio, resulting in the following error:
mspdb110.dll not found
1. Navigate to the Visual Studio path in your Visual Studio developer command prompt (for me it's C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin)
2. Run `.\vcvars32.bat` which automatically sets some variables for you, but there is no output -- lack of error means likely success
Step 4 - Compile the Boost binaries
Now running .\Bootstrap.bat in your Visual Studio developer command prompt should succeed and you can now use the binaries in your project!

Use of NVIDIA Tools Extension under Visual Studio 2010

I'm trying to use the NVIDIA Tools Extension to perform a more accurate performance assessment of a CUDA code with the Visual Profiler. I'm using Visual Studio 2010 for developing the code.
To setup Visual Studio 2010 for this feature, I have added
Properties -> Linker -> General -> Additional Library Directories -> $(NVTOOLSEXT_PATH)\lib\$(Platform);
Properties -> Linker -> General -> Input -> Additional Dependencies -> nvToolsExt32_1.lib;
However, when I use
#include <nvToolsExt>
the compiler says
Error 1 error C1083: Cannot open include file: 'nvToolsExt': No such file or directory
The environmental variable NVTOOLSEXT_PATH is set as
NVTOOLSEXT_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\nvToolsExt\
but the directory C:\Program Files\NVIDIA GPU Computing Toolkit\nvToolsExt\ is not present on my system and so I think that the NVIDIA Tools Extension is not installed.
I have two questions:
1) Is the above procedure to set up Visual Studio 2010 for the NVIDIA Tools Extension feature correct?
2) How to install the tools?
Thanks in advance.
In the Nsight User Guider for Visual Studio 2.2 \ NVIDIA Tools Extension Library \ Section 5. Adding NVTX to a Project has the following instructions:
The NVTX API is installed by the NVIDIA Nsight “host” installer (by
default) into the following location:
On a 32-bit system: C:\Program Files\NVIDIA GPU Computing
Toolkit\nvToolsExt
On a 64-bit system: C:\Program Files (x86)\NVIDIA GPU Computing
Toolkit\nvToolsExt
Both the header files and the library files themselves (.lib, .dll),
are located underneath this path.
By default, the NVIDIA Nsight installer will set up the environment
variable NVTOOLSEXT_PATH to point to the aforementioned location that
matches the system's bits.
5.1 C++ Project
In order to compile your project with NVTX support in Visual Studio,
use the following steps to setup your project accordingly:
Open the project properties dialog.
Navigate to Configuration > Properties > C/C++ > General.
Add the following path to the Additional Include Directories: $(NVTOOLSEXT_PATH)\include
Navigate to Configuration Properties > Linker > General.
Add the following path to the Additional Library Directories:
$(NVTOOLSEXT_PATH)\lib\$(Platform)
Navigate to Configuration > Properties > Linker > Input.
Add nvToolsExt32_1.lib or nvToolsExt64_1.lib (according to your system specifications), to the
Additional Dependencies.
5.2 CUDA (.cu file)
In case you use NVTX to annotate code in .cu files, please also make
sure the following configuration is setup (this is in addition to the
steps discussed in the previous section):
Open the project properties dialog. Navigate to Configuration Properties > CUDA C/C++ > Common. > Add the following path to the
Additional Include Directories: $(NVTOOLSEXT_PATH)\include
In the question you have skipped step 5.1.2 which adds NVTX to the Additional Include Paths. Without the updated include path the compiler will fail to find the NvToolsExt.h.
Section 5.3 and 5.4 recommend moving the NVTX library into your source tree (vs. using the default location) and adding a deploy to step to copy the DLLs to the project bin directory.

How to include <cuda_runtime.h> in .cpp file

I have problem to include <cuda_runtime.h> in .cpp file. Error: Cannot include file: cuda_runtime.h: No such file or directory.
I am trying to complie code from Rob Farber ( http://www.drdobbs.com/architecture-and-design/222600097?pgno=1 ).
I have compiled few cuda codes before but <cuda_runtime.h> was allways included in .cu file.
I am using VS 2008 Express.
Q: Do I have to link VS somehow different so it knows where to look for <cuda_runtime.h>?
In Visual Studio 2008, add the path of the include files in Visual C++ directories.
"Installation Path"\NVIDIA GPU Computing Toolkit\CUDA\"version"\include\
Here is the procedure:
In Visual Studio 2008, go to
- Tools -> Options -> Projects And Solutions -> Visual C++ Directories.
- Select include files from the drop down list named "Show Directories For".
- Add new item by clicking the yellow button below the drop down list.
- Paste the include fles path here.
- Verify the correctness of path by clicking the check button on left of yellow button
- Click ok and restart visual studio.
Now Visual Studio 2008 will know where the include file is located.
Instead of setting up a hard-coded path - which you will most likely have when locating CUDA installation on your machine - you can also add cudart.lib as additional dependency for the linker.
Right click on the project > Properties > Linker > Input > Additional Dependencies. Add cudart.lib there.

Compiling a simple Qt "Hello World!" application within Visual Studio 2010 Express?

I'm trying to build a basic Qt "Hello, world!" application inside Visual Studio.
I got the moc step to work (I think), but now I am at a loss as to how to fix this linker error:
1>moc_mainwindow.obj : error LNK2001: unresolved external symbol "public:
static struct QMetaObject const QMainWindow::staticMetaObject"
(?staticMetaObject#QMainWindow##2UQMetaObject##B)
I've done a lot of searching but I am at a loss.
Here are my include directories:
i:\Qt\4.6.3\include\QtCore;
i:\Qt\4.6.3\include\QtGui;
i:\Qt\4.6.3\include;
i:\Qt\4.6.3\include\ActiveQt;
reease;
.;
i:\Qt\4.6.3\mkspecs\win32-msvc2008
Here are the libraries I am linking against:
i:\Qt\4.6.3\lib\QtGui4.lib;
i:\Qt\4.6.3\lib\QtCore4.lib;
gdi32.lib;
comdlg32.lib;
oleaut32.lib;
imm32.lib;
winmm.lib;
winspool.lib;
ws2_32.lib;
ole32.lib;
user32.lib;
advapi32.lib;
libpng.lib;
msimg32.lib;
shell32.lib;
kernel32.lib;
uuid.lib;
Does anyone have any ideas?
qmake will generate the moc voodoo from the header file in .pro file. As you aren't using qmake, by the sound of it, but a native visual studio project, this is probably the cause of the problem.
If you use qmake to generate your visual studio project all your problems will go away and life will be sweet. Probably!
I am using the open 2010.05; obviously you want to substitute the correct path for your version.
set up the environment
start 2010 command environment from the start menu
-set include=%include%;C:\Qt\2010.05\qt\include
-set lib=%lib%;C:\Qt\2010.05\qt\lib
-set path=%path%;C:\Qt\2010.05\qt\bin
-set QMAKESPEC=win32-msvc2010
write code, create files etc
generate the initial pro and makefile and fire up VS
-qmake -tp vc
-qmake
you should now have a makefile - check that it works by running:
-nmake
now launch visual studio
-VCExpress.exe /useenv
-XXX.vcxproj can now be opened
If this doesn't work you may need to build qt at against visual studio. This is very straightforward - go to the qt directory (from within the visual studio express command window) and type:
configure.exe -platform win32-msvc2010 -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools -no-multimedia -no-qt3support -fast
You cannot install the Qt VS plugin on the Express edition of VC++. Assuming you got the moc to compile, you also need to make sure you're including the appropriate libraries (*.lib files) at link time. This goes under Project properties > Linker > Input > Additional Dependencies.
You will need qtcore4.lib at a minimum.
Also make sure the Qt library path is in your library search path. On my computer it's c:\qt\4.6.2\lib.
I was able to get QT to work with Visual C++ Express 2010 using http://rajorshi.net/blog/2009/01/using-qt-with-msvc-express-2008/ and http://portfolio.delinkx.com/files/Qt.pdf as guides. Just in case anyone still is having problems.
Have you create the visual studio project using qmake first? The problem seems to be the moc compilation. Do you have qt plug-in installed and the qt path in enviromental variables? Can you add you hello world code so I can have a look at it?
You need to add commands to generate QT metaclasses, then also include the generated files in your project as c++ code.
Generating the QT metaclasses:
First, add your QT bin path into the Executable Directory. (This is in Configuration Properties > VC++ Directories)
Add your Header files that contain Q_OBJECT macros to the project.
Multi-select your header files, then right click on a header file, click Properties.
Change "Item Type" from "C/C++ Header" to "Custom Build Tool".
Set Command line to this: moc.exe "%(FullPath)" > "$(ProjectDir)MetaObjects\moc_%(Filename).cpp"
Set Description to this: QT: Generate $(ProjectDir)MetaObjects\moc_%(Filename).cpp (optional)
Set Outputs to this: $(ProjectDir)MetaObjects\moc_%(Filename).cpp
Run Build just to make it generate the metaobject code
Add the generated C++ files from the Project Directory Metaobjects folder into your project

Resources