How can i find out what DLL's my C++ program uses? - c++

Even when I build an exe in release mode, when I try to execute the program on another PC, I get DLL not found errors. So I need to find out which dlls my program needs and copy them with the exe. But I can't seem to figure out how to find what dlls my program uses.
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include "SDL_mixer.h"
#include <string>
#include "head.h"
#include <cstdlib>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <windows.h>
I'm pretty sure what dll's it needs is based on the includes so here they are. I know which ones are used by the SDL libraries but I don't know the others.

Dependency Walker might help. Have a look at the application screen-shot below.

Use dumpbin to print all dynamic libraries required by your executable or DLL:
dumpbin /dependents myprog.exe
Typically you can find dumpbin.exe in directory "C:\Program Files (x86)\Microsoft Visual Studio XXX\VC\bin".

You can use a dependence walker to see whether all dependence are available before your run the exe:

Related

understanding of dll lib c++ vs

I am trying to understand dlls. But it is still a bit vague. So please forgive if this is a very stupid question.
Lets say I have a project with lots of files and a mainfile that #includes those files.
mainfile.cpp:
#include "fileA.h"
#include "fileB.h"
#include "fileC.h"
I can create a mydll.dll from this project. A lib is created along with that. (I used C++, VS)
Then I have a project UseMydll that uses this dll. There I include
#include "pch.h"
#include "fileA.h"
#include "fileB.h"
#include "fileC.h"
So whats the point then in creating the dll if I still need to include and provide my fileA,fileB,fileC ?

Unable to use Precompiled headers in visual studio

I've seen several questions discussing this topic but none of their solutions seems to apply here. I have several libraries that I don't wont to be compiled every time I build the project so I've created "b5pch.h" and b5pch.cpp" files.
//b5pch.h
#pragma once
#include <iostream>
#include <memory>
#include <utility>
#include <algorithm>
#include <functional>
#include <sstream>
#include <string>
#include <vector>
#ifdef B5_PLATFORM_WINDOWS
#include <Windows.h>
#endif
//b5pch.cpp
#include "b5pch.h"
In properties I've set precompiled header for every cpp file to be Use(/Yu) like so:
And for b5pch.cpp it's set to Create(/Yc)
after that I've added #include "b5pch.h at the start of each cpp file(I only have two not including b5pch.cpp) but when I try to build the project I get two errors saying exactly the same thing
Error C1010 unexpected end of file while looking for precompiled header. Did you forget to add '#include "b5pch.h"' to your source?
Okay I've fixed the problem. when I was including b5pch.h in my cpp files I was doing it like this:
#include ../b5pch.h since they were in different directories.
When I moved pch files in same directory and I just wrote #include b5pch.h there were no more errors. I didn't wanted them to be in same folder so I've moved them back out but in Project Properties->Additional Include Directories I've added "src" so I could just use #include b5pch.h in my cpp files even tho they were not in the same folder.

Cannot find header file in Visual Studio project directory

I am trying to build a simple Windows 32 Console application pong game using Visual C++. See link http://www.noobtuts.com/cpp/2d-pong-game for more information. I have downloaded a group of headers files as well as a DLL file and libraries in a folder called freeglut_files.
Structure:
/GL
/freeglut.h
/freeglut.lib
/freeglut_ext.h
/freeglut_std.h
/glut.h
/freeglut.dll
/freeglut.lib
In Visual Studio Community 2015, my project structure looks like this:
/Pong
/External Dependencies
/Contains a number of files including GL.h and GLU.h (see below)
/Header Files
/stdafx.h
/targetver.h
/Resource Files
/Source Files
/freeglut.dll
/freeglut.h
/freeglut.lib
/freeglut_ext.h
/freeglut_std.h
/glut.h
/Pong.cpp (executable)
/stdafx.cpp
/ReadMe.txt
I added all the files, including the GL directory, to the source files directory of my Visual Studio project.
For some reason Visual Studio puts some of the header files in the /External Dependencies folder, including GL.h and GLU.h. However, my compiler cannot seem to find freeglut.h. I have tried moving it to the /Header Files directory and cannot move it to the /External Dependencies directory. Here is my code to Pong.cpp
#include "stdafx.h"
#include <string>
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <sstream>
#include <math.h>
#include <gl\GL.h>
#include <gl\GLU.h>
#include "freeglut.h"
#pragma comment (lib, "OpenGL32.lib")
int _tmain(int argc, char** argv)
{
return 0;
}
The compiler will not compile the line where I include freeglut.h. Where should this file be? Why can I not add it to /External Dependencies?
Have a look at page Team Development with Visual Studio .NET and Visual SourceSafe. It might help problems in the future as well. It's always good to try to find the answer from the developer of the software you're using.

fatal error: vector: No such file or directory

I have an Android project comprising of lots of native code in C++. However, I am unable to build my library as it is not able to find out vector.h header file. What could be the issue ?
A sample of my inclusions in almost all the pages.
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <vector>
The compiler is able to find out all other header files except vector.h in every file. Any suggestions about where am I going wrong ?
NOTE : Filenames end with .cpp and I have already tried #include <vector.h> , #include "vector.h"
Thanks !
The issue was finally resolved by creating Application.mk in JNI folder of project and adding the following to it :-
APP_STL := stlport_static
For more details, refer to this question on SO

How to solve an error with imgproc.hpp and core.hpp?

i used a c++ programm for image processing using opencv 2.1. and that program has below include files:
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <math.h>
#include <string.h>
but after debuging the program i get error message as:
fatal error C1083: Cannot open include file: 'opencv2/core/core.hpp': No such file or directory.
that is same as for imgproc.hpp and highgui.hpp after that i changed #include "opencv2/highgui/highgui.hpp" to #include <highgui.h> and that error solved.
But i could not find a solution for imgproc.hpp and highgui.hpp and there are no files named imgproc.hpp and highgui.hpp inside the opencv folder.
How can i solve this error?
From the path separator, I assume you are using *nix OS. So the following shell commands should help you to find the correct location of the header files:
locate highgui.h
locate highgui.hpp
As previously stated, your libraries aren't in an included area. Most people have tailored their responses to a Linux-based system, but if you're on Windows (i.e. Using Visual Studio), you can usually just include the entire path of your library folder in the include statement.
For example:
#include "C:\OpenCV\bin\install\opencv2\highgui\highgui.hpp"
#include "C:\OpenCV\bin\install\opencv2\imgproc\imgproc.hpp"
I recently had my fair share of errors after trying to install OpenCV 2.4.1 and finding the correct directories to include (both for 'include' and 'lib') was difficult at first. I recommend re-installing your OpenCV and going from there.
http://opencv.willowgarage.com/wiki/InstallGuide