How to add a library in C++? - c++

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

Related

Add external library into current c++ project

I'm trying to use the xgboost library to basically translate a model I developed in R to C++.
I've not used an external library and other sources online did not help me much so decided to ask the question here to hopefully find the way to do it.
Here's the library I need to use in my C++ code: https://github.com/dmlc/xgboost
I'm using Visual Studio Ultimate 2013. I have a make file that I use to define my project.
I am looking for the proper way to use this library in my C++ code.
If you have ever used this library before, I really appreciate your help. Any hint will be appreciated.
To use the library, one needs to first build it. I could not manage to build the master branch. So, I decided to use the V0.4 instead. I built the solution in that branch using Visual Studio and it produced the dll and lib files. One can then import the .dll file by using Add_library to add it via Cmake. After Add_library, the include directories need to be added by include_directories command.
I need to generate .a and .so files in the end. I'm working in windows and could not find a way to generate these files, yet!
So I found the way to resolve this issue. I shared it in another answer
Add an external library (e.g., Eigen) via CMake
Hope this helps people who are looking!

How to compile or use a library that downloaded online

I am unfamiliar with C++ but I got a project that needed to deal with it.
I need to use a library available online, RtAudio, and of course I need to
import it in my program.
My question is, how do I use/do it?
Here is my understanding on the library, I am sure that I am totally wrong, but
just to tell where I am.
I think i cannot use the file that I download directly but change it to a lib file and a dll file (as I have use some other precompile library before and it only require a dll and lib file[.h too of course]; I know how to put these into MSVC 2015 and use it).
And also I think in order to compile the library into dll and lib file I need to do something with the follow file in the cmd in window: configure, install, and makefile.in
I am desperate as I had already given up using another library before as I do not know how to deal with this, therefore it will be nice that if anyone can give any help. Thanks.

How to create a .dylib of a full C++ project?

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!

run-time error "boost_log-vc100-mt-1_49.dll"

this may sound like a silly question, but it would be really useful if there was a way around this.
I am writing a c++ code using microsoft visual which uses eigen, matlab, and ilog cplex libraries. It can be build without problem but there is a run time error as follow:
[Translated]
impossible to start the program because it lacks "boost_log-vc100-mt-1_49.dll".
Try reinstalling the programe for courriger this problem.
6 months ago I tried to use boost library but I gave up. After I deleted all dependencies to boost and I used Eigen without any problem. Even I can not run previous versions of my code now! Maybe I deleted a file some where?
Moreover, I tried my code on another machine and the error is the same. So, it looks it's not a system error.
I appreciate any advice you may have.
Thank you.
It's solved!
Matlab has some boost libraries and the link between MSV and matlab was not working though it was mentioned in linker. I copied those dll files to the current folder and now it is working.

How to call Matlab functions from Visual studio mfc project?

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().