I want to do collision detection in MATLAB. In MATLAB its possible to include a shared library written in C with
loadlibrary();
I found a collision detection library written in C:
https://github.com/danfis/libccd
The documentary says that
mkdir build && cd build
cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON ..
make && make install
build libccd as a shared library. After execute these commands in terminal I get a libccd.dylib. Thats what I need for MATLAB...
loadlibrary('libccd');
But MATLAB wants a header file (or more than one) in addition to the shared library.
https://www.mathworks.com/help/matlab/ref/loadlibrary.html
So I added the ccd.h file to the loadlibrary command. Then the problem is that ccd.h includes another header file but in an under folder: ccd/vec3.h
It seems that MATLAB has a problem with this.
So my questions are:
I don't know if the ccd.h file is the correct file to link first. Which one should I use?
How to resolve the problem that MATLAB can not find a file in another path
I don't know what
mkdir build && cd build
cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON ..
make && make install
does. Maybe I should build a shared library my own. But I am not a programmer and never worked with Cmake, Makefiles and so on.
Thanks for every help
I think you need to use the 'addheader'option to loadlibrary.
loadlibrary('libccd', 'ccd.h', 'addheader', 'ccd/vec3')
Rinse and repeat for all the headers it needs.
Related
I'm a complete beginner at Eigen, including headers and coding in general. I tried installing Eigen's libraries to do some stuff in Visual Studio Code but I can't find the solution, or rather I don't understand what the answers mean.
I have downloaded the zip from the site but don't know what to do with it. My main question is, should you not be able to see the definition to #include <eigen3/Eigen/Dense> in vscode? Because I can't and I don't understand if I'm supposed to.
I hear many of the answers say "Eigen c++ is a header only library: you don't have to install it, you just download it, unzip it and link your code against it." so does that mean i need to place the Eigen/Dense files in the default include? Because when I do I can't find them when I right click on /Dense> in the include code. Do I include them in my environment variables?
1. Download Eigen
$ wget -O Eigen.zip https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.zip
2. Extract and copy to /usr/local/include
$ unzip Eigen.zip # it has unzipped into the library called eigen-3.4.0
$ sudo cp -r eigen-3.4.0/Eigen /usr/local/include
Now you can compile your source files
You need to add the directory to which you copied Eigen to the include path of your project. After this #include<Eigen/Dense> should work.
Please google "visual C++ add directory to include path" to see how this is done.
I am trying to install Matlab on Manjaro, but after I run the script "install", I got error: ...Downloads/matlab_R2020a_glnxa64/bin/glnxa64/libexpat.so.1: file too short
Does anyone know how can I fix it?
Use root as the ID for the Matlab. Otherwise, the key recognition may cause errors.
From the matlab aur package:
Maybe you'd create this archive like this:
1) download the matlab installer form themathworks, let's imagine that file is ~/Downloads/matlab_R2019b_glnxa64.zip
2) extract it: unzip ~/Downloads/matlab_R2019b_glnxa64.zip -d ~/matlab
3) run the installer almost completely through manually: ~/matlab/install -downloadFolder ${HOME}/matlab/dl -destinationFolder ${HOME}/matlab/deleteme
you must enter all your proper license info here, the purpose of this is to get the toolbox files you'll need for the offline install later when you see that the installer has finished downloading everything, press the Cancel button in the gui and end the installer early you don't really want the installer to extract/decrypt the files it has downloaded
4) delete anything that might have started to be installed in the above step: rm -rf ~/matlab/deleteme
5) now you can create the tarball you'll need here: tar -cvf matlab.tar -C ~/matlab/ .
You can get your file installation key (that you must manually put into matlab.fik) from https://mathworks.com/licensecenter
Then maybe you could make the matlab.fik file you need for this package like this:
echo "xxxxx-xxxxx-xxxxx-xxxxx-..." > matlab.fik
I am writing a software for an embedded device, the basic function is VoIP, now I want to implement the SIP using eXosip2. I have downloaded the libeXosip2-3.6.0 source code from http://savannah.nongnu.org/projects/exosip/
I checked a few example code and find that to send an INVITE message, I need to call:
eXosip_call_build_initial_invite (in eXcall_api.c)
In this function, it will call osip_to_init , osip_to_parse , osip_to_free etc functions, however I could not find these functions in the eXosip2 folder....why?
Actually I also downloaded the osip2 library, I can find these functions, but can not see them in the eXosip2. Are these functions included in some object files that I can not read the content? Or actually I need to include both the osip2 and eXosip2?
I am sorry if this is a trivial question, I am novice to programming and would be very thankful if you can help.
You need to also build libosip2. Then link libeXosip2 to the libosip2 libraries
To be complete, you need to download libosip-3.6.0 and install it with those commands line (on a linux/unix platform):
$> tar -xvzf libosip-0.X.X.tar.gz
$> mkdir linux-build
$> cd linux-build
$> ../libosip-0.X.X/configure
$> make
# make install
Then compilation of eXosip2 should work.
The same is true for newer versions.
I just want to develop a C app in linux with the auto(make/conf/...) stuff automatically generated. I tried generating it with ede and anjuta, but it doesn't seem to generate Makefile.am. So, I tried running automake, and it says "ltmain.sh" isn't found. Is there some easy to generate the basic build files for linux C/C++ apps. What is the standard practice? Do most people write these files themselves?
Generating a really trivial set of autotool files is pretty easy. Here's a (really basic) example. After you run these, you should get a copy of ltmain.sh in the directory, and you'll be all set to run the configure script:
$ mkdir sample
$ cd sample
$ echo 'int main( void ) { return 0; }' > foo.c
$ echo 'bin_PROGRAMS = foo' > Makefile.am
$ autoscan
$ mv configure.scan configure.ac
$ # edit configure.ac, add AM_INIT_AUTOMAKE([foreign])
$ # and LT_INIT, set project name and bug-report-address
$ autoreconf -ivf
Note that in this example, libtool really isn't necessary since
the example is just building a simple app. But you asked about
ltmain.sh, and that's a libtool thing so LT_INIT is needed to
address that portion of the question. If you want to build
a library, change bin_PROGRAMS to lib_LTLIBRARIES.
EDE can work with your Automake files in two different ways. If you write your own automake files, it will read them, and tweak them via the UI.
If you prefer, you can have EDE do the whole thing for you. First, create your first C file, then when it is on disk, do:
M-x ede-new RET Automake RET
then from the project/project options menu, add a target, like "program".
If you fill in your C file, you can then choose Project->Build->build currentproject from the menu, and it will create and setup everything needed for Automake to do it's thing, in addition to running all the misc automake commands needed.
Lastly, there is a 'run' option somewhere to run your program.
I'd consider not using autoconf and automake at all -- their complexity outweighs their benefit, particularly if you're targeting only Linux.
Note that "git", for example, doesn't use them at all; instead it simply has a moderately-complex (but comprehensible) Makefile.
I've created a deployment project which works rather well and now I want to add it to source control repository for others to use.
The main problem I'm facing is that the .prj file which deploytool creates contains absolute paths which will not work on other computers. So far I've tried the following:
Create the stand alone exe using just mcc without deploytool. This works great but I could find a way to create the final _pkg.exe which contains everything. mcc doesn't seem to be able to create this file and there doesn't seem to be any other tool which does. Is this really the case?
Edit the .prj file to include relative paths instead of absolute paths. This only works partially because the .prj file contains a section called MATLABPath which is always replaced with the current setpath of matlab. anyone which uses this file will have to check it out since it is being changed when used.
Find a way to generate the .prj file. the mcc documentation say: Project files created using either mcc or deploytool are eligible to use this option. suggesting there is a way to create a .prj file using mcc but I wasn't able to find how this can be done.
Is there a solution to this situation?
We ran into the same thing with Matlab Builder JA. Not only are the paths absolute, Matlab also adds other toolboxes that it finds on the path, which is irritating, as the build machine doesn't have licenses for a lot of them.
So what we do is:
Edit the prj file by hand to get rid of the absolute paths
Check it into source control and build with mcc
NEVER EVER check in the prj file after it has been touched by deploytool (do all changes by hand in an editor)
Our revision control lets you modify files without an explicit checkout, so using deploytool is not a problem. But why would you want to?
Not sure what the final packager does, but if it just bundles the MCR with the compiled binary, I would just write a replacement.
I personally use Visual Studio 2005 project to maintain my deployment projects and then convert the VCPROJ to PRJ on the fly using build command step
http://younsi.blogspot.com/2011/11/matlab-relative-path-issue-in-prj.html
Here's the mcc option documentation.
What I've found most useful is creating a standalone exe using mcc:
mcc -C -m <function.m> -a <fig> -a <dll> -a <etc> -d <outputPath>
The -C option tells mcc to generate the ctf file (which is the archive of all the compiled MATLAB stuff) as a separate file. I've had trouble on some target computers using a single exe with everything compiled in.
The -m option tells mcc to make an exe.
The -a options tell mcc to include the specified file in the package. For instance, if your script uses two fig files and a data file, you need a -a for each to make sure they get put in the output package.
To tell mcc to use a project file (I've never done this myself):
mcc -F <projectfile>
Also, if you're using R2009a on Windows, there's a known bug that requires some manifest manipulation.