I am working on a multi-solution project on VS 2013 in C (I must use C for this project). I implemented one "Common" project that I intended to use as a reference in another project. So I have one solution with a common.h and a matching common.c source in which I implemented all the common functions.
I now created a new "Application" project (inside the current one, so I now have 2 solutions) which does many things, and use the functions that are already implemented in the common.c file (that is in the "Common" solution). So I have a app.h file with a matching app.c source. I changed the settings so that the "Application" project will include the "Common" project.
However, when I run the "Application" solution (only it since the "Common" project is only used as a reference without a main function) I receive an error telling me that there is no reference to the functions in common.h.
I looked online for a solution and someone said that I should just copy the common.c to my "Application" project, however this is a very bad solution for me since I want to have multiple applications that all of them use the "Common" project.
How can I solve it?
You shouldn't have to copy any files to make this work. Right-click on your solution at the top of the Solution Explorer window. Choose Add -> Existing Project from the context menu. Find the project file for your "Common" project. It should show up in the list of projects for your solution.
Right-click your "Application" project in the solution explorer and choose "Properties" from the context menu. In the property pages window, go to "Common Properties". Click the "Add New Reference..." button. In the "Add Reference" window, go to the "Solution" tab, and then click the checkbox for your "Common" project. Click "Ok".
Now your "Application" project has a reference to your "Common" project. You can also open common.c and common.h from inside your new solution, and any changes will automatically be applied to all other solutions that reference it, because they are the original files and not mere copies.
The above method assumes that the output of your Common project is a DLL. Visual Studio (for whatever reason) won't automatically copy statically linked library (.lib) files. You can of course link against them, but adding a reference won't work. You will need to go to the properties page for your "Application" project, go to the linker -> input tab, and edit the Additional Dependencies line. You can also add the directory containing common.h to your Additional Include Directories under the C/C++ tab.
Either way, my opinion is that merely copying the files is a bad idea unless you're using modules in source control (e.g. Git modules or SVN externals) to manage dependencies.
Related
I am trying to publish a WPF application using the publish section in the project properties. When I attempt to specify application files (i.e. references) for the publish, I see lots of old dlls that were once in the project but were deleted later.
Is there a way to clean up this list so that it matches the references actually used in the project ?
It is not possible without extensions. However you can check this question for more details. There are also some extensions listed you could use.
I want to use a DLL written in C in a VB project such that the DLL will be copied to the output directory.
I earlier asked this question here and got an excellent answer:
VB.Net using C DLL
All you have to do is go to the Project menu and "Add Existing Item". This works great if you copy any updates to your DLL into the project folder. Now I have a new project, and I put my C project folder inside the Visual Basic project folder in hopes that Visual Basic would fetch the DLL from that folder and copy it to the output directory. Oh no, they would never make it that easy. Adding an existing item copies that file to the project folder. So now it always fetches an old copy of the DLL unless I manually fix this, which I do not want to. How can I make Visual Basic honor my wishes?
When you do the "Add Existing Item..." the Add button has two options, one that will add a Link to an existing file and not copy to your project, but it will copy to the build output.
What is the best way to put a DLL written in C into a VB.NET (Express Edition 2010) project? I have the declarations for the external functions locating absolute paths right now like so:
C:\Users\Kyle\Documents\Pelles C Projects\ROBOLIB\ROBOLIB.dll
Because Visual Basic creates so many different directories the program could be running from (Debug, Release, Publish). Is there any way I could tell VB.NET to some files into the program's directory? Or should I somehow customize the installer so it puts the DLLs I need in a specific location?
You can add the DLL to your project (either per Drag'n'Drop or right mouse click -> Add -> Existing Element). If you right click the file and choose properties, you can define "Copy to output directory".
Of course, you should ensure that the installer (in case you create one) copies the files.
I am using VS2010, When you create a new project, you can choose from ConsoleApplication, WindowsFormsApplication, WindowsService, etc. There's also Empty Project.
The empty project contains a reference folder without any references. What is the use of this Empty Project? Is it use for any test?
The “empty project” is used when you wish to create a project that does not have any files or reference automatically added to it.
Sometimes visual studio concept of being helpful is not what you want, and you just wish to be able to define a project to include only what you decide to put in it. This is not directly related to using a project for tests, but may be helpful when you are using a test framework that is not supported by any of the project templates.
I have a Silverlight project with lots of source files. Now I want to create a new WP7 project using the same source code files (but obviously, target WP7).
I link the WP7 project to the existing Silverlight project using Project Linker. However, this does not automatically generate links to the existing files in the source project.
Is there any way using Project Linker to automatically populate the destination project with the already existing files in the source project? Or do I manually have to add links in the WP7 project to all previously existing files in the source project?
I have the same problem, but I resolved it.
Simply exclude all files from "source" project and then re-include them.
In this way project linker refresh its references adding all links!
It worked for me!
I'm not quite sure what you but I think you'll have to do manually in VS.Net, but if all the files in the same directory you can add all the files in one go, it sounds as though you want to select the 'Add as Link' option once the add 'Existing items' dialog is displayed.