Cmake build error for c++ - c++

I want to build the bayes optimization program error is
The C compiler identification is GNU 4.9.2
The CXX compiler identification is GNU 4.9.2
Check for working C compiler: C:/MinGW/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: "C:\MinGW\bin" "cmTryCompileExec2576605559/fast"
Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: C:/Code-Lite-Test/CMakeFiles/CMakeTmp
Run Build Command:"C:\MinGW\bin" "cmTryCompileExec2576605559/fast"
Access is denied
Generator: execution of make failed. Make command was: "C:\MinGW\bin"
"cmTryCompileExec2576605559/fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
I have downloaded source from url https://bitbucket.org/rmcantin/bayesopt/ and i have downloaded the MinGW compiler for Windows when I try to build the program the error is:
Please help me on this I have also deleted the old cache when I try to build the bayes optimization.

You could try to compile a simple C++ program first without CMake. E.g. store a simple main.cpp somewhere in your user directory C:\Users\<yourname>\Temp directory with following content:
int main()
{
return 0;
}
Now open CMD window in your C:\Users\<yourname>\Temp directory and run:
C:\MinGW\bin\gcc.exe main.cpp -o testprog
If an error popup appears that is saying something about a missing .dll, run following command in your CMD window and try to compile again:
set PATH=%PATH%;C:\MinGW\bin
If you had to run the last command, add the C:\MinGW\bin path permanently. After all it should be possible to run CMake with MinGW as compiler.

Verify that your MinGW compiler for Windows is able to build a simple program without CMake, for example: Hello World
When it works, clean your cache and try again.

Related

How to setup mingw in vcpkg (Windows)

I tried to install mingw package from vcpkg but I got an error
C:\Users\Administrator\Downloads\vcpkg>vcpkg.exe install curl:x64-mingw-static
Computing installation plan...
The following packages will be built and installed:
curl[core,non-http,schannel,ssl,sspi]:x64-mingw-static -> 7.82.0
* zlib[core]:x64-mingw-static -> 1.2.12
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-mingw-static...
Error: while detecting compiler information:
The log content at C:\Users\Administrator\Downloads\vcpkg\buildtrees\detect_compiler\stdout-x64-mingw-static.log is:
-- Configuring x64-mingw-static
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:128 (message):
Command failed: ninja -v
Working Directory: C:/Users/Administrator/Downloads/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/vcpkg-parallel-configure
Error code: 1
See logs for more information:
C:\Users\Administrator\Downloads\vcpkg\buildtrees\detect_compiler\config-x64-mingw-static-out.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_configure_cmake.cmake:370 (vcpkg_execute_required_process)
scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake)
scripts/ports.cmake:145 (include)
Error: vcpkg was unable to detect the active compiler's information. See above for the CMake failure output.
C:\Users\Administrator\Downloads\vcpkg>
How can I fix it? I have mingw installed on C:/mingw64 and C:/mingw32 and I'm using them in CLion without problems
Error in config-x64-mingw-static-out.log
[1/1] cmd /c "cd .. && "C:/Users/Administrator/Downloads/vcpkg/downloads/tools/cmake-3.22.2-windows/cmake-3.22.2-windows-i386/bin/cmake.exe" "C:/Users/Administrator/Downloads/vcpkg/scripts/detect_compiler" "-DCMAKE_MAKE_PROGRAM=C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe" "-DBUILD_SHARED_LIBS=OFF" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=C:/Users/Administrator/Downloads/vcpkg/scripts/toolchains/windows.cmake" "-DVCPKG_TARGET_TRIPLET=x64-windows-static" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=v143" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=C:/Users/Administrator/Downloads/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=static" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=C:/Users/Administrator/Downloads/vcpkg" "-DZ_VCPKG_ROOT_DIR=C:/Users/Administrator/Downloads/vcpkg" "-D_VCPKG_INSTALLED_DIR=C:/Users/Administrator/Downloads/vcpkg/installed" "-DVCPKG_MANIFEST_INSTALL=OFF" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=C:/Users/Administrator/Downloads/vcpkg/packages/detect_compiler_x64-windows-static""
-- The C compiler identification is MSVC 19.31.31107.0
-- The CXX compiler identification is MSVC 19.31.31107.0
#COMPILER_HASH#c3649029c7e070e5f43d9ce4d317605f000f9404
#COMPILER_C_HASH#2db604846bbf78fdf1b811ea56df2670f6b33536
#COMPILER_C_VERSION#19.31.31107.0
#COMPILER_C_ID#MSVC
#COMPILER_CXX_HASH#2db604846bbf78fdf1b811ea56df2670f6b33536
#COMPILER_CXX_VERSION#19.31.31107.0
#COMPILER_CXX_ID#MSVC
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
BUILD_SHARED_LIBS
CMAKE_INSTALL_BINDIR
CMAKE_INSTALL_LIBDIR
VCPKG_TARGET_ARCHITECTURE
_VCPKG_ROOT_DIR
-- Build files have been written to: C:/Users/Administrator/Downloads/vcpkg/buildtrees/detect_compiler/x64-windows-static-rel
It looks like it detects microsoft compiler instead of mingw
The problem was not set gcc.exe in PATH, adding it resolved problem

error when trying to compile with MinGW: cannot execute cc1plus

I did a clean install of MinGW on Windows 7 32bit with the GUI Installer, and installed
ming32-base-bin
mingw32-gcc-g++-bin
msys-base-bin
When trying to compile a simple "Hello World.cpp" from the cmd.exe i get the error:
C:\Users\Lorenzo\Desktop>g++ "Hello World.cpp" -o"Hello World.exe" -m32
g++: fatal error: cannot execute 'cc1plus': CreateProcess: No such file or directory.
compilation terminated.
The weird thing is that by grabbing the file from the desktop and putting it over g++.exe (so that i open the file with the application) in the MinGW directory, i don't get any error.
A temporary fix i found was to have a new environmet variable pointing in the folder where cc1plus is (C:\MinGW\libexec\gcc\mingw32\9.2.0). The program runs but doesn't include the libraries from C:/MinGw/lib and C:/MinGw/Include, i have to include those manually, which shouldn't occur (i guess).
I don't want to do this crude fix since i know i'll encounter some other problems with time.
Ok. I found the solution with some luck.
It is as simple as adding .exe to g++
> g++.exe *input file* -o*output.exe*
Don't Know if it's a bug or not, but this works for me.
I'm not sure which MinGW you used exactly, but it's better to use MinGW-w64.
There is a standalone build you can get from http://winlibs.com/ that doesn't require installation. The site also gives some instructions on how to use it.

lld-link: error: <root>: undefined symbol: mainCRTStartup when building V8

I've spent a whole day on this now and I can't seem to get the .lib files to build with VS 2017. I followed the V8 docs here:
https://v8.dev/docs/build
Following the instructions does work, but I end up with a V8 command line program in the out directory and .lib that do NOT work with Visual Studio 2017.
fatal error LNK1107: invalid or corrupt file: cannot read at 0x1422A
I executed this to try to get the build files for the libraries only:
gn gen out/lib --args="v8_static_library=true v8_use_snapshot=true v8_use_external_startup_data=false v8_monolithic=true icu_use_data_file=false is_component_build=false is_debug=false"
Then ran this: ninja -C out/lib
And this was the final result:
ninja: Entering directory `out/lib'
[1632/1645] LINK cctest.exe cctest.exe.pdb
FAILED: cctest.exe cctest.exe.pdb
ninja -t msvc -e environment.x64 -- ../../../../third_party/llvm-build/Release+Asserts/bin/lld-link.exe /nologo /OUT:./cctest.exe /PDB:./cctest.exe.pdb #./cctest.exe.rsp
lld-link: error: <root>: undefined symbol: mainCRTStartup
[1634/1645] LINK generate-bytecode-expectations.exe generate-bytecode-expectations.exe.pdb
ninja: build stopped: subcommand failed.
I think I'm missing something, but I have no idea at the moment.
Ok, seems my first mistake was changing the prompt to v8\tools\dev\ and working from there. The "normal" steps I found actually only work properly from the root of the source. I ended up with v8\tools\dev\out\x64.release then ninja -C out/x64.release v8 failed because v8 was not accepted in this setup for some reason.
The other thing I did wrong was to edit the args.gn file directly and save it. The CORRECT process is to run gn args out.gn\x64.release so that after you save AND close the editor, it automatically re-generates/updates the files. Most likely changing the file has no effect on its own, and you'll get confused because ninja won't even see the changes.
The linker error about corrupt files is because is_clang is true by default. Setting is_clang=false fixes that error. It just works, I have no idea why; just take it and go ... ;)
The correct way, from the root that worked for me is:
python tools\dev\v8gen.py x64.release
python tools\dev\v8gen.py ia32.release
python tools\dev\v8gen.py x64.debug
python tools\dev\v8gen.py ia32.debug
This will output files that can be compiled in the "v8\out.gn" folder.
Tip: Run "python tools\dev\v8gen.py list" to see a list of possible build configurations.
Next I updated the build arguments:
gn args out.gn\x64.release
Using these:
is_debug = false <-(or true for debug builds)
target_cpu = "x64"
is_component_build = false
v8_static_library = true
use_custom_libcxx = false
use_custom_libcxx_for_host = false
v8_use_external_startup_data = false <-(or true to use the bin startup files)
is_clang = false
And again for the 32-bit version (changing "x64" above to "x86" of course):
gn args out.gn\ia32.release
Then repeated all the above for x64.debug and ia32.debug.
And compiled them:
ninja -C out.gn/x64.debug v8
ninja -C out.gn/ia32.debug v8
ninja -C out.gn/x64.release v8
ninja -C out.gn/ia32.release v8
Visual Studio 2017 now builds and links my project against them again now (was an old project I resurrected).
Note: Linking against debug versions of V8 libraries may give an error that _ITERATOR_DEBUG_LEVEL does not match. To fix this I simply went to the C++ project settings (Confiuration Properties->C/C++->Preprocessor->Preprocesor Definitions) and added ;_ITERATOR_DEBUG_LEVEL=0 so it matches.

gcc compiler error when building on raspbian

I am trying to build openvibe! source code on raspbian and i have installed all the required dependencies, one by one manually, but in the end it seems to have a compilation error.
So after writing build files it says:
-- Build files have been written to: /home/pi/Desktop/openvibe-2.0.0-src/build/sdk-Release
Generation succeeded!
Building project...
and:
[1/340] Building CXX object build-tool...
[some dirty code here]
and then stops building sdk
returning this :
c++: error: unrecognized command line option ‘-msse2’
ninja: build stopped: subcommand failed.
ERROR: Build failed
Error while building sdk
I want to make it clear that i have searched everywhere and SOF is my last resort! So any help would be highly appreciated!
Judging by the output, you are building the library using cmake.
-msse2 is gcc compilation flag, which enables x86 sse vectorisation. Since you are compiling for raspbian you need to disable it.
Usually, compilation flags are set in CMakeLists.txt files. Find, the place where it was set:
find . -name CMakeLists.txt | xargs grep msse2
You will find something like:
# Switch -msse2 enables vectorization. Remove if your CPU/compiler doesn't support it.
SET(OV_EIGEN_FLAGS "-msse2")
As guided, remove every occurrence, and you are done.

Error building C++ project in HaxeDevelop

I use HaxeDevelop 5.2 and Haxe 3.4.2. I tried to build simple Hello world app in HaxeDevelop. But failed.
Here is the log:
Running process: C:\Program Files (x86)\HaxeDevelop\Tools\fdbuild\fdbuild.exe "E:\temp\New Project14\New Project14.hxproj" -ipc 7de8e6ea-dcd6-4496-acea-c62337a09d79 -version "3.4.2" -compiler "C:\HaxeToolkit\haxe" -notrace -library "C:\Program Files (x86)\HaxeDevelop\Library"
Building New Project14
haxe -cp src -cpp "E:/temp/New Project14/bin" -main Main
Unix.Unix_error(21, "open_proc", "haxelib path hxcpp")
Build halted with errors (haxe.exe).
Done(1).
What is the possible reason for this error? When I used the build command directly in the cmd.exe, it didn't fail. I've asked about this issue on github, but nobody has given any answer. FlashDevelop also failed.