I'm trying to install VLD visual Link Detector in a CMake project.
The CMake looks like this,
find_library(VLD vld HINTS "C:/Program Files (x86)/Visual Leak Detector/lib/Win64/")
find_file(VLD_H vld.h HINTS "C:/Program Files (x86)/Visual Leak Detector/include")
if(VLD_H)
include_directories(${VLD_H})
link_directories(${_Visual_Leak_Detector}/lib/Win64/)
link_libraries(${VLD})
endif()
message("Enabling Visual Leak Detector Done")
CMake generation is successful but on building the project, the error is fatal error LNK1104: cannot open file 'vld.lib'
Any suggestions to fix this?
Thanks in advance
Related
I am trying to build VTK version 9.2.2 with CMake for a few days now, but no luck so far. I am getting the below error in CMake GUI:
CMake Error: Cannot open file for write: C:/Program Files/vtk/bin/CMakeCache.txt.tmpc3fcf
CMake Error: Unable to (re)create the private pkgRedirects directory:
C:/Program Files/vtk/bin/CMakeFiles/pkgRedirects
CMake Error: : System Error: No such file or directory
CMake Error: Unable to open cache file for save. C:/Program Files/vtk/bin/CMakeCache.txt
CMake Error: : System Error: No such file or directory
I am following the video here, but it still does not work for me. I have tried to search for answers for a while, but there doesn't seem to be the exact same error that I am having on the internet anywhere.
I am on Windows 10, using VTK 9.2.2 and my CMake version is 3.25.1. I also tried with multiple versions of visual studio in the configuration, but it returned the same error.
The steps I have taken were:
Download VTK from the site
Put the downloaded files into the program files directory
Made a /src and /bin folder under a /vtk folder, which is outside the downloaded package
Copied and pasted the downloaded files into the /src folder
Opened CMake GUI and chose the src folder as the source and chose the bin folder as the build folder
Clicked generate and it threw the errors above
The error message like
CMake Error: Cannot open file for write: ...
usually occurred when CMake has no permissions to write a given file.
Your case involves directories under C:/Program Files/, which are usually configured as read-only for normal users.
The file CMakeCache.txt is created in the build directory, so the error message about such file usually means problem with a build directory.
A build directory should always be writable by the regular user. Here CMake creates files for the build tool, and here a build tool creates intermediate and resulted files.
Using cmake from command line, I got:
"== Building Windows-Release =="
-- Building for: Visual Studio 15 2017
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_CXX_COMPILER could be found.
Where CMakeError.log contain:
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 31/12/2018 12:54:05.
Project "C:\myproj\CMakeFiles\3.13.1\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /nologo /W0 /WX- /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TC /analyze- /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
c1 : fatal error C1083: Cannot open source file: 'CMakeCCompilerId.c': No such file or directory [C:\myproj\CMakeFiles\3.13.1\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "C:\myproj\CMakeFiles\3.13.1\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\myproj\CMakeFiles\3.13.1\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(ClCompile target) ->
c1 : fatal error C1083: Cannot open source file: 'CMakeCCompilerId.c': No such file or directory [C:\myproj\CMakeFiles\3.13.1\CompilerIdC\CompilerIdC.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.43
...
I tried repairing the installation of Visual Studio, and renstalling CMake, but nothing seems to work it. Also looked at similar thread here, but nothing was helpful.
I met the exact same question with you. After a very very long struggle, I finally find the solution for me. I am not sure whether that is the same problem you met, but I still want to write and recode this strange problem.
Firstly, I also reinstall cmake, repair the VS and add many components in it and fixed(brake) many PATH environments, but all of them don't work, and I bet the problem is not because of these problems.
As the two messages:
The C compiler identification is unknown
The CXX compiler identification is unknown
They do not exactly mean the cmake don't detect the VS compiler, it just means that the cmake's use it to build its demo but fail. And from the errorlog, I even can believe your VS has already installed success and work well. The only problem is that the compiler can't open the 'CMakeCCompilerId.c' file.
I don't know whether have your check the .c file is exactly in the project location, but it is in there very well in my computer (otherwise, it means that the cmake failed to create this file, and maybe you need to open it as an administration)
I am very confused about why the compiler can't read that and try to directly open the .vcxproj file in VS and change many settings but still get the same error, like below.
After some try, I move the project to the desktop and reopen it, then it builds success! So as the whole cmake project. I am also be shocked by that.
After some compare and research, I found error reason in me, I am using the git in windows-wsl to clone the project to my windows file system(it has a little risk to break the file permission in wsl), it works well in normal, but as a cmake cross-compilation, I guess it may use some linux-like way to operate files and therefore meet some file permission problem.
So, the final solution to me is using the git in cmd or download the whole project in the browser instead of using the git in wsl. (Truly a little funny-. and may differ with your situation)
Hope these can help you.
The reason for my problem turned out to be that case sensitivity was turned on in the current directory.
Turn off case sensitivity or switch to another directory.
I am trying to use conan in a CLion project. Conan generates a conanbuildinfo.cmake file. In this file, it's trying to read another file, generated by conan too, and called conaninfo.txt.
It's not able to find it, and cmake prints the following error :
CMake Error at D:/Sources/vodrm-ecmg_c++/build/conanbuildinfo.cmake:663 (file):
file failed to open for reading (No such file or directory):
/cygdrive/d/Sources/myproject/D:/Sources/myproject/build/conaninfo.txt
As you can see the error is saying cmake could not find the requested file. But it actullay can, because the following code :
if (EXISTS ${_CONAN_CURRENT_DIR}/conaninfo.txt)
message("Found :" ${_CONAN_CURRENT_DIR}/conaninfo.txt)
endif()
file (READ "${_CONAN_CURRENT_DIR}/conaninfo.txt" CONANINFO)
Prints :
Found :D:/Sources/project/build/conaninfo.txt
It's totally contradicting since cmake is finding the file, but not when using file command.
Did anyone encountered this bug, if it's one, before? Any solution? I really don't see what I am doing wrong, since this file is generated by conan.
By the way, I am using cmake version 3.6.2.
Thanks in advance.
I am trying to link a .lib file and a .def file to create a .dll of this .lib file. I have been using this command: link /dll /machine:x86 /def:mylib.def mylib.lib and have been receiving the LNK 1181 error message. As noted on other stack posts (Visual Studio: LINK : fatal error LNK1181: cannot open input file), I have added the .lib path to my linker input directory and my additional library directory. Also, I have checked to make sure there are no spaces in the paths. I have tried everything noted in the post linked above.
Anyone have an idea as to what might be causing this error?
Thanks
I got this error when trying to compile a cpp code
c:\mingw\bin>g++ hello.cpp
g++: fatal error: -fuse-linker-plugin, but liblto_plugin-0.dll not found
compilation terminated
what is going wrong?
you have (or the build-system has) specified the flag -fuse-linker-plugin which requires the dynamic library file liblto_plugin-0.dll to be in your library search path, but the linker cannot find it.
btw, you could have discovered that by carefully reading the error message you got.