What I have done is following the guidline in this
website
Now, I want to use some functions like rgb2gray() and imresize()... but I dont know how to use them, or I dont know which header file should I include in my project?
I have tried other way by creating a C++ shared-library in Matlab, then used it in VS 2012, but I could not add the DLL file to my project when I added new references. it is like that:
Please help me!
thanks in advance.
If you really want to call Matlab inside visual-studio, there are two ways:
Distribute MATLAB into independent shared library: check out my blog-post on how to do this (with detail steps and example).
Call MATLAB Engine directly: Refer to another blog of mine for more info.
On the other hand, it seems that you don't need to call Matlab to achieve your goal. OpenCV library will offer functions similar to rgb2gray() and imresize().
Related
I am trying to make my own libraries that I can use in future projects. My issue is that the tutorials I find and understand all tell me to create my new project in the solution that my library resides in. This is what I find weird.
My knowledge tells me that a library is supposed to house reusable code and will be used with different projects. Having to force my project to the same solution as my library to use it seems odd and how would it then work if I had to use two different libraries that I have made? I feel like I have missed something obvious.
After searching I have stumbled across something called external libraries, but the only useful thing I understood from this is that "this might be the key".
My question is: How can I create multiple libraries that I can use one or more of in different projects? Or have I misunderstood something crucial and what I am looking for is entirely different? If so, how and where should I create one or more files with reusable code meant to be used across different projects?
This might seem like a no-brainer type of question and I agree! But my googling skills are not up to par to find a solution. Thank you and sorry for using your time.
I am using Visual Studio 2012.
Example of tutorial: https://msdn.microsoft.com/en-us/library/ms235627.aspx
On a C++ Win32 Console App project there is an option on the new project wizard to create a library.
Create your libraries in a single solution and add a post build step to copy them to a "central folder".
In you code that uses the libraries add an include path to your "Central folder"
Add a reference to the library in the project properties, like you would if you were including a windows or boost library.
I have a project written in C++ and I want to call some functions of it from Maple. Searching about possible solutions, I found the one to create .dylib from the C++ files and then call this .dylib from Maple.
I was able to create a .dylib from a single C++ file and use its functions from Maple, following this: How do I create a dynamic library (dylib) with Xcode?
Now, I'm wondering if I can do it with a full project. I saw that maybe I could do it using Xcode (I have the version 6.4), but I don't know how...
Someone could help me? Any help is appreciate, thank you in advance!
I'm trying to write my first game in c++, and I want it to dynamically load everything from files. This includes the enemies, and I was wondering if there was a way to dynamically include their code at runtime, instead of linking the on compile, so that the levels are easily interchangeable. Lua might be an option but I have no clue where to start, and dll seems to be Windows-only (and I wouldn't know where to start there anyway). Can anyone help with this?
tl;dr I want to link in code to my c++ game at runtime.
For the Lua approach you first need to choose the version first. Right now there is the major version 5.1 and 5.2. My previous work was using 5.1 and for my new project I decided to update to 5.2, however I found that my favorite script wrapping tool (SWIG) does not work with 5.2. Just something to decide at the beginning, because you do not want to get a version working and then have to change it.
Lua comes with makefile build environment. My first experience of trying to build on Windows was a bit of a nightmare, did not appear to just run out-of-the-box, so I opted to create my own Visual Studio project at the time, and just include all the .C files in the project. There are two files which need to selectively included/excluded depending on how you intend to compile: lua.c and luac.c. If you are planning to embed Lua in your app, then exclude both of these files; they both contain a main() function and are designed to build console apps. Include all the rest of the C files in your project.
You should be able to compile easy from this point.
When you include the headers of Lua, keep in mind that the functions are C functions so if you are including them from C++ you need to wrap the file inclusion inside of: extern "C" {} - example: C++ Lua 5.1 Issue
Wrapping your interfaces in another topic and there are lots of resources available. My favorite is SWIG but there are lots of options, including hand coding the conversion of your C/C++ -> LUA -> C/C++ code. Would recommend just focusing on getting the first part working first, get the interpreter embedded so that you can run a "hello, world!" script from Lua inside your app.
So going by your requirement of crossplatform use and dynamic linking, what you're probably looking for is an environment like QT which has QLibrary: https://stackoverflow.com/a/9675063/453673
But https://softwareengineering.stackexchange.com/questions/88685/why-arent-more-desktop-apps-written-with-qt
MingW is the open-source equivalent for Visual C++, so it can help you writing code for Windows (though if I had a choice, I'd directly use Visual C++). The way dll's are loaded in Windows is somewhat similar to the way they're loaded in Linux, so you'll be able to write code with #ifdef's to do conditional compilation. I've written one such program a couple of years back.
To load a shared library(always with .so as suffix) under Linux, you could use dlopen(), dlsym() and dlclose()
Iam new to C++ and I am trying to add NLopt library to C++ using VS 2013. NLopt is a non-linear optimization library (http://ab-initio.mit.edu/wiki/index.php/NLopt_C-plus-plus_Reference#Compiling_and_linking_your_program_to_NLopt). NLopt has a DLL file and .h file and I cannot figure out a way to get them work. I appreciate if anyone can give me a quick guide on how to import this library.
Thank you in advance.
Here's what you'd want to go through: DLLs in Visual C++ - http://msdn.microsoft.com/en-us/library/1ez7dh12.aspx
More specifically, gauging from your question you are probably looking for Implicit Linking - http://msdn.microsoft.com/en-us/library/d14wsce5.aspx
And if all of that sounds confusing to you, you might go through this walk-through first: http://msdn.microsoft.com/en-us/library/vstudio/ms235636.aspx
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