C++ project folder External Dependencies contains only .h and .hpp files - c++

I'm working on a C++ project in Visual Studio, the bulk of which was designed by someone else, and I have limited knowledge of computer programming outside of writting simple classes and using them. In the solution explorer, there's a folder called "External Dependencies", and it contains a ton of .h and .hpp files, but no .cpp files.
In the code editor, if I go to some block of code containing a function call to a function declared in a file in the External Dependencies folder, and I right-click>go-to definition on that function, it will take me to the declaration, not the definition. It's as if the project doesn't know where the .cpp files are, but it must, otherwise these functions wouldn't work.
What kind of folder is External Dependencies?
What is the process of setting one of these up in Visual Studio so that the compiler knows the definition of the functions your using in your program?

If I understand your question correctly, you need to include the appropriate header files with the methods you're using in your program? I think you still need to have all of the appropriate #include directives. So, if you include the header files
#include <library>
or
#include "header_file.h"
that would enable the compiler to have access to the methods of the class you're trying to use.
If the header files don't include the actual implementation (it's a common practice I think to split classes into .h header files and .cpp implementation files), you also need to put the include directives in the .cpp implementation files.

Related

Hide class implementation using static lib c++

I am working on a project and I need to make a class which I will share using a static library. So far I wrote the implementation inside a .cpp file and shared only de .h and .lib files. If I use those inside another project and I try to debug something that uses my class I am able to see the full implementation written in the .cpp file. Is there any way I could hide the implementation?
If I use those inside another project and I try to debug something that uses my class I am able to see the full implementation written in the .cpp file. Is there any way I could hide the implementation?
You can only see the implementation in .cpp because:
.lib has debug information not stripped.
.cpp file happens to be in a location mentioned in the debug information (i.e. there is no copy of .cpp inside .lib).
If you remove any of the above conditions you won't be able to see the source in the debugger.
You can use the pimpl idiom to hide the implementation.By switching to pimpl idiom, you can change your implementation anytime without affecting the way your client uses library.
But to your question, if you are distributing your header and library file only, then others won't be able to see your implementation. The library has embedded info about your source files in your machine. That's why you are able to debug like that.

VC++ C2011 redefinition errors - unused header files

I am working with a large console application. The solution contains 5 projects.
I am adding a 6th project to replace one of the existing projects to allow for the use of a GUI.
I am getting many compiler C2011 errors regarding type redefinition. In particular, they are 'struct' type redefinitions or '[function]: redefinition; different linkage. They come from the header files ws2def.h and winsock2.h.
I've been searching the entire project and the entire solution for where these are included, but I don't see any #include <ws2def.h> or #include <winsock2.h> statements, nor anything to indicate they are used.
However, there are External Dependencies folders/filters included in both the project I'm replacing, and my new project. Both ws2def.h and WinSock2.h exist in those filters. I wouldn't think that having the same file included in separate projects under one solution would cause these issues. Also, I'm getting these errors when building just my new project, meaning it shouldn't see the old project anyway.
Based on the information I've given, are you able to see where my problem may lie? Is it the case that these header files must be #included somewhere within the project and I'm just not seeing it? I've considered deleting both the header files from the External Dependencies filter because it seems I don't need them. Is there a different, common header file that also includes these header files so that they wouldn't show up in a CTRL-Find?
Thank you.
The issue seems to have mostly been based on the horrible file structure of the original large project.
Trying to create a new project within the solution to replicate another project as a GUI instead of Console project meant that the compilation of the project was doubling up on many files.
I found another post (can't find it right now) that stated that when a Visual Studio solution compiles, all of the project files are combined, much like all the #include statements in a .c/.cpp/.h file really just copy all of those files into the file which #included them.
My solution was to create a copy of the large project (for backup purposes), and in the copied project, remove the original Console project and only include the UI Project. Files are not longer doubling up because they don't exist in both projects anymore, just the one still existing in the solution.

How to use zxing in c++ project?

I'm just started doing things on c++, and I'm interested in barcode reader /writer, so I've chosen zxing for those purpose. Problem is that I don;t know how to use it since it has only .cpp and .h files. I've used opencv and it was easy to join it to my proj cuz it has .lib files. But ZXing does not.
So, can u please explain me, how to use .cpp "libraries" (are they?) in my project (if it isnt hard, do it on zxing example please).
first you need to know if your library needs compilation or no. mostly you need link precompiled libraries to your project and add the path to header files. if it's no, you can simply move your .cpp and .h files to your project directory, in your IDE you add these files to your project and then you use #include with doublequotes. I mean you need to include only header files.

Conversion of header into cpp file using Visual Studio

I have folder contain a Visual Studio project and contain lots of .h and .cpp file I want to put all of this .h and .cpp file into just one main.cpp file is there any way to do that with Visual Studio or any other things??
Depending on the functions and libraries you are using it can/can't be done. if all the functions are compilable in Turbo and the project isn't that professional which I think it isn't based on you saying you want it for your course project you can simply copy everything in a cpp and convert the header files into simple classes. anyway Turbo C++ is Dead!
You cannot do this trivially. You would have to refactor, as merging source files can introduce semantic problems. It's best to not do this at all.

Visual Studio plugin to find out which files are being included implicitly

A particular header file may only be including "Foo.h" but Foo.h is including other headers which implicitly include many other headers. I would like to know all the headers that a particular file is including.
In case anybody is wondering why a plugin for Visual Studio; simply because of the way the include directories are set-up in the project. If an external tool does the job and allows me to specify the locations where it can search for the header files, that will do as well.
I don't know of any plugins that do this, but you could whip up a homebrew solution by turning on the showIncludes flag in your projects settings, then doing a full build and parsing the output. The indentation changes based on the nesting of the includes.
Try out Boost.Wave. It is straight forward to dump all the headers included. They also have an example named list_includes that does exactly that.