I am developing Windows code in C using Visual Studio 2010.
I am working on several related projects: a static library, a DLL, and an executable. The DLL should have the static library linked in, and the executable depends on the DLL. (I am using "implicit" DLL linking; I do not need to control the DLL loading and unloading.)
Right now I have three separate VS2010 projects, but I know it is possible to set things up as "subprojects": the static library should be a subproject of the DLL, and the DLL should be a subproject of the EXE.
I want to solve the following:
When I rebuild the EXE, it should rebuild the DLL if need be, and in turn the DLL build should rebuild the static library if need be. I'd like to just have the EXE open, hit the F7 key, and everything builds.
When I rebuild the EXE as Debug, it should link with the Debug .lib file from the DLL; likewise when I rebuild the EXE as Release, it should link with the Release .lib file from the DLL. If I set up the subprojects correctly, will this Just Work automatically?
EDIT: I have made progress. First, in the DLL project, I used File / Add and then chose Add Existing Project to add the static library. (This is only available on the File menu as far as I can tell! It definitely is not in the right-click menu.) Second, I clicked on the DLL project in the "Solution Explorer" sidebar on the left, then right-clicked and chose Project Dependencies... and set that the DLL project depends on the static library project, which should build first. Visual Studio seems to have then magically set up the link dependency for me, and when I hit the F7 key in the DLL project, it will build the static library project.
I tried repeating the above steps for the EXE project. Now it will build the DLL, but it isn't linking things correctly yet; the linker is complaining that the functions exported from the DLL are not available.
You can't really have 'sub-projects', but you can have multiple projects in a solution. Then you can mark their dependencies on each other by opening the "Project | Project Dependencies..." menu item.
You can also make a 'stronger' dependency between some projects by having one reference another one (from the "Project | References..." menu item). For example, if an application project references a library project, that library will be automatically be linked to the application.
I have it working. Here are the steps I used to make it work:
Choose File / Add / Existing Project... and navigate to the other project that you want as a subproject. Choose the .vcxproj file and okay the dialog. You have just added a project as a subproject.
Right-click on the main project in the "Solution Explorer" sidebar pane on the left, and choose Project Dependencies... Click on the subproject to make it a dependency of the main project, then okay the dialog. This is a tabbed dialog, and the other tab is "Build Order"; if you click on that you can make sure that Visual Studio will build the subproject first and then build the main project. You have now set things up so that the subproject builds first, then the main project.
Right-click on the main project in the "Solution Explorer" sidebar pane on the left, and choose References... In the references dialog, click on the Add New Reference... button. Make the main project reference the sub-project and okay it. You have now set things so that the linker will link the output file of the sub-project.
I performed the above steps to make the DLL project have the static library project as a subproject, and I again performed these steps to make the EXE project have the DLL project as a subproject. But I got build errors about the static library file not being found. So I think that, even though I set the static library as a subproject of the DLL library, it is essential to set up that dependency within the EXE project; the dependencies don't seem to be transitive! I performed the above steps to make it clear that the static library is a subproject of the DLL subproject of the EXE project, and that fixed things.
Now when I hit the F7 key, everything builds. If I choose Build / Clean Solution it cleans all three projects. When it links, it gets the Debug or Release library files as appropriate and links them in.
Sometimes when I hit F7 and build, the build fails, saying that the dependent library is outdated; but if I just hit F7 again then Visual Studio rebuilds the dependent library and the build succeeds. If I hit Ctrl+Alt+F7 to force a clean build, the build succeeds every time. I don't know why Visual Studio has this quirk.
Related
I've built a small desktop application with which I am trying to use a Setup project to allow other users to install it. But whenever I run this installer, it does not produce an executable file. This is my first time making a setup project.
My solution contains two projects. One is the setup project which installs the primary output from the other project. The other project is a WPF App that consists of two xaml files, a xaml.cs file for each, an App.config file, and an icon. It also has a few dependencies including one Assembly, two Frameworks, and a handful of Packages. The app works exactly as intended whenever I start a Visual Studio debugging instance on either Debug or Release configurations.
I followed these instructions to build my Setup and deploy my app.
Whenever I ran the resulting Setup, it installed an XML configuration file, a JSON file, a main application dll file, and a bunch of dll files for my assemblies. I looked into some resources on how to run the main dll file properly, only (A) I'm completely stumped by everything I find on that topic, and (B) I would rather just produce an executable file anyway, since I intend for this Setup project to be used by other people and it would be inconvenient to ask said others to jump through the same hoops just to run it.
Why does my Setup project not produce a .exe file? I see that a .exe file is produced in my bin folder whenever I build my project (and this .exe works), so I would think the setup project should also produce one of those, but it doesn't. What am I doing wrong with my Setup project or anything else?
The setup.exe is a bootstrapper over the setup.msi. We can install the content using .msi or by running .exe which inturn runs /gets the data from the msi. To enable setup.exe building, go to solution explorer -> project -> properties -> prerequisites. check the check box on the top "Create setup program to install prerequisite components". apply and rebuld the project. A setup.exe bootstrapper will be created allong with msi.
Switch to Release mode, then rebuild your setup project. If everything went well (check the output console), you'll find an MSI file inside {setup project folder}/bin/Release
In "system file" from your proyect installer, you shoud to add in "Application Folder" the next source = PublishItemsOutpuGroup. In my case functions well.
I can't navigate through a project in Eclipse (Oxygen.3a Release (4.7.3a) with CDT version 9.4.3.201802261533). The project is built successfully but I can't trace back many functions using ctrl+LMclick.
I tried fixing the problem from online resources, but many suggested modifying the entry of Preprocessor Include Paths, Macros etc, which my project does not even have. What is the reason behind this and how do I fix it?
For some reason, the next entry (C/C++ Include Paths and Symbols) shows that |Include path not found"
When I try to trace a function, I get the "Could not find symbol "xyz" in index". I have already tried rebuilding the indexer but it did not work for me.
In my experience, the absence of the Preprocessor Include Paths, Macros etc. preference page happens in newer versions of CDT when you select the new Makefile Project option in the new project wizard, whose description is
(Experimental) Create a new project that builds with the 'make' build
tool using CDT's new Core Build System.
I would avoid using this as it's experimental, and would select instead C Managed Build (or C++ Managed Build). On the next wizard page you can still make it a makefile project if you want.
I ran into this problem trying to use cmake4eclipse. I forgot to heed the warning in the help file, which explicitly state:
"Do not choose the New C/C++ project wizard, as that will take you down the road of CDT`s new project type (which has poor cmake support)."
What this means is that, for the entry to appear in an executable / library -type project (not Makefile project), you have to do this now:
File --> New --> Other...
Choose "C++ Project" (not "C/C++
Project") under the C/C++ category:
P.S. Also, I had to remake the folder and copy all the sources there, i.e. when I tried the old wizard on top of a "deleted" project, something didn't override correctly and I was still missing "Preprocessor Include Paths, ...". Deleting .cproject and .project files within the folder before recreating works too.
Depending on your project, you may need to include the path of the toolchain manually. It wasn't for me. So for my project I did the following:
Go to Project – Properties – C/C++ Include Paths and add there “C:\Program Files (x86)\GNU Tools ARM Embedded\5.4 2016q3\arm-none-eabi\include” (change to fit your installation). Then refresh, clean and build the project. Finally, rebuild the indexer and this should work.
I have the source from an Eclipse project, and I need to import all of the build settings as well as the source into a new project so I can make some changes. The trouble is, when I go to build the project, Eclipse is calling the internal builder and NOT calling the Makefile from the previous project (which I have imported). The makefile contains some values in #define statements that need to be passed in on the command line.
When I go to change these options in Eclipse (by right clicking on the project and going down to "Properties" and then examining the "C/C++ Build" tab) they are grayed out!
If someone could help me out I'd greatly appreciate it.
Thanks all!
There is a folder called ".settings" under your project, copy this (and everything under it) to your new project, this is where all of the settings are stored. To see the folder, you may need to use the view menu (upside down triangle) in the Package or Project Explorer and remove the filter on the ".resources". For Package Explorer select the "Filters", in Project Explorer use "Customize View"
I have a project which I try to compile with Eclipse-CDT. The project depends on a library with header files and source files. How can I configure the project in Eclipse such that it will compile the needed source files from the library with the project?
With a makefile I use:
SRC+=lib_source.c
You can add linked source file.
Choose project properties and in the left panel choose c++ general.
Under it choose path and symbols.
Now in the right panel tabs choose source location and add linked source folder.
Include you need to define in "include" (under c++ build you will find settings)
Another approach is to use the operating system to add your libraries to the project. Eclipse then treats all source files (including library files) as part of the project, and therefore compiles any that need it even if they are in the libraries. This set-up allows keeping the library sources in a separate git repository from the project source code. You can record the git commit of a library to provide library version control so that improving the library in one project does not break all the others. The setup relies on the operating system's capability to link directories in a way that is entirely transparent to eclipse--in windows using the mklink command.
In windows the steps are
put your library files in a clean workspace not mixed with .git (you can have .git in the parent directory as egit sets it up)
use cmd window in administrator mode to add a link from your project directory to your library directory.
from eclipse press F5 t make sure your project matches what is on disk, then set up git to ignore your library directory.
set up your library file properties for read only access unless you are still tweaking that library.
set up your project include path to include the project sub-directory in your project.
I can't remember why I abandoned eclipse linked directories; i think it was that the includes kept breaking. The mklink approach has worked flawlessly so far.
I have a pdf tutorial of how to set this up--but I'm new to the forum and don't see how to attach a file.
How do I share files between WPF and Silverlight projects in Visual Studio 2010?
You can download Project Linker for Visual Studio 2010 in the Extension Manager. Just search for "Project Linker". It works perfectly!
The project linker download can be found here at the bottom of the page in the "Files in this Download" section:
http://www.microsoft.com/downloads/details.aspx?familyid=fa07e1ce-ca3f-4b9b-a21b-e3fa10d013dd&displaylang=en
And just in case you were also asking about its usage, here is a link to the usage information:
http://msdn.microsoft.com/en-us/library/dd458870.aspx
It doesn't appear to have been released as a self installer for VS2010. However, the code does appear to have been updated to allow the plugin to run in VS2010.
Have a look at this discusson thread. About two thirds of the way down the tread, it gets to the point where they give that link and discuss the steps for making it work. Here is the link to the source code updated for VS2010.
The steps to use the code to generate an installer that will work for you are (ripped from the linked thread):
open solution in vs2010
compile as release
add a new VSIX project (template located under c#>Extensibility).
In the VSIX project you need to add two "content" items
- a "VS Package type" as the output of the project linker project,
- a "Custom Extension" Type - as a file and browse to the compiled project linker helper dll
HTH