BUG: simulink 7.6 (r2010b) and visual c++ 2010 compiler

  • Follow


I believe that there is a bug in matlab R2010b.

I work with win 7 64bit so I installed Visual C++ 2010 Express and Windows SDK 7.1 as it is suggested here:  
http://www.mathworks.com/support/compilers/R2010b/win64.html

I set mex compiler as Visual C++ 2010 Express and I tested that everything is OK within Matlab environment by compiling yprime.c and making executable a .m file that I created for this purpose. 

Everything worked well and the executable was created.

THEN, I opened a simple model (really simple) in simulink and I tried to built the executable through real-time workshop. 

Whatever options I make, unfortunately I get error that vcvars64 cannot be found in system, meaning that the real-time workshop cannot find the 64bit compiler. I search within my C: drive and in fact vcvars64 is missing. 

I am not sure but I think that vcvars64 is a component of Visual C++ 2010 Professional. I haven't VC 2010 Pro so I cannot test it.

So even if VC compilers work well in Matlab, they DON'T in Simulink. I believe that this is a bug of Real-Time workshop as it calls wrongly vcvars64. It should call the Visual C++ 2010 Express compiler. 

If anyone has any idea how to link Simulink with the Visual C++ 2010 Express compiler, please provide info.

Elsewhere, I believe that Mathworks should remove from their site that "Microsoft Visual C++ 2010 Express and Windows SDK 7.1" is a supported compiler for Simulink Release 2010b
0
Reply Panos 10/29/2010 10:37:03 PM

I had the same problem and spent a few hours trying to figure out a solution. Finally, I got something to work. I have 64-bit Windows 7 and MATLAB R2010b. Here's what I did:

Most of the information I got from this link:
http://www.mathworks.com/support/compilers/R2010b/win64.html

I first installed Microsoft Visual C++ 2010 Express and Windows SDK 7.1 according to the instructions here:
http://www.mathworks.com/support/solutions/en/data/1-ECUGQX/
As with the previous post, I could compile yprime.c into a mexw64 file and run it. However, I could not compile simulink code using RTW since the vcvars64.bat file was missing:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars64.bat
The error message said that it could not find or run this file (sorry I didn't write down the exact error message). I tried to create vcvars64.bat by modifying vcvars32.bat, which did exist in the above directory. But that did not work either.

I then installed Microsoft Visual C++ 2008 Express and Windows SDK 6.1 since it is second on the list of free compilers, using the instructions here:
http://www.mathworks.com/support/solutions/en/data/1-6IJJ3L/?solution=1-6IJJ3L
I noticed that when I installed VC++ 2008, only vcvars32.bat existed in the directory:
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin
After installing Windows SDK 6.1, however, vcvars64.bat showed up as well in that directory. I tried to compile simulink code using the VC++ 2008 complier, but that did not work.

Finally, I copied vcvars64.bat from this directory:
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin
to this directory:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
with some minor modifications. I then selected the VC++ 2010 compiler and I could finally compile simulink code using RTW!

In summary, all you should have to do is:
- Install VC++ 2010 Express and Windows SDK 7.1 with the instructions here:
http://www.mathworks.com/support/solutions/en/data/1-ECUGQX/
- Run mex - setup and try to compile something in simulink
- If you get the error message that vcvars64.bat is missing, you can try my method and copy the text below into a new file called C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars64.bat. Take out the starting and ending lines that I added in (i.e., "---START OF VCVARS64.BAT, CUT FROM HERE---").

I hope this helps someone else!

Chris


--- START OF VCVARS64.BAT, CUT FROM HERE ---
@SET VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 10.0
@SET VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
@SET FrameworkDir=C:\Windows\Microsoft.NET\Framework64
@SET FrameworkVersion=v4.0.30319
@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR
@if "%VCINSTALLDIR%"=="" goto error_no_VCINSTALLDIR

@echo Setting environment for using Microsoft Visual Studio 2010 x64 tools.

@call :GetWindowsSdkDir

@if not "%WindowsSdkDir%" == "" (
	set "PATH=%WindowsSdkDir%bin\x64;%WindowsSdkDir%bin\win64\x64;%WindowsSdkDir%bin;%PATH%"
	set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%"
	set "LIB=%WindowsSdkDir%lib\x64;%LIB%"
)

@set PATH=%VCINSTALLDIR%\BIN\amd64;%FrameworkDir%\%Framework35Version%;%FrameworkDir%\%Framework35Version%\Microsoft .NET Framework 3.5 (Pre-Release Version);%FrameworkDir%\%FrameworkVersion%;%VCINSTALLDIR%\VCPackages;%VSINSTALLDIR%\Common7\IDE;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%PATH%
@set INCLUDE=%VCINSTALLDIR%\ATLMFC\INCLUDE;%VCINSTALLDIR%\INCLUDE;%INCLUDE%
@set LIB=%VCINSTALLDIR%\ATLMFC\LIB\amd64;%VCINSTALLDIR%\LIB\amd64;%LIB%

@set LIBPATH=%FrameworkDir%\%Framework35Version%;%FrameworkDir%\%FrameworkVersion%;%FrameworkDir%\%Framework35Version%;%FrameworkDir%\%FrameworkVersion%;%VCINSTALLDIR%\ATLMFC\LIB\amd64;%VCINSTALLDIR%\LIB\amd64;%LIBPATH%

@goto end

:GetWindowsSdkDir
@call :GetWindowsSdkDirHelper HKLM > nul 2>&1
@if errorlevel 1 call :GetWindowsSdkDirHelper HKCU > nul 2>&1
@if errorlevel 1 echo WindowsSdkDir not found
@exit /B 0

:GetWindowsSdkDirHelper
@SET WindowsSdkDir=
@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows" /v "CurrentInstallFolder"') DO (
	if "%%i"=="CurrentInstallFolder" (
		SET "WindowsSdkDir=%%k"
	)
)
@if "%WindowsSdkDir%"=="" exit /B 1
@exit /B 0

:error_no_VSINSTALLDIR
@echo ERROR: VSINSTALLDIR variable is not set. 
@goto end

:error_no_VCINSTALLDIR
@echo ERROR: VCINSTALLDIR variable is not set. 
@goto end

:end

--- END OF VCVARS64.BAT ---


"Panos" wrote in message <iafiaf$j8s$1@fred.mathworks.com>...
> I believe that there is a bug in matlab R2010b.
> 
> I work with win 7 64bit so I installed Visual C++ 2010 Express and Windows SDK 7.1 as it is suggested here:  
> http://www.mathworks.com/support/compilers/R2010b/win64.html
> 
> I set mex compiler as Visual C++ 2010 Express and I tested that everything is OK within Matlab environment by compiling yprime.c and making executable a .m file that I created for this purpose. 
> 
> Everything worked well and the executable was created.
> 
> THEN, I opened a simple model (really simple) in simulink and I tried to built the executable through real-time workshop. 
> 
> Whatever options I make, unfortunately I get error that vcvars64 cannot be found in system, meaning that the real-time workshop cannot find the 64bit compiler. I search within my C: drive and in fact vcvars64 is missing. 
> 
> I am not sure but I think that vcvars64 is a component of Visual C++ 2010 Professional. I haven't VC 2010 Pro so I cannot test it.
> 
> So even if VC compilers work well in Matlab, they DON'T in Simulink. I believe that this is a bug of Real-Time workshop as it calls wrongly vcvars64. It should call the Visual C++ 2010 Express compiler. 
> 
> If anyone has any idea how to link Simulink with the Visual C++ 2010 Express compiler, please provide info.
> 
> Elsewhere, I believe that Mathworks should remove from their site that "Microsoft Visual C++ 2010 Express and Windows SDK 7.1" is a supported compiler for Simulink Release 2010b
0
Reply first.last6487 (7) 4/10/2011 6:46:04 PM


1 Replies
610 Views

(page loaded in 0.266 seconds)

Similiar Articles:













7/21/2012 5:47:44 PM


Reply: