Is it possible to link the Matlab compiler to Visual C++ compiler? - visual-studio-2010

I am using Matlab 2010 and VS2010.
I have the Matlab Compiler Runtime installed in my system.
Whenever if run command mcc -setup I get only one compiler lcc. This compiler gives a lot of errors when used to build a C++ shared library using deployment tool. It builds only C Shared libraries correctly.
Can I also connect VC++ compiler with MCC ????
How should I do that ??

Have you read this article? Especially note 2? They are talking about a similar bug there.
PS
Matlab interacts with compilers using mexopts files, located in
matlabroot\bin\win64\mexopts\
So, you may add virtually any compiler yourself.
Some mexopts are available through Mathworks fileexchange.
If you've got access to newer matlab installation, you can get mexopts from there.
You can write your own set of mexopts, based on existing files. In genereal, it's rather easy make, say VS2010 mexopts out of VS2008 ones.
Here's an official article on this.

There is an issue with Matlab 2010 and VS2010. It seems like Matlab was released before VS and therefore it does not have automatic way of configuring VS2010.
I ran into this issue once and my best advice is to download VS2008 express edition...
It's lame, but its the quickest way to get Matlab 2010 working with VS.
Sorry.

Related

Visual Studio, CMake and Toolchain Files

before I explain my current problem with Visual Studio in combination with CMake, I try to explain what I want to accomplish as there might be a better solution.
At our company we have a huge code base mainly written in C for QNX. For development we are using the standard IDE QNX momentics. As this is based on a quite old eclipse version ... the whole IDE sucks.
I'm currently evaluating to use Visual Studio as a replacement. With a really simple HelloWorld-programm I was able to build and debug the project from within VS using CMake and a CMakeSettings.json.
As our code base is basically organized in a tree-like structure, I've created a typical hierarchy of CMakeLists.txt which allows me to build single/multiple projects.
As QNX delivers its own compiler I've created a toolchain file, this is running fine so far, the required toolchain is invoked once a build is triggered via cmake.
Now for the part that I'm struggling with:
How to use this CMake setup in order to develop/debug code from VS?
I had two ideas in mind which don't really work or I'm doing something wrong.
Use the CMake generator for VS 2019 and generate a complete solution. Problem: The toolchain file is not "used" as all projects will be setup with the internal VS compilers. Is there any way to get this working? I thought calling cmake -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE=$FILE would do the job. Additionally: how would I incorporate the debugger configuration? With this solution the CMakeSettings.json seems to be ignored as VS solutions are used.
Use File->Open->CMake to open the root project. Shouldn't this show all "contained" projects which also include a CMakeLists.txt as projects? I can only see the folder tree in the Solution Explorer. Build a single project from the solution explorer is also not possible ... there is simply no option.
Anyone with experience on this topic?
Minor comment please limit questions to 1 question in the future. Multiple questions clutters questions and makes search results worse.
============================================================
I'll answer question #1 this part of question number 1.
"Use the CMake generator for VS 2019 and generate a complete solution. Problem: The toolchain file is not "used" as all projects will be setup with the internal VS compilers. Is there any way to get this working? I thought calling cmake -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE=$FILE would do the job."
Instead of using Visual Studio as your generator try using "Ninja" instead. Ninja will work if your toolchain code is correct. Toolchains and visual studio are complicated to say the least. If you wanna go down that rabbit hole I can help but that's a separate question
Basically try switching to Ninja instead of Visual Studio as your generator for CMakeSettings.json. Ninja is very easy to write toolchains for.
======================================================================
"Additionally: how would I incorporate the debugger configuration?"
The MSDN articles are actually quite good. I figured it out this week. In my opinion the debugger configurations are more powerful with the CMake approach than vanilla visual studio.
Configure CMake debugging sessions
https://learn.microsoft.com/en-us/cpp/build/configure-cmake-debugging-sessions?view=msvc-160
"Tutorial: Debug a CMake project on a remote Windows machine"
https://learn.microsoft.com/en-us/cpp/build/cmake-remote-debugging?view=msvc-160
Trust me once it clicks you'll love it.

Compiling a Fortran .dll on Windows 7 (for free)?

My boss just asked me to integrate his bosses old Fortran code into a project (Java) I'm working on. The code was written in the 90s, so I imagine it'll still compile, so rather than re-write it, I'm hoping I can just call the functions from a .dll. I'm already calling some C .dlls, so I think I've got that part covered.
I've been doing some reading, and most of the articles talk about integrating the Intel Visual Fortran Compiler into Microsoft Visual Studio. We've got a university site license for Visual Studio, but it looks like the Intel Visual Fortran Compiler is in around the $700 range. I don't think my boss will go for that, so I'm looking for another option. I know Microsoft makes a lot of products freely available to students via Project Dreamspark, but I didn't see anything Fortran related.
I'm looking at some cygwin based options right now (g95, I think), but I'm looking for other ideas/options. Any ideas?
I've used the gfortran (g95) compiler with the -shared flag to create DLLs. first compile the .for/.f90 files with:
gfortran -c myfile1.f90
gfortran -c myfile2.f90
then:
gfortran -shared -o mydll.dll myfile1.o myfile2.o
MinGW will let you create a DLL that will work with your MS stuff.
Look for a GCC port to Windows, such as Mingw or GCW. Both those will create .obj files which can be linked to in Visual Studio. Or you could futz around and configure VS to invoke one of those command line compilers into the project. But since the code is relatively static, it might be a nice compile once and forget it task, hopefully.
Don't expect much help from Microsoft on Fortran.
They spent years trying to kill it off in favour of Visual Basic / C.
You could try Silverfrost's compiler.
http://www.silverfrost.com/11/ftn95/ftn95_fortran_95_for_windows.aspx
This is available free ('personal edition' version) and works with Visual Studio.
It's basically a F90/F95 compiler with a selection of later features included.
You did not say if the old boss' code was written in F77 or F90.
But I think that Silverfrost will handle the old code with minimal changes.
If it turns out well for you, there's also an academic version and an enterprise edition to move up to as desired.

gcc compiled code on visual studio

Assume I have source code for a lib/tool that works on gcc compiler. Can I use the same code and compile it in visual studio. will that be possible at all? If it is possible, how do I do it?
if you are just using all the standard C/C++ library like stdio.h, stdlib.h, etc. it should work fine. Pure console program should work fine. If you used some GUI related library (especially if you are porting over from unix to window) then it might not work.
To do so, you can simply just create a new project in visual studio and add the existing source code into the project workspace. Compile it, if you encounter any error, just post here or try solve if you know how
It depends on your code, GCC support a variant of C (C99) which Visual Studio doesn't support yet.
If your trying to compile a Unix program on Windows you best bet will be to use Cygwin.
Check this question for pointers on using Cygwin in Visual Studio.

Boost installation on windows

i have downloaded boost_1_42_0,zip but i'm not sure how to set it up. does http://www.boostpro.com/download/boost_1_42_setup.exe has to do something with it?
If you are only going to use header only libraries in Boost then all you need to do is extract the source archive and add an include path to your project to the Boost root location. There's a, possibly not up to date, list of which libs need to be compiled in the Getting Started docs (see Section #3). If you do need to compile things you can follow the instructions in the Getting Started (see 5.2 and/or 5.3). The BoostPro installer is done independently and hence isn't always up to date, although Dave A. And Daniel W. do try to keep it current. But since there's a limit to how many configurations they can account for it has limits as to having the kind of binary you will need, and of course it's only for Visual Studio.
IIRC, the boostpro setup is an alternative way to get Boost running on your system. It is smallish program that starts by asking you which libraries and configurations you want, and then downloads the necessary files on the fly. It is much easier and faster to get going this way than by building from source, but it isn't always up to date, particularly just after a new source release, and only supports Microsoft's compilers, AFAIK.
Boost Getting Started on Windows
How to use Boost in Visual Studio 2010
Boost linking, Visual Studio & version control
Using Boost on Windows (Visual Studio)
Including Relevant Boost Libraries with C++ Source (Using Visual Studio)

Importing WinSCP source files into Microsoft Visual Studio 2008?

I am pretty new to programming. I would like to download an open source project and build it in my Microsoft Visual Studio 2008. In fact, I tried to import and build the application WinSCP:
https://sourceforge.net/projects/winscp/
But I didn’t work. Please can somebody help me and tell me which files do I have to download (from sourceforge) and how to import these into Microsoft Visual Studio in order to build the application. Thank you a lot. David
WinSCP seems to be written in Borland C++ Builder or whatever it's called today. It's not a standard C++ program and wouldn't compile in any other compiler because it uses special features only present in BCB. (It uses Delphi-style components, VCL and thus the __property keyword.)
Unfortunately, a lot of Open Source projects have very poor support for Microsoft's development tools. One project that comes to mind as being not too big and having workable MSVC project files is FreeType2, but that's a library and not an application, which probably makes it not very interesting for toying around with.
In support forum of winscp, they say, that you can't compile this project in Visual Studio.
Winscp appears to be a CPP project using a makefile instead of a sln file. VS uses SLN and *proj files to control builds and such. A good way to start would be to open VS, create a new console project (and solution) and go through some tutorials online.
If you really want to just see how a large project works in VS, grab something like IronRuby or IronPython or even something like the Witty twitter client.
In the general case, it is not possible to pour the C++ sources of a program into Visual Studio and expect it to work. C++ programming environments are far too different between operating systems for that. If you have a open-source program which builds and runs fine on Linux (for example), it may need several weeks (or months) or programming effort to make it run on Windows.

Resources