How to install SPAMS toolbox in Matlab 2014b under windows 8.1 - c++

I am trying to learn how to successfully compile "Sparse Modeling Software" (SPAMS) in my machine which uses a Windows 8.1 OS and MATLAB R2014b.
The steps I have taken are as followed (some parts might have been unnecessary or missing)
Step 1. Installed "Microsoft Visual C++ 2013 Professional".
Step 2. Installed "Microsoft Windows Software Development Kit (SDK)".
Step 3. Download "spams-matlab-v2.4-svn2014-02-18.tar" from http://spams-devel.gforge.inria.fr/
Step 4. Unzip it in Windows using 7-zip. Only 1 error I received but all he other data were uncompressed. The error is this :
ERROR: Can not set reparse data: C:\Users\Yashar\Desktop\spams-matlab\cpp_library\spams.h
Step5: In MATLAB, I set the compiler:
>> mex -setup C++
message I recieve:
MEX configured to use 'Microsoft Visual C++ 2013 Professional' for C++ language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading- mex-files-to-use-64-bit-api.html.
Step 6. Open compile.m in SPAMS (as recommended) and run it. The error I get looks like this:
compilation of: -I./linalg/ -I./decomp/ -I./prox/ -I./dictLearn/ dictLearn/mex/mexTrainDL.cpp
Error using mex
C:\Users\Yashar\Desktop\spams-matlab\Files not found; check that you are in the
correct current folder, and check the spelling of
'C:\Users\Yashar\Desktop\spams-matlab\Files'.
Error in compile (line 391)
mex(args{:});
Question : What I am doing to me looks pretty standard but I know it takes a while learning how to cope with issues with regard to interfacing codes with MATLAB, etc. Can you please help me with getting around the problems I have and managing to compile SPAMS toolbox in my machine? FYI, I am interested in using mexLasso function in this toolbox.

Hmm. Compiling this toolbox is a bit tricky.
Here is how I do it in Windows 7 + MATLAB 2013a.
Hope it works for you.
(I don't have the issue of unzip)
First, you want to make sure that 'mex' works properly, I have compiled some smaller packages and they worked in general.
Second, change the line
compiler='gcc';
to
compiler='mex';
Third, you can find a lot of lines look like
-I./linalg/ -I./decomp/ -I./prox/ -I./spams/dictLearn/ dictLearn/mex/mexArchetypalAnalysis.cpp
Here 'I./lib_name/' is Linux style path, and you need to change it into something that Windows can understand.
Here is an example:
-I./linalg/ ---> -IC:\Users\XXX\Downloads\SPAMS\linalg
There are totally six pieces that you need to change as following,
-I./linalg/
-I./decomp/
-I./prox/
-I./dictLearn/
-I./dags/
-I./image/
After replacing these strings, just run compile.m, then it should work.

Select 2.5 version the SPAMS software you are running for Windows version. Set the compiler to VS in compile.m and execute the code. This generates the required files. Finally run start_spams.m, which in turn creates the source folders. Now you can run the respective code.

Related

Integration of Armadillo in x86 C++ Application in Microsoft Visual Studio

since last week I'm working with the "Armadillo" C++-library.
I started with a default 64-bit C++ application in Microsoft Visual Studio. For the installation I followed the steps in the post below:
How can I install Armadillo on Windows?
Following these steps, everything worked fine for me.
But now I have to expand my C++-application and have to include/integrate another .dll. The problem for me is, that this .dll is a 32 bit .dll. So when I try to call it in my 64-bit application, which uses the Armadillo library, I always get the "class not registered"-error. This is why I want to migrate my whole project into a x86-application. But for some reason I'm not able to migrate the Armadillo-library into this x86-application (Following the instructions in the link above doesnt works anymore). While building the programm I always get more than 50 "LNK2019" errors.
Does anyone know how to fix the problem and know who to integrate Armadillo into a 32-bit application?
Thanks for your help!!
Solved it.
For me it works with replacing the x64-bit "libopenblas.lib" and "libopenblas.dll", which are installed from Armadillo by default, with the x86 "libopenblas.lib" and "libopenblas.dll", which are included in the "OpenBLAS-0.3.15-x86.zip" download file from the OpenBlas release page on GitHub:
https://github.com/xianyi/OpenBLAS/releases
Probably it is enough to only replace the "libopenblas.lib" file.

Compiling C++ project from powershell is not working

I am programming a chess engine with 2 friends and it is getting very strong (above 3000 Elo).
We have written the code in C++ and compile using make. For some reason the normal installer for MinGW did not do what it was supposed to so I went with msys2 and installed all the requires packages using msys2.
I am not familiar with compiling C++ under windows and here is the problem:
When I compile the program using the Git Bash or powershell, it compiles nicely (except for a few warnings) using: make native
The issue is the way I need to execute the program:
It does not work if I run using powershell or cmd
It does not work if I double click it (see the error message below)
It does only work if invoked from a bash
If you are not familiar with german, this is a rough translation:
The procedure entry point "..." was not found in the DLL "..."
We have provided a makefile which can build different versions (native, release (for multiple hardwares)). Running a non-native version like Koivisto_3.9-x64-windows-popcnt-avx.exe does run by simply double clicking it.
Also the file sizes are very different:
native: 600kb
non-native: 3100kb
The entire project is on github: Koivisto Chess Engine
And the makefile can be found here: Makefile
I wonder why there seems to be that difference and why the native version only runs within a bash. I am very happy if someone could explain this behaviour to me and potentially even tell me a way to fix this.
I am very happy for any advice!
Greetings,
Finn

OpenCV haartraining: Mergevec error: Input file does not exist or not readable

Following this tutorial, I've created my positive samples but need to merge them now, using mergevec. I downloaded the mergevec.exe binary file provided and got the two required dlls cxcore100.dll and highgui100.dll. However, when I run it like so:
mergevec samples.txt samples.vec
it gives me the error:
ERROR: Input file <filename> does not exist or not readable.
What should I do to fix this? My vec files are fine, because I was able to view them using the opencv_createsamples utility. So I know they're fine.
I ran into this issue as well and made a python utility that combines .vec files to avoid installing openCV again: https://github.com/wulfebw/mergevec
Hope it helps.
I was in the same situation as you few days ago so i'll try to help you out =P.
First of all i am interested to know where you found the mergevec.exe, because it isn't available to download anymore if i recall. I ask because i think that you might have downloaded an exe compiled on Linux. I had the same error when i tried to execute the mergevec, i had compiled on Ubuntu, on my Windows computer. Even with the 2 dlls.
As i explained it here , The mergevec from Naotoshi was originally made for Unix distribution, so under windows you will encounter a lot of problems. I first tried to do it on windows but i abandonned because it was too complicated and even with a full Cygwin installation i could not compile the mergevec.cpp.
What i advise you to do is to create yourself an Ubuntu virtual machine and to compile your own mergevec.exe. Once done you can copy your vec files in your virtual machine and merge them under Ubuntu. After this you can bring back the merged vec file to Windows if you want (It is better to not run the training under a VM: less computation power).
Here is what i did:
Installed VMware player with Ubuntu 14.0.4 (although i don't recommend it, still some bugs)
Installed OpenCV from the sources with TBB. There are a lot of tutorials, but the only one that worked for me is the OPenCV website, they are the more accurate on the libraries you mandatorily need.
I downloaded the GitHub classifier training and then I followed the commands given and it worked well.
If you encounter any library problem or OpenCV Installation issue don't hesitate i went through them too.

Cannot run Matlab Mex files on Mac OS X Lion 10.7.5 with Xcode Version 4.3.2

When I am trying to run c++ codes on matlab, I use the following commands:
mex '-setup'
(Then I select the following two options which are:
1: /Applications/MATLAB_R2011a_Student.app/bin/gccopts.sh :
Template Options file for building gcc MEX-files
and
2: /Applications/MATLAB_R2011a_Student.app/bin/mexopts.sh :
Template Options file for building MEX-files via the system ANSI compiler
When I select either one and select a mex file by writing the following:mex mextest1p0.cpp, I get these error messages:
/Applications/MATLAB_R2011a_Student.app/bin/mex: line 1041: g++-4.2: command not found
How can I fix this. Note: I have seen a couple post about this problem and I've tried various solutions, but nothing is working
You need to install a compiler -- namely G++ (the GNU C++ compiler). On OS X, the easiest way to do is this is by installing the XCode Command Line Developer Tools -- open up XCode, go to preferences, choose downloads, and then install the command line tools. If Matlab still can't find G++, you've got a path problem (and tell us about it) -- the solution is then probably in your gccopts script.
You don't actually need to install all of Xcode if you don't want to, I believe. It takes up a lot of hard drive space. You will need (1) an Apple Developer account (free for students). You can then (2) go to the downloads page at developer.apple.com and get just the Command Line Tools download for your version of OS X (the last to these for 10.7 was in March 2013 – it's on the third page of downloads currently). Run the installer for this.
Then you'll need to (3) edit your mexopts.sh file. You'll need to do this if you have Xcode or not. Type the following in your Matlab command window:
edit([matlabroot '/bin/mexopts.sh'])
Make a copy of the file that opens in case you screw up. You'll need to edit the file based on your system and the complier included with the Command Line Tools (you can try getting the versions by running cc -v and c++ -v or similar in Terminal.app). Look for the section related to OS X. You'll need to set the following items (these are from Matlab R2012b and have changed slightly since, but I'm guessing you're using an older version):
CC='llvm-gcc-4.2'
or maybe just
CC='gcc-4.2'
and
SDKROOT='/'
MACOSX_DEPLOYMENT_TARGET='10.7'
If you're using Xcode, the SDKROOT should probably be '/Developer/SDKs/MacOSX10.7.sdk'. For the C++ section just below you'll probably need
CXX='llvm-g++-4.2'
or
CXX='g++-4.2'
(4) Finally, save your edited mexopts.sh file and run the following in the Matlab command window:
mex -setup
Choose your file (press 1 probably) and choose yes ([y]). You should now be able to compile using the mex function.

How to make a c++ project run on a different PCs

I developed a small c++ program in Visual Studio 2012 on Windows7, 64bit (let's call it PC1). On that pc it runs fine!
Since I didn't have a versioning control system like SVN at hand, I copied ALL the project data (the exact folder structure, DLLs, source files, project files...) to a usb stick and moved it to another computer.
On that other engine there's Visual Studio 2010 on Windows7, 64bit (PC2).
So I just changed the platform toolset to v100 as described here.
I successfully compiled the project on PC2 (clean, build) and wanted to run the exe, but the command prompt stayed empty.
I then tried to debug and added a breakpoint at the very first line of main - which wasn't reached, the command prompt was still empty.
Ok, a usb stick is certainly not the most secure solution for data storage, so I gave it another try and moved it again - the problem remains.
Visual Studio's output on PC2 is the same as on PC1, so I couldn't find any anomalies there.
Yeah, there might be many error sources, so where can I start?
And how can I get a more verbose output for troubleshooting?
Or is this even a common phenomenon (perhaps due to different VS versions) and there's an simple way fix it?
This is not a full solution, but at least I'm a tiny step ahead:
In my last comment I wrote:
I took your advices into account and created a brand new project on PC2, VS2010. I exactly followed this guide: http://frozenhamster.wordpress.com/2011/02/11/lapack-on-windows-with-visual-studion-2010/
That didn't work either, so I removed I "out-commented" everything except for a single cout. Voila, that worked!
But as soon as I make use of the desired Armadillo (LAPACK and BLAS), the project compils but does not run.
What's going wrong here?
I don't get any compiler errors!