I try to compile some stuff with Matlab, and during the process Matlab should create some
temporary folders. Unfortunately, for some reason, this is not happening and therefore the compilation fails. I executed Matlab with Administrator rights, but the problems reminds. I am not sure if their is some other problem with the User Access Control under Windows 7. Could anyone give me some instructions of how I can make sure that Matlab has all the privileges to write temporary files?
EDIT:
Actually it is mex file compilation, so the error could also come from the VS compiler:
--> cl /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Temp\mex_OmN_AO\test.obj -I"C:\Program Files\MATLAB\R2011a\extern\include" -I"C:\Program Files\MATLAB\R2011a\simulink\include" /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 vcd_count_transitions.c
test.c
Contents of C:\Temp\mex_OmN_AO\mex_tmp.rsp:
C:\Temp\mex_OmN_AO\test.obj
--> link /out:"test.mexw64" /dll /export:mexFunction /MAP /LIBPATH:"C:\Program Files\MATLAB\R2011a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /implib:"C:\Temp\mex_OmN_AO\templib.x" /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib #C:\Temp\mex_OmN_AO\mex_tmp.rsp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Temp\mex_OmN_AO\test.obj
LINK : fatal error LNK1104: cannot open file 'test.mexw64'
C:\PROGRA~1\MATLAB\R2011A\BIN\MEX.PL: Error: Link of 'test.mexw64
I would expect after the compilation fails, there should be C:\Temp\mex_OmN_AO directory,
but there is nothing in my TEMP folder.
Many thanks for your help!
Related
I need to analyze exactly how MSBuild builds a C++ project, in order to rebuild it in a different way with a different toolchain. At the moment, my main strategy for doing this is to run msbuild -fl to ask it to log its actions, then I can try to analyze the resulting msbuild.log. The compile steps in this seem clear enough, but I am still trying to figure out the linking steps.
When I use Visual Studio 2022 to create a skeleton console application, the linking step is recorded in msbuild.log as
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\olivine\test\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe" /INCREMENTAL /ILK:"x64\Debug\ConsoleApplication1.ilk" /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\olivine\test\ConsoleApplication1\x64\Debug\ConsoleApplication1.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\olivine\test\ConsoleApplication1\x64\Debug\ConsoleApplication1.lib" /MACHINE:X64 /pdbthreads:4 x64\Debug\ConsoleApplication1.obj
that is, a lot of options, plus the name of the object file (the skeleton project only has one object file). That seems straightforward.
Now trying the same thing again on a skeleton desktop application:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\olivine\test\Project1\x64\Debug\Project1.exe" /INCREMENTAL /ILK:"x64\Debug\Project1.ilk" /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\olivine\test\Project1\x64\Debug\Project1.pdb" /SUBSYSTEM:WINDOWS /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\olivine\test\Project1\x64\Debug\Project1.lib" /MACHINE:X64 /pdbthreads:4 x64\Debug\Project1.res
x64\Debug\Project1.obj
Again, the skeleton project only has one object file. This time, it is not placed at the end of the link command, but on a separate line after the link command. Inspection of msbuild.log for a real project suggests this pattern is repeated when there are multiple object files; they are mentioned after the link command, one per line.
What's up with this? Why the difference in output format between the two projects? And how exactly does MSBuild obtain the list of object files and communicate it to the linker?
I’ve been trying to install OPENCV 2.4.13.6 into a GPU-equipped Windows10 machine (CUDA9.0, VS2015, cmake3.10.0 have already been installed).
Though trying to install the opencv 2.4 by referring to https://jamesbowley.co.uk/build-compile-opencv-3-4-in-windows-with-cuda-9-0-and-intel-mkl-tbb/, I got following error.
Error message:
The CXX compiler identification is MSVC 19.0.24215.1
The C compiler identification is MSVC 19.0.24215.1
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- broken
CMake Error at share/cmake-3.10/Modules/CMakeTestCXXCompiler.cmake:45 (message):
The C++ compiler
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/opencv/opencv-2.4.13.6/built/CMakeFiles/CMakeTmp
Run Build Command:"C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe" "cmTC_678c6.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=14.0"
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2018/10/28 21:46:10.
Project "C:\opencv\opencv-2.4.13.6\built\CMakeFiles\CMakeTmp\cmTC_678c6.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "cmTC_678c6.dir\Debug\".
Creating directory "C:\opencv\opencv-2.4.13.6\built\CMakeFiles\CMakeTmp\Debug\".
Creating directory "cmTC_678c6.dir\Debug\cmTC_678c6.tlog\".
InitializeBuildStatus:
Creating "cmTC_678c6.dir\Debug\cmTC_678c6.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe /c /Zi /W3 /WX- /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_678c6.dir\Debug\\" /Fd"cmTC_678c6.dir\Debug\vc140.pdb" /Gd /TP /errorReport:queue "C:\opencv\opencv-2.4.13.6\built\CMakeFiles\CMakeTmp\testCXXCompiler.cxx"
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
cl /c /Zi /W3 /WX- /Od /Ob0 /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"cmTC_678c6.dir\Debug\\" /Fd"cmTC_678c6.dir\Debug\vc140.pdb" /Gd /TP /errorReport:queue "C:\opencv\opencv-2.4.13.6\built\CMakeFiles\CMakeTmp\testCXXCompiler.cxx"
testCXXCompiler.cxx
Link:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\opencv\opencv-2.4.13.6\built\CMakeFiles\CMakeTmp\Debug\cmTC_678c6.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:/opencv/opencv-2.4.13.6/built/CMakeFiles/CMakeTmp/Debug/cmTC_678c6.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/opencv/opencv-2.4.13.6/built/CMakeFiles/CMakeTmp/Debug/cmTC_678c6.lib" /MACHINE:X64 /machine:x64 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib cmTC_678c6.dir\Debug\testCXXCompiler.obj
LINK : fatal error LNK1104: cannot open file 'C:\Program.obj' [C:\opencv\opencv-2.4.13.6\built\CMakeFiles\CMakeTmp\cmTC_678c6.vcxproj]
Done Building Project "C:\opencv\opencv-2.4.13.6\built\CMakeFiles\CMakeTmp\cmTC_678c6.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\opencv\opencv-2.4.13.6\built\CMakeFiles\CMakeTmp\cmTC_678c6.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1104: cannot open file 'C:\Program.obj' [C:\opencv\opencv-2.4.13.6\built\CMakeFiles\CMakeTmp\cmTC_678c6.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.42
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:64 (project)
Configuring incomplete, errors occurred!
See also "C:/opencv/opencv-2.4.13.6/built/CMakeFiles/CMakeOutput.log".
See also "C:/opencv/opencv-2.4.13.6/built/CMakeFiles/CMakeError.log".
Though I've been trying to fix this error referring to below URLs for a week, those solution on the URLs did not work with me.
CMake configuring fails. "cl.exe is not able to compile a simple test program"
Why does fatal error "LNK1104: cannot open file 'C:\Program.obj'" occur when I compile a C++ project in Visual Studio?
I would sincerely appreciate for your kind instruction to solve this issue.
Why isn't CMake working?
CMake build message:
The C compiler identification is MSVC 16.0.30319.1
Check for working C compiler using: Visual Studio 10 2010
Check for working C compiler using: Visual Studio 10 2010 -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "C:/Program Files (x86)/Microsoft Visual Studio
10.0/VC/bin/cl.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/theWindows7User/Desktop/glfw-3.1.2/CMakeFiles/CMakeTmp
Run Build
Command:"C:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe"
"cmTC_318a4.vcxproj" "/p:Configuration=Debug" "/p:VisualStudioVersion=10.0"
Microsoft (R) Build Engine version 4.0.30319.34209
[Microsoft .NET Framework, version 4.0.30319.34209]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 01-Jan-2016, Friday 6:35:52 AM.
Project
"C:\Users\theWindows7User\Desktop\glfw-3.1.2\CMakeFiles\CMakeTmp\cmTC_318a4.vcxproj"
on node 1 (default targets).
PrepareForBuild:
Creating directory "cmTC_318a4.dir\Debug\".
Creating directory "C:\Users\theWindows7User\Desktop\glfw-3.1.2\CMakeFiles\CMakeTmp\Debug\".
InitializeBuildStatus:
Creating "cmTC_318a4.dir\Debug\cmTC_318a4.unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /Zi /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D _DEBUG /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"cmTC_318a4.dir\Debug\\" /Fd"cmTC_318a4.dir\Debug\vc100.pdb" /Gd /TC /analyze- /errorReport:queue testCCompiler.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl /c /Zi /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D _DEBUG /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"cmTC_318a4.dir\Debug\\" /Fd"cmTC_318a4.dir\Debug\vc100.pdb" /Gd /TC /analyze- /errorReport:queue testCCompiler.c
testCCompiler.c
ManifestResourceCompile:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /nologo /fo"cmTC_318a4.dir\Debug\cmTC_318a4.exe.embed.manifest.res" cmTC_318a4.dir\Debug\cmTC_318a4_manifest.rc
Link:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\theWindows7User\Desktop\glfw-3.1.2\CMakeFiles\CMakeTmp\Debug\cmTC_318a4.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /ManifestFile:"cmTC_318a4.dir\Debug\cmTC_318a4.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:/Users/theWindows7User/Desktop/glfw-3.1.2/CMakeFiles/CMakeTmp/Debug/cmTC_318a4.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Users/theWindows7User/Desktop/glfw-3.1.2/CMakeFiles/CMakeTmp/Debug/cmTC_318a4.lib" /MACHINE:X86 cmTC_318a4.dir\Debug\cmTC_318a4.exe.embed.manifest.res
cmTC_318a4.dir\Debug\testCCompiler.obj /machine:X86 /debug
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid
or corrupt
[C:\Users\theWindows7User\Desktop\glfw-3.1.2\CMakeFiles\CMakeTmp\cmTC_318a4.vcxproj]
Done Building Project
"C:\Users\theWindows7User\Desktop\glfw-3.1.2\CMakeFiles\CMakeTmp\cmTC_318a4.vcxproj"
(default targets) -- FAILED.
Build FAILED.
"C:\Users\theWindows7User\Desktop\glfw-3.1.2\CMakeFiles\CMakeTmp\cmTC_318a4.vcxproj"
(default target) (1) ->
(Link target) ->
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt [C:\Users\theWindows7User\Desktop\glfw-3.1.2\CMakeFiles\CMakeTmp\cmTC_318a4.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.43
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
Configuring incomplete, errors occurred!
See also "C:/Users/theWindows7User/Desktop/glfw-3.1.2/CMakeFiles/CMakeOutput.log".
See also "C:/Users/theWindows7User/Desktop/glfw-3.1.2/CMakeFiles/CMakeError.log".
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid
It's a classic Visual Studio issue. You have to install the service pack to fix it. See here: https://msdn.microsoft.com/en-us/library/7dz62kfh%28v=vs.110%29.aspx
There seems to be an error when generating VS2010 projects from premake, even with the "Hello World" example (Also tried with clink (here) and premake itself)
hello.c
#include <stdio.h>
int main(void) {
puts("Hello, word!");
return 0;
}
premake4.lua
-- premake4.lua
solution "HelloWorld"
configurations "Any"
project "HelloWorld"
kind "ConsoleApp"
language "C"
files "*.c"
defines { "DEBUG" }
flags { "Symbols" }
This simple example fails to link with the message "LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt"
The logfile says:
Build started 09-02-2015 16:06:34.
1>Project "E:\D\Source\premake-dev\pm-test\HelloWorld.vcxproj" on node 2 (build target(s)).
1>InitializeBuildStatus:
Creating "obj\Any\HelloWorld.unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /Od /Oy- /D DEBUG /D _MBCS /Gm /EHsc /RTC1 /MDd /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fo"obj\Any\\" /Fd".\HelloWorld.pdb" /Gd /TC /analyze- /errorReport:prompt hello.c
hello.c
ManifestResourceCompile:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /nologo /fo"obj\Any\HelloWorld.exe.embed.manifest.res" obj\Any\HelloWorld_manifest.rc
Link:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:".\HelloWorld.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /ManifestFile:"obj\Any\HelloWorld.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"E:\D\Source\premake-dev\pm-test\HelloWorld.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /ENTRY:"mainCRTStartup" /DYNAMICBASE /NXCOMPAT /IMPLIB:".\HelloWorld.lib" /MACHINE:X86 obj\Any\HelloWorld.exe.embed.manifest.res
obj\Any\hello.obj
1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
1>Done Building Project "E:\D\Source\premake-dev\pm-test\HelloWorld.vcxproj" (build target(s)) -- FAILED.
Build FAILED.
Time Elapsed 00:00:00.33
SOLVED!!
It was an error in my pristine VS2010 install!! See
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d10adba0-e082-494a-bb16-2bfc039faa80/vs2012-rc-installation-breaks-vs2010-c-projects?forum=vssetup
Although i never installed anything but VS2010 ..
SOLUTION: From this page:
http://blogs.msdn.com/b/heaths/archive/2011/04/01/visual-c-2010-sp1-compiler-update-for-the-windows-sdk-7-1.aspx
Copy c:\windows\Microsoft.Net\Framework\v4.0.30319\ cvtres.exe (42Kb)
into Programs(x86)\Microsoft Visual Studio 10.0\VC\Bin\
I have a C-File that I wanna compile in Matlab with MS Visual Studio 10.
For that I use the following command:
mex -v test.c
The output that I get after compilation is the following:
test.c
Contents of C:\Temp\mex_kpuu4t\mex_tmp.rsp:
C:\Temp\mex_kpuu4t\test.obj
--> link /out:"test.mexw64" /dll /export:mexFunction /MAP /LIBPATH:"C:\Program Files\MATLAB\R2011a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /implib:"C:\Temp\mex_kpuu4t\templib.x" /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib #C:\Temp\mex_kpuu4t\mex_tmp.rsp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Temp\mex_kpuu4t\test.obj
LINK : fatal error LNK1104: cannot open file 'test.mexw64'
C:\PROGRA~1\MATLAB\R2011A\BIN\MEX.PL: Error: Link of 'test.mexw64' failed.
Anyone an idea what could go wrong here? The interesting thing is, that the test.obj file seems not to be written to the temp folder, could that be the issue here?
Many thanks!
Maybe you called "test" from a previously compiled mex? If yes, it might still be loaded to Matlab's memory, and cannot be overwritten. Try:
clear mex
and then compile again.