I've these project inside Visual Studio 2015:
as you can see, they "share" the same classes (.cpp/.h). If I edit it inside DefaultProject-app, automatically it change within DefaultProject-vst2.
Now, I want to make a new class, and I want the same for it. So right click to DefaultProject-app->Add->Class. But once I create it, it place only in DefaultProject-app. It should be in both project, and compile when I compile one of the other.
How can I do it? Somethings like "Build Phases" in Xcode?
If you have classes that are used by more than one project, the best approach is to create a new third project that both DefaultProject-app and DefaultProject-vst2 can both reference. This is one of the foundations of programming: a library with common classes and functions.
Related
there is a possibility to add an existing project as a "reference" to a solution in VS(talking about C++ now). As far as I understand it means that all the project files will be added to a solution and I can modify any properties and source code, and it will affect the original solution to which this project belongs. Do I have a correct understanding of it? Or is it something else?
I don't really get why we need it, if I need another project I can use it as a lib or DLL file, this reference thing seems to make things more complicated - if I do any changes to project properties I need to think how it will affect building another solution this project belongs to.
In Visual C++ "project-to-project" references within a solution really does two things:
If the referenced project is a static or DLL library, it's implicitly included in your referencing project's link statement.
The referenced project is considered a build-dependency for the referencing project so it will be built first.
That's pretty much it. If you want to include headers in the referenced project, you need to add it your AdditionalIncludes property for the referencing project.
For a DLL project, you can set a property on it to get it's DLL copied to your referencing project's build directory.
See Visual C++ Team Blog which was back in VS 2010 when it was first introduced.
There's a different model of code sharing called Shared Projects where the shared code is built in each referencing project--i.e. there's no shared binaries.
I'm working on a utility (for practice) that has two tools that a user can run.
I want to know if there's an outer layer within a solution where I can build classes that are recognized by all projects of said solution.
I'm at the point where both tools are finished and I want to add the two projects to one solution. However, these tools can share a few non-static classes and I really want to avoid having multiple of the same .cpp/.h files for each project so if I need to edit or add to a shared class, I don't have to copy/paste the edits into each project.
I tried using resource files, but they won't add .h or .cpp files. I tried adding the classes to their own project and then using them as references in the other projects, but the classes within the other projects won't recognize them. I also looked around at creating a library, but I'm not sure if it's possible to create non-static libraries as these projects will have multiple objects of the shared classes.
I'm very visual and I'm not sure if I explained my issue well so here's a simple diagram of what I want. Each arrow shows who each project can "be aware of" so-to-speak (conceptually similar to class inheritance). The bold First Project is the solution's entrance; essentially just where the user specifies which tool to run.
From what you described a class library would be the solution. This would allow you to share your two classes between both projects. In C++ there are two types of class libraries the Static Link Library and the Dynamic Link Library.
Here is a nice answer from a previous StackOverflow question which should aid you in determining which type of class library to use.
I have also included two separate links from Microsoft, since you tagged your post with Visual Studio, on how to create and use a library of each type.
MSDN: Static Link Library Tutorial
MSDN: Dynamic Link Library Tutorial
I want to use Xcode for C/C++ project.
I don't care about build/compilation, all i want is to use it as editor.
Needs:
- Find symobol , References , callers etc
I've opened a console project, i can search for a symbol in the same file but nothing else. (for example, right click + jump to definition gives me a question mark ('?').
Any pointer to what needs to be done ?
Thanks,
Shaul.
From my experience, XCode is not designed to work well with C++. For example, you'll find that simple refactoring, such as renaming a function and automatically renaming usages, doesn't work well with XCode. I find AppCode works a lot better for (Obj)C++ development. Worth a look.
Thare are two approches
You need to create a library of your c++ project and add that library in your project
Add C++ project in your xcode and make it build as target source
let me now if you need a walkthrough
Ok, I found the solution.
When adding files to the Xcode project, on the bottom , need to click 'Options' and then choose 'Create groups' instead 'Create folder references'
This options will add all the sources and headers to 'Compile sources' and 'Headers' (Under 'Build Phases')
I am working on a game engine project in C++ with VS2010. We have one main project, OgreProject, which includes some Ogre3D stuff for rendering. Then, we have a class library project called AudioLibrary. AudioLibrary uses fmod, and has includes to the appropriate headers and libs. The problem arises when a class in OgreProject wants to use the SoundPlayer.h in AudioLibrary. Then, OgreProject does not know where #include is. It feels wrong to tell OgreProject where fmod is, since it will not directly use these headers. What is the correct way to using header files from AudioLibrary in OgreProject, without OgreProject knowing of ?
There is no correct way. There's no magical way for one library to know about the other library; you'd have to configure them to do that. If you put them in the same solution you can add one project to another as a project reference.
You might try the Pimpl idiom (or pattern).
It will let you remove everything related to fmod from your project's header file. Only the implementation files will need the fmod headers, not client projects.
See this answer which explains the benefits.
You should probably define a heirarchy for all the components of your project and keep all the header files from a particular component which other components are going to use at a pre-defined place. Other components can then always look at this place. There is nothing wrong in telling the components where to look for these dependencies explicitly
I am working on a neural network project that requires me to work with C++. I am working with the Flood Neural Network library. I am trying to use a neural network library in an unmanaged C++ project that I am developing. My goal is to create an instance of a class object within the Flood library from within another project.
There is plenty of documentation online regarding how to reference an unmanaged C++ project from within a C# project, but there is not enough information on how to reference one C++ project within another. Similar to how I would do it in C#, I added the Flood project as a reference in my other project, but I have tried all sorts of techniques to work with the object. I have attempted to use the #include directive to reference the header file, but that gives me errors stating that I need to implement the methods declared in the header file.
How to add a reference in unmanaged C++ and work with the class objects?
Yes. You need to do two things:
#include the respective header files, as you did
Add a reference (Visual C++ supports two types, "dependencies" which are outdated and should not be used anymore, and "references" which are the correct ones). Use them to reference the other project, which must be a part of your solution. Meaning, in this case you must be able to COMPILE the other project.
Alternatively, if you do not have the source code, or you do not wish to compile the 3rd-party code for any other reason, you may also reference a compiled binary. The best way to do it is pragma comment lib. If this is what you need, please comment and I will edit my response.
Looking at the provided vcproj file, the flood distribution is really weird, and builds an exe file.
As such, the supported way to use Flood in your own project is not via two projects (being your application and a "libflood" project) - But simply to add all the flood cpp files to your own project and build that.