How to combine two dependent projects in Visual Studio - visual-studio

I have a solution which has two projects. One is a static link library project, and another is a console project for demo. Now I want to create a MFC project to replace the console project, what should I do to configure the MFC project.
the MFC project need to use some classes in the .lib project.
I have set MFC project as start project and depend on the .lib project.
My platform is win7 + vs2015.
Actually, the solution is EasyPR, you can get it here EasyPR.
Thanks for any help.

Setting the dependency to the static library is one step.
To compile the code you may need headers for the compiler. So the MFC projects may need settings for the compiler to define additional include paths.
You still need to configure the linker to use and find the library. To reference the library you may use a pragma comment lib. In the linker settings you may add an additional path for the libraries.
Or you may simply drag the lib into the solution explorer. The build mechanism will know how to treat a lib and will include it into the build process. The later will only work if you have 1 lib for release and debug.
If you have different libs for release and debug a advise you to use different names. You may adjust the project settings of the MFC program for debug and release differently.

Related

How to link a static library in Visual C++ 2017?

Trying to set up libtins on windows. Im relatively new to Visual studio and most of the documentation on the matter was for older versions. I was able to get the include files set up with the project but linking the .lib's was problematic and i cant seem to configure it properly. The properties menu seems pretty convoluted as im used to doing most things compiler related configurations from a command line.
In the Solution Explorer, right click on the project, select Properties. Expand to Configuration Properties > Linker > Input. Add the .lib file to Additional Dependencies. Do this for both the Release and Debug configuration.
If the static library in question is in fact the output of another visual studio project, you can just add that project to your solution file, and then add a reference to that project, and let VS2017 figure out where the lib files are located, and that the linker needs them.
i.e.
Solution '...' (2 projects)
Lib Consuming Project
References(Lib Producing Project)
Lib Producing Project
hint for creating static libraries from visual studio
for Lib Producing Project, go to Properties
Properties->Configuration Properties->General
and set Configuration Type to static lib (for both debug and release)
for foreign static libs, the accepted answer is AFAIK the proper way to do it.

How to setup a project shared between multiple projects in Visual Studio 2013 while maintaining versions

I have a situation where a class library project is used by multiple other projects in Visual Studio. While working on one project sometimes I may have to make changes in the shared code that is relevant to one of the other libraries. These changes may break something in the other class libraries until the necessary work is done to bring all other in line with the changes in the shared library.
The question is, how do I share the library and reference specific versions in the other projects?
If these libraries are source controlled, then whenever you want to compile a library that depends on your shared library, make sure you checkout the appropriate version of the shared library.
If these are .NET libraries, you could install the different versions of your shared library in your GAC, and have your dependent libraries reference the appropriate version of the .dll directly. Of course, you won't have the advantage of being able to change the shared library within the same solution as your application because it wouldn't be a referenced project.
Alternatively, instead of installing them in the GAC, you could keep a common directory with your versioned shared libraries (see the answer to this post: Visual Studio: Add same project or reference to different solutions).

How can i build project in visual studio 2012 on both way(dll and lib) together

I managed to set up build project in dll mode and in library mode but not together:
for build in dll:
project->properties->Configuration Type: Dynamic Library (.dll)
project->properties->Target Extension: .dll
for build in library:
project->properties->Configuration Type: Static library (.lib)
project->properties->Target Extension: .lib
it is possible to build both of them together?
Yes, you can have single project that can be used for .dll and .lib.
Steps to be followed:
Visual Studio will provide you Debug and Release solution
configurations. Create custom configurations for lib and dll (i.e.
lib-release, dll-release).
For each configuration set different project type and set export
symbols. i.e. for lib-release define LIB_CONFIG and don't set it for
dll-release.
In code file use LIB_CONFIG with #IFDEF to include/exclude project
type specific code. IF some part of code is lib specific the add it
in #ifdef LIB_CONFIG...#endif, and if it is dll specific add it in
#ifndef LIB_CONFIG...#endif.
Compile project after changing Active solution configuration. i.e.
change to lib-release, if you want to have .lib file.
I hope this will help you. Please let me know your feedback.
During creation of new project in Visual Studio, make sure you check on "Export Symbols"
No. You must have two projects in your solution (using the same source files). Don't forget to have different names for your 2 .lib files.
EDIT: use some trick to not include a DllMain function in your static lib (either some #ifdef, or a separate file not added to the static project)

VS2010 C++ how to have different project references for each developer

We are trying to move from C++ VS2005 to VS2010, but can't figure out how to move from the solution dependency model to the MSBuild project reference model. We have multiple developers, but don't distribute all the source to each developer although each developer is provided with all the header files, .lib, and .dll files.
With VS2005, each developer has their own solution and sets up a project dependency to a project, unique to that developer, which includes all the .lib files they don't have source for. This way, they can use the most current .vcproj files for the source they do have.
In trying to move to VS2010 / MSBuild, the project files now require that dependencies be included as references, yet some developers will not have a copy of the referenced project, only its .h and .lib.
Is there any way to combine the solution-based dependency model of VS2005/VS2008 with the MSBuild project reference model of VS2010?
MS removed implicit adding libraries in linker list once dependency added.
Now libs should be explicitly specified in Additional Dependencies of linker settings as well as includes in settings of compiler.

Make Visual Studio not to compile any projects

Is it possible to tell VS not to recompile some projects every time and use already compiled dll-s instead?
You can exclude any project from building in Configuration manager. Just unselect desired projects in Build column. You still will be able to debug those projects.
Instead of project references, you can add the compiled DLLs as references.
Any such referenced project will not rebuild if not changed.
However, since the references will now be to DLLs, you need some strategy to keep them synchronized and up to date with your code.
As I understood your question, you have a solution with multiple projects and you seem to have dependency of some of them on some other.
VS will always compile all the "loaded" projects. But when you add a reference to a project, add it directly to a (preferred) DLL assembly file, and not to one of the projects. This way the other project will be compiled but you are referencing the same DLL assembly over and over. Since if you reference the project, the output of the project is always what you reference actually.

Resources