CMake project using ifort failed. "is not able to compile a simple test program." - cmake

I can compile the project using gfortran in both Linux and Windows with no error. But for some reason I have to use ifort.exe as compiler in Windows and it failed. Anyone can help?
The detailed information is as follows:
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - failed
-- Check for working Fortran compiler: D:/Program Files/IVF/compilers_and_libraries_2018.3.210/windows/bin/intel64/ifort.exe
-- Check for working Fortran compiler: D:/Program Files/IVF/compilers_and_libraries_2018.3.210/windows/bin/intel64/ifort.exe- broken CMake Error at D:/Program Files/CMake/share/cmake-3.18/Modules/CMakeTestFortranCompiler.cmake:51 (message): The Fortran compiler
"D:/Program Files/IVF/compilers_and_libraries_2018.3.210/windows/bin/intel64/ifort.exe"
is not able to compile a simple test program. It fails with the following output:
Change Dir: C:/Users/xxx/build/CMakeFiles/CMakeTmp
Run Build Command(s):D:/PROGRA~2/MINGW-~1/X86_64~1.0-P/mingw64/bin/mingw32-make.exe cmTC_809ef/fast && mingw32-make.exe[1]: Entering directory 'C:/Users/xxx/build/CMakeFiles/CMakeTmp'
D:/PROGRA~2/MINGW-~1/X86_64~1.0-P/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_809ef.dir\build.make CMakeFiles/cmTC_809ef.dir/build
mingw32-make.exe[2]: Entering directory 'C:/Users/xxx/build/CMakeFiles/CMakeTmp'
Building Fortran object CMakeFiles/cmTC_809ef.dir/testFortranCompiler.f.obj
D:\PROGRA~2\IVF\COMPIL~1.210\windows\bin\intel64\ifort.exe /nologo /fpp /W1 /nologo /fpp /libs:dll /threads /Od /debug:full /dbglibs /FoCMakeFiles\cmTC_809ef.dir\testFortranCompiler.f.obj /FdCMakeFiles\cmTC_809ef.dir/ -c C:\Users xxx\build\CMakeFiles\CMakeTmp\testFortranCompiler.f
warning #31001: The dll for reading and writing the pdb (for example, mspdb110.dll) could not be found on your path. This is usually a configuration error. Compilation will continue using /Z7 instead of /Zi, but expect a similar err r when you link your program.
Linking Fortran executable cmTC_809ef.exe
"D:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_809ef.dir\link.txt --verbose=1
"D:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_809ef.dir --rc=rc --mt="" --manifests -- xilink /nologo #CMakeFiles\cmTC_809ef.dir\objects1.rsp /out:cmTC_809ef.exe /implib:cmTC_809ef.lib /pdb:C:\Users\xxx\build\CMakeFiles\CMakeTmp\cmTC_809ef.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL:YES /subsystem:console user32.lib
RC Pass 1: command "rc /fo CMakeFiles\cmTC_809ef.dir/manifest.res CMakeFiles\cmTC_809ef.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified.mingw32-make.exe[2]: *** [CMakeFiles\cmTC_809ef.dir\build.make:107: cmTC_809ef.exe] Error -1 mingw32-
make.exe[2]: Leaving directory 'C:/Users/xxx/build/CMakeFiles/CMakeTmp'
mingw32-make.exe[1]: *** [Makefile:140: cmTC_809ef/fast] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/xxx/build/CMakeFiles/CMakeTmp'

The error is because that the rc.exe cannot be found. I solved the problem by adding the file path to the PATH variable.

Related

CMake for MinGW Makefiles won't create the build

I am trying to create a build of MinGW Makefiles using cmake but I get the following error when I execute the command cmake -G "MinGW Makefiles" ..\source\
I have attached a picture of my path varibles below.Path Variables. I get the following error on running the cmake -G commmand
PS C:\Users\gaura.YASH\OneDrive\Desktop\new_code\cmake_1st_proj\C-Make\1st project\build> cmake ..\source\ -G "MinGW Makefiles"
-- The CXX compiler identification is MSVC 19.33.31630.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/CMakeTestCXXCompiler.cmake:63 (message):
The C++ compiler
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/gaura.YASH/OneDrive/Desktop/new_code/cmake_1st_proj/C-Make/1st project/build/CMakeFiles/CMakeScratch/TryCompile-mhmynt
Run Build Command(s):C:/MinGW/bin/mingw32-make.exe -f Makefile cmTC_29120/fast && C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_29120.dir\build.make CMakeFiles/cmTC_29120.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/gaura.YASH/OneDrive/Desktop/new_code/cmake_1st_proj/C-Make/1st project/build/CMakeFiles/CMakeScratch/TryCompile-mhmynt'
Building CXX object CMakeFiles/cmTC_29120.dir/testCXXCompiler.cxx.obj
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\cmTC_29120.dir\testCXXCompiler.cxx.obj.d --working-dir="C:\Users\gaura.YASH\OneDrive\Desktop\new_code\cmake_1st_proj\C-Make\1st project\build\CMakeFiles\CMakeScratch\TryCompile-mhmynt" --filter-prefix="Note: including file: " -- C:\PROGRA~1\MICROS~4\2022\COMMUN~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\cl.exe /nologo /TP /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\cmTC_29120.dir\testCXXCompiler.cxx.obj /FdCMakeFiles\cmTC_29120.dir/ /FS -c "C:\Users\gaura.YASH\OneDrive\Desktop\new_code\cmake_1st_proj\C-Make\1st project\build\CMakeFiles\CMakeScratch\TryCompile-mhmynt\testCXXCompiler.cxx"
testCXXCompiler.cxx
Linking CXX executable cmTC_29120.exe
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_29120.dir\link.txt --verbose=1
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_29120.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\MICROS~4\2022\COMMUN~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\link.exe /nologo #CMakeFiles\cmTC_29120.dir\objects1 /out:cmTC_29120.exe /implib:cmTC_29120.lib /pdb:"C:\Users\gaura.YASH\OneDrive\Desktop\new_code\cmake_1st_proj\C-Make\1st project\build\CMakeFiles\CMakeScratch\TryCompile-mhmynt\cmTC_29120.pdb" /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
RC Pass 1: command "rc /fo CMakeFiles\cmTC_29120.dir/manifest.res CMakeFiles\cmTC_29120.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specifiedCMakeFiles\cmTC_29120.dir\build.make:99: recipe for target 'cmTC_29120.exe' failed
mingw32-make.exe[1]: *** [cmTC_29120.exe] Error -1
mingw32-make.exe[1]: Leaving directory 'C:/Users/gaura.YASH/OneDrive/Desktop/new_code/cmake_1st_proj/C-Make/1st project/build/CMakeFiles/CMakeScratch/TryCompile-mhmynt'
Makefile:126: recipe for target 'cmTC_29120/fast' failed
mingw32-make.exe: *** [cmTC_29120/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/gaura.YASH/OneDrive/Desktop/new_code/cmake_1st_proj/C-Make/1st project/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/gaura.YASH/OneDrive/Desktop/new_code/cmake_1st_proj/C-Make/1st project/build/CMakeFiles/CMakeError.log".
PS C:\Users\gaura.YASH\OneDrive\Desktop\new_code\cmake_1st_proj\C-Make\1st project\build>
I am trying to avoid adding the compiler to be used in the cmakelist.txt file as I saw that it is a bad practice. I searched and found alternative approaches using -D flag and saving the preferred settings in cache but I am curious to know why this one works in the tutorial but not on my system.
I tinkered for a bit and realized it is necessary to give the g++ compiler as a flag to the cmake command. The default compiler here is MSVC but mingw-makefile use the g++.exe. Thus, the command cmake -G MinGW Makefiles" -D CMAKE_CXX_COMPILER=g++ ..\source\ will create a build for your project given the build repository doesn't have any existing cache, if it does, then you would need to clear it.
One thing to keep in mind is that compiler = g++ is the name of the application of the compiler in path. So you must add it to path and write the exact name without ext. here.
Additionally, I tried to run the ninja build system, which also showed the same error as the original question. Similar changes in the command fixed it as well, so cmake -G "Ninja" -D CMAKE_CXX_COMPILER=g++ ..\source\ will build your project, given you have no cache in build. Delete if you do.
I could not find out how to run ninja using msvc though, replacing g++ with the cl exe did not work.
Edit: How to use Clang-CL LLVM with VS2019 CMAKE? for the clang-msvc one.

CMake building for Windows (clang-cl) using Ninja Generator

I am trying to build a simple application on a Windows machine using CMake as the main build tool. Once CMake is invoked on the project the is an error on configuration phase:
> cmake -H. -G Ninja -Bbuild -DCMAKE_C_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" -DCMAKE_CXX_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe"
-- The C compiler identification is Clang 7.0.0
-- The CXX compiler identification is Clang 7.0.0
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe --broken
CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/CMakeTestCCompile
r.cmake:52 (message):
The C compiler
"C:/Program Files/LLVM/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/mak/Desktop/cmake-test/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/Qt/Tools/QtCreator/bin/ninja.exe" "cmTC_f5485"
[1/2] Building C object CMakeFiles\cmTC_f5485.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_f5485.exe
FAILED: cmTC_f5485.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_f5485.dir --manifests -- CMAKE_LINKER-NOTFOUND /nologo CMakeFiles\cmTC_f5485.dir\testCCompiler.c.obj /out:cmTC_f5485.exe /implib:cmTC_f5485.lib /pdb:cmTC_f5485.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
RC Pass 1: command "rc /foCMakeFiles\cmTC_f5485.dir/manifest.res CMakeFiles\cmTC_f5485.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the given file
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
I read a lot through the web but my problem was not solved by any proposed solution. What I found so far is a simmilar but maybe outdated solution to the same problem which did not work for me, because Ninja was not able to build the executable:
> ninja all
[1/2] Building CXX object CMakeFiles/minimal.dir/main.cpp.obj
FAILED: CMakeFiles/minimal.dir/main.cpp.obj
C:\PROGRA~1\LLVM\bin\clang-cl.exe -MD -MT CMakeFiles/minimal.dir/main.cpp.obj -MF CMakeFiles\minimal.dir\main.cpp.obj.d -o CMakeFiles/minimal.dir/main.cpp.obj -c ../main.cpp
clang-cl.exe: warning: unknown argument ignored in clang-cl: '-MF' [-Wunknown-argument]
clang-cl.exe: error: no such file or directory: 'CMakeFiles/minimal.dir/main.cpp.obj'
clang-cl.exe: error: no such file or directory: 'CMakeFiles\minimal.dir\main.cpp.obj.d'
ninja: build stopped: subcommand failed.
Before this error CMake configured properly except that all compilers ABI info detection failed - but CMake resumed without error. There are some other questions out there which did not help either.
The official documentation states it is quite simple but in fact it is not.
So: How do I build a simple C++ project using CMake with the Ninja generator and Clang as the compiler? I try to avoid the installation of Visual Studio but it would be great if generated binaries are compatible with MSVC build binaries.
Versions:
CMake 3.12.2
Ninja 1.8.2
Clang 7.0.0
Example: Here is the minial example which I am working with:
CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(minimal)
add_executable(${PROJECT_NAME} main.cpp)
main.cpp
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}
To compile with clang-cl, it is necessary to run cmake with MSVC environment loaded (use vcvarsall.bat). Otherwise it tries to use GCC compatibility options.
It is enough to install just the Build Tools.

Trying to use JetBrains CLion, but Cmake - c++ compiler broken after cygwin install

I have been trying to get JetBrains CLion IDE working, but I am running into a problem with Cmake and none of my research online has been helpful. I installed cygwin with the necessary packages (as stated here - gcc/g++, cmake, make, gdb). When I open up CLion and go into Settings (I'm running Windows 10) under Build>Toolchains>Debugger everything has a check next to it, so it seems like CLion has found everything alright, but when I look in the Debugger window I get the following error:
"C:\Users\Lucas Lofaro\.CLion2016.3\system\cygwin_cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" "/cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview"
-- The CXX compiler identification is GNU 5.3.0
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- broken
CMake Error at /cygdrive/c/Users/Lucas Lofaro/.CLion2016.3/system/cygwin_cmake/share/cmake-3.6.2/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/bin/c++.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_96921/fast"
/usr/bin/make -f CMakeFiles/cmTC_96921.dir/build.make
CMakeFiles/cmTC_96921.dir/build
make[1]: Entering directory '/cygdrive/c/Users/Lucas
Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_96921.dir/testCXXCompiler.cxx.o
/usr/bin/c++.exe -o CMakeFiles/cmTC_96921.dir/testCXXCompiler.cxx.o -c
"/cygdrive/c/Users/Lucas
Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp/testCXXCompiler.cxx"
Linking CXX executable cmTC_96921.exe
"/cygdrive/c/Users/Lucas
Lofaro/.CLion2016.3/system/cygwin_cmake/bin/cmake.exe" -E cmake_link_script
CMakeFiles/cmTC_96921.dir/link.txt --verbose=1
/usr/bin/c++.exe -Wl,--enable-auto-import
CMakeFiles/cmTC_96921.dir/testCXXCompiler.cxx.o -o cmTC_96921.exe
-Wl,--out-implib,libcmTC_96921.dll.a
-Wl,--major-image-version,0,--minor-image-version,0
c++: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
CMakeFiles/cmTC_96921.dir/build.make:97: recipe for target 'cmTC_96921.exe'
failed
make[1]: *** [cmTC_96921.exe] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/Lucas
Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_96921/fast' failed
make: *** [cmTC_96921/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeError.log".
I've also added the cygwin bin directory to my Path environment variable, but I am really at a loss as to what to do next. Something isn't linking up and I don't want to start digging around in Cmake files without a better understanding of what's going on. Any guidance would be much appreciated. Please let me know if I can provide any additional information.
It turns out that the cmake, make, and g++ packages were installed but not updated to their most recent versions. Rerunning cygwin installer solved my problem and everything now compiles fine.

Clang and CMake on Windows

I am building a C++ project with Clang 3.8 and CMake 3.7 on Windows, but Clang emits an error in configure like below.
Determining if the CXX compiler works failed with the following output:
Change Dir: C:/tools/k.build/CMakeFiles/CMakeTmp
Run Build Command:"C:/tools/ninja.exe" "cmTC_c0004"
[1/2] Building CXX object CMakeFiles/cmTC_c0004.dir/testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_c0004.exe
FAILED: cmTC_c0004.exe
cmd.exe /C "cd . && C:\tools\llvm-3.8.1.build\Release\bin\clang++.exe CMakeFiles/cmTC_c0004.dir/testCXXCompiler.cxx.obj -o cmTC_c0004.exe -Wl,--out-implib,libcmTC_c0004.dll.a -Wl,--major-image-version,0,--minor-image-version,0 && cd ."
LINK : warning LNK4044: unrecognized option '/-out-implib'; ignored
LINK : warning LNK4044: unrecognized option '/-major-image-version'; ignored
LINK : warning LNK4044: unrecognized option '/-minor-image-version'; ignored
LINK : fatal error LNK1181: cannot open input file 'libcmTC_c0004.dll.a'
clang++.exe: error: linker command failed with exit code 1181 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Strange thing is that no file exists in CMakeFiles/CMakeTmp/. How can I get it to work?
Simply put, you are defining your toolchain wrong. CMake thinks you are using the MSVC compiler with a different path. See this question for a detailed answer. Note that you will still need MSVC or Cygwin as a build environment.

cmake unable to find libstdc++

(Using elementaryOS/Ubuntu)
I'm cross-compiling x265 and I encouraged annoying problem. For some reason cmake doesn't want to accept -static-libstdc++, because ld is apparently unable to find it. Cmake is built from Source Code, working pretty well without -static-libstdc++, if I then copy libstdc++-6.dll from mingw-w64 libs to folder with x265.exe, it works well, but I want it to build with it. mingw was built with this script and contains these libraries, but I don't know where is ld looking for them.
Here is output of cmake attempt:
-- cmake version 3.5.0-rc1
-- The C compiler identification is GNU 5.2.0
-- The CXX compiler identification is GNU 5.2.0
-- Check for working C compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++ -- broken
CMake Error at /usr/local/share/cmake-3.5/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler
"/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++" is not
able to compile a simple test program.
It fails with the following output:
Change Dir: /home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_e7611/fast"
/usr/bin/make -f CMakeFiles/cmTC_e7611.dir/build.make
CMakeFiles/cmTC_e7611.dir/build
make[1]: Entering directory
`/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_e7611.dir/testCXXCompiler.cxx.obj
/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++
-static-libgcc -static-libstdc++ -o
CMakeFiles/cmTC_e7611.dir/testCXXCompiler.cxx.obj -c
/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
Linking CXX executable cmTC_e7611.exe
/usr/local/bin/cmake -E cmake_link_script
CMakeFiles/cmTC_e7611.dir/link.txt --verbose=1
/usr/local/bin/cmake -E remove -f CMakeFiles/cmTC_e7611.dir/objects.a
/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-ar cr
CMakeFiles/cmTC_e7611.dir/objects.a #CMakeFiles/cmTC_e7611.dir/objects1.rsp
/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++
-static-libgcc -static-libstdc++ -Wl,--whole-archive
CMakeFiles/cmTC_e7611.dir/objects.a -Wl,--no-whole-archive -o
cmTC_e7611.exe -Wl,--out-implib,libcmTC_e7611.dll.a
-Wl,--major-image-version,0,--minor-image-version,0
#CMakeFiles/cmTC_e7611.dir/linklibs.rsp
/home/myname/mingw-w64/mingw-w64-x86_64/lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld:
cannot find -lstdc++
collect2: error: ld returned 1 exit status
make[1]: *** [cmTC_e7611.exe] Error 1
make[1]: Leaving directory
`/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp'
make: *** [cmTC_e7611/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:19 (project)
-- Configuring incomplete, errors occurred!
See also "/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeOutput.log".
See also "/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeError.log".
make: *** No targets specified and no makefile found. Stop.
Cmake is run like code below.
cmake -DCMAKE_C_COMPILER='/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc' -DCMAKE_CXX_COMPILER='/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++' -DCMAKE_RC_COMPILER='/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-windres' -DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_TOOLCHAIN_FILE='/home/myname/x265/build/linux/build.cmake' ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
make ${MAKEFLAGS}
build.cmake file is not much important here, but it contains:
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_ASM_YASM_COMPILER yasm)
Any ideas how to make -static-libstdc++ work? I tried linking it in many folders, but I couldn't find out where is ld looking for it.
I managed to solve this. Source of my confusion was the fact that you can use -static-libgcc, so I thought even -static-libstdc++ should work. The problem was that there indeed were libraries, but not the .a files for libstdc++. These can be disabled using this parameter when using the script. Then both -static-lib options work well.
bash ./mingw-w64-build-3.6.7 --disable-shared