views:

261

answers:

2

First of all, let me say that I am not a C++ developer. However, 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.

Could someone tell me how to add a reference in unmanaged C++ and work with the class objects? This is an urgent request, as my project deadline is drawing close. Thank you very much for your help!

A: 

Yes. You need to do two things:

  1. #include the respective header files, as you did
  2. 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.

Pavel Radzivilovsky
Thanks for the help. I created a test solution and managed to get the references to work. I created my class library as a "static library (.lib)" and added a reference to the project in my console application. I then added the include directories of the class library to my console project. I then used #include to include the class I wanted to reference and it worked without a problem.I would be happy to post my solution, but I don't see a place on here to attach a file.
Nick Ruiz
A: 

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.

Chris Becke