0
votes

I have source code of a Visual Studio C++ project. Project contains cpp and header files of the initial project. Those files are in different folder and subfolders. However the main function exists in the default directory. I want to create a new project and add the code.

However I don't know what exactly I've to do in order to build the project. Firstly I create a empty C++ project. The next step to add .cpp files and .h files. Should I add in the project stdafx files? How can I add the code in subfolders in the new project?

EDIT:I follow instructions of TobiMcNamobi. I add existing items from solution project. Project build all files. However I am receiving an error:

 fatal error LNK1561: entry point must be defined

What exactly this error mean? I have checked the following link, it says that maybe it is not clear if the new project is Win32 Project instead of a Console. However I have created an empty project? Should I turn into a Console project?

EDIT2: I add all the dependencies and all files. The problem now is that I am facing the following error:

error LNK2005: "public: static class cv::Mat __cdecl CmSaliencyRC... already defined in .obj

1
I don't understand the question. Is it really that you know how to add .cpp and .h files but you ask how to add those files from subfolders? - TobiMcNamobi
The fist question is clear, am I suppose to add stdafx.cpp and stdafx.h from the source code? The second one, I just have to add all .cpp and .h files to project from all possible directories? As I said I ve created a new empty project and I try to add files in header files and source files folders. - Jose Ramon

1 Answers

3
votes

It depends a bit on what you want and how much source code you have.

Do you want to work on the project as a whole using Visual Studio? And the project is has many source files? Then I would put every .cpp and .h file of it into the VS project. Yes, stdafx.cpp and .h and all subdirectories.

Do you want something specific, a certain part of the project and you have just a few source files? Then you should start with only those files you need and add files when you see that they are required, too.

Adding files to a VS project is simple right clicking the project (in Solution Explorer), select "Add" / "Existing Item". A file chooser dialog appears, select all files you want to add from any subdirectory.

I admit that I do not know an elegant way to do this if you have a lot of directories.