I have a c++ project developed in visual studio. The project which is currently .exe depends on external libs (xerces c++ and system C libraries). I now need to create a dll file (taking into account all the external libraries if possible).
Is there a way to convert the existing project into a dll (a tool) ?
If I need to create a dll project from the scratch (which is crazy cos the project is large :( ) what happens to the external libs - i.e. will a user need
to configure those lib before using my dll?
Thanks guyz for your help
You can change the Configuration Type in the General page of the project properties. Select Dynamic Library (.dll). The library projects can be consumed as before.
If you need to keep the .EXE project you have to make copy, of course.
Related
I am creating a C++ shared library and targeting multiple platforms (Android, iOS and Windows). Usually, I use this step to the create the shared library. I first create a Console DLL Windows library project which creates dll share library I can use for testing on Windows.
The problem is that when I want to build the project to generate Android and iOS shared libraries, I have to create a new project then select "Dynamic Shard Library (Android)" and "Dynamic Shard Library (iOS)" and then manually copy the existing C++ header and source files to that new Project. I basically have to create new project for each platform. After this, I have to change some settings to match the settings from the original C++ Windows project.
This is tiresome and I can't continue to do it like this.
Is there a way to add more target platforms to an existing project without creating new project? I just want to be able to change the platform then build the project from one project only. Is this possible?
I thought if you compile a Visual-studio 2013 Win32 project using /MT Code Generation->Runtime library then it will automatically package all dependency dll's - including 3rd party dll's - into the executable?
Currently certain users get an error when running my .exe. Its related to not having a 3rd party dll (OpenSSL):
The program can't start because LIBEAY32.dll is missing from your computer
This error has occurred for users using my .exe on Windows 10 OS's. How can I ensure all dependency dll's are packaged into my .exe?
I currently compile my application on my 64bit Windows 8.1 OS. The win32 visual-studio project is compiled using the following project properties:
Character Set: Unicode char set
Use of MFC: Use standard windows libraries
Whole Program Optimisation: Use Link Time Code Generation
Debug info format: none
Code Generation->Runtime library: /MT
/MT indicates that you are using multithread, static version of the run-time library. This doesn't affect third party dependency, e.g. OpenSSL is still linked dynamically.
To check your dll's dependency I prefer Dependency Walker tool. It will show if some of dependency is missed.
To ensure all dependency linked into your .exe file use static linking for all your third party dependency, e.g. for OpenSSL you should use libeay32MT.lib library.
Nikita is right, use Dependency Walker and I'd add that you're missing some knowledge about what a DLL really is. No offence meant, I know dlls can be a pita. What is a DLL?
By definition a DLL is not included in your .exe but it is loaded at runtime and could be shared amongst several applications. If you want to include it in your .exe it will require some extra non trivial work to embed them into your exe, unpack and load at runtime.
See this post
I'd suggest to use an installer instead, much easier to handle! Just create an installer (you know the click click click "yes-yes-I agree-Ok-Done" wizard installer) that will include your .exe and all needed dependency files. As a reference Inno setup is quite great.
Is there any way to compile existant projects written in vc++ and libraries such as ITK or OpenCV into DLL files ? The purpose here is to call the functions implemented in these subprojects in a final software, using simple DLL files, instead of gathering tens of header and source files from different modules with DLLs and .lib files of the used libraries. So what are the steps I need to make to obtain the DLLs, and how should I interface the functions (the main functions also) of each subproject (module) in order to make them convenient for use in my final project ?
Thanks.
Make your existing project as dll project by changing the target format. or create a fresh dll project.
add existing dll in your target folder and lib as dependent input file in linker section of propeties of project.
3.You want to bundle all your dlls and libs into single dll or lib then you have download source code of each dependent and add in single project and build it as your own dll.
I've created a Static Library (no mfc is used in it) in Visual Studio and want to link with it in statically linked mfc project (com-dll actually).
When linking mfc-lib I get a bunch of messages symbol is already defined. This is because I linked standard C++ library twice (once in static library, and other in mfc project).
How do I fix it?
There is a workaround with /FORCE:MULTIPLE, but I think this is a bad decision.
When linking static libraries to a DLL or EXE project, you need to take care, that all projects have been compiled to use the same runtime library. So please set all projects to the same "Use of MFC" and also to the same "Runtime library". If you do not do so, then one project might have been compiled to take the fopen function from the standard CRT while another project might have been compiled to take the fopen function from the MFC. Mixing these is a problem for the linker because he does not know which runtime (and in the example: which fopen) to use.
When linking your DLL or EXE project against another DLL project, this is not a problem. You can have a DLL without MFC usage and link your MFC EXE against that DLL.
If you have a util library that you use very often in different projects, then you might consider setting up different build settings so you can build your library in DEBUG and RELEASE and with and without MFC. Then in your EXE project you can pick the library binary that matches your project settings.
Using Visual Studio 2010 C++. I have a project which uses MFC and I am statically linking to MFC. I am in the process of trying to extract the non-GUI functionality into a separate static library project. Because I want to use CStrings in my library project (debatable whether I should, but for the sake of argument) I now need to reference MFC in both my library and my exe projects.
My question is if I statically link with MFC in my library project and in my exe project, will I effectively have two copies of MFC linked in my final exe? What if I added a third project so I had multiple libraries referencing mfc? That sounds bad but I'm not sure how to get around it.
You don't need to link a library project, so there won't be an extra copy of MFC being linked in. You'll be creating a dependency on the MFC library from your static library, but that's normal. As long as the .exe project includes both libraries, everything will come out all right in the end.