c++codeblocksaccess-denied

Error: id returned 5 exit status when building C++ code in Code::Blocks


I'm encountering an issue in Code::Blocks where attempting to build C++ code results in the error message "Error: id returned 5 exit status," even when there are no syntax errors present in the code. Here's an example:

#include <iostream>

int main() {
    std::cout<<"hello world";
    }

Even for this simple code snippet, the same error occurs. The full "rebuild all" log is here


        -------------- Clean: Release in GraphicsC++ (compiler: GNU GCC 
        Compiler)---------------
    
        Cleaned "GraphicsC++ - Release"
    
        -------------- Build: Release in GraphicsC++ (compiler: GNU GCC 
        Compiler)---------------
    
        g++.exe -Wall --verbose -fexceptions -O2 -Iinclude -c 
        C:\Users\ALEX\Documents\GraphicsC++\main.cpp -o obj\Release\main.o
        g++.exe  -o bin\Release\GraphicsC++.exe obj\Release\main.o  --verbose - 
        s  ..\..\..\..\Windows\SysWOW64\glu32.dll
        Using built-in specs.
        COLLECT_GCC=g++.exe
        Target: x86_64-w64-mingw32
        Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64- 
        mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 -- 
        prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-seh-rt_v6- 
        rev0/mingw64 --enable-shared --enable-static --disable-multilib -- 
        enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes -- 
        enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto - 
        -enable-graphite --enable-checking=release --enable-fully-dynamic- 
        string --enable-version-specific-runtime-libs --disable-libstdcxx-pch - 
        -disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable- 
        win32-registry --disable-nls --disable-werror --disable-symvers --with- 
        gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with- 
        libiconv --with-system-zlib --with- 
        gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with- 
        mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with- 
        mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with- 
        isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with- 
        pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with- 
        bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe - 
        fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6- 
        rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib- 
        static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32- 
        static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64- 
        810-posix-seh-rt_v6-rev0/mingw64/opt/include - 
        I/c/mingw810/prerequisites/x86_64-zlib-static/include - 
        I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' 
        CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-seh-rt_v6- 
        rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib- 
        static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32- 
        static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810- 
        posix-seh-rt_v6-rev0/mingw64/opt/lib - 
        L/c/mingw810/prerequisites/x86_64-zlib-static/lib - 
        L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
        Thread model: posix
        gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 
        COLLECT_GCC_OPTIONS='-Wall' '-v' '-fexceptions' '-O2' '-I' 'include' '- 
        c' '-o' 'obj\Release\main.o' '-shared-libgcc' '-mtune=core2' '- 
        march=nocona'
        C:/Program Files/CodeBlocks/MinGW/bin/../libexec/gcc/x86_64-w64- 
        mingw32/8.1.0/cc1plus.exe -quiet -v -I include -iprefix C:/Program 
        Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/ - 
        D_REENTRANT C:\Users\ALEX\Documents\GraphicsC++\main.cpp -quiet - 
        dumpbase main.cpp -mtune=core2 -march=nocona -auxbase-strip 
        obj\Release\main.o -O2 -Wall -version -fexceptions -o 
        C:\Users\ALEX\AppData\Local\Temp\ccF1iSDG.s
        GNU C++14 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) version 
        8.1.0 (x86_64-w64-mingw32)
        compiled by GNU C version 8.1.0, GMP version 6.1.2, MPFR version 4.0.1, 
        MPC version 1.1.0, isl version isl-0.18-GMP
        GGC heuristics: --param ggc-min-expand=100 --param ggc-min-            heapsize=131072
        ignoring duplicate directory "C:/Program         Files/CodeBlocks/MinGW/lib/gcc/../../lib/gcc/x86_64-w64-    mingw32/8.1.0/include/c++"
        ignoring duplicate directory "C:/Program     Files/CodeBlocks/MinGW/lib/gcc/../../lib/gcc/x86_64-w64-    mingw32/8.1.0/include/c++/x86_64-w64-mingw32"
        ignoring duplicate directory "C:/Program     Files/CodeBlocks/MinGW/lib/gcc/../../lib/gcc/x86_64-w64-    mingw32/8.1.0/include/c++/backward"
        ignoring duplicate directory "C:/Program Files/CodeBlocks/MinGW/lib/gcc/../../lib/gcc/x86_64-w64-    mingw32/8.1.0/include"
        ignoring nonexistent directory "C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../include"
        ignoring duplicate directory "C:/Program Files/CodeBlocks/MinGW/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed"
        ignoring duplicate directory "C:/Program Files/CodeBlocks/MinGW/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"
        ignoring nonexistent directory "C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/mingw/include"
        #include "..." search starts here:
        #include <...> search starts here:
         include
         C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++
         C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32
         C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward
         C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include
         C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed
         C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include
        cc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64End of search list.
        GNU C++14 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) version 8.1.0 (x86_64-w64-mingw32)
            compiled by GNU C version 8.1.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.18-GMP
        GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
        Compiler executable checksum: 82f0c9785fd37a38ba7b7f8357369a82
        COLLECT_GCC_OPTIONS='-Wall' '-v' '-fexceptions' '-O2' '-I' 'include' '-c' '-o' 'obj\Release\main.o' '-shared-libgcc' '-mtune=core2' '-march=nocona'
         C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-    mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/as.exe -v -I include -o     obj\Release\main.o C:\Users\ALEX\AppData\Local\Temp\ccF1iSDG.s
        GNU assembler version 2.30 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.30
        COMPILER_PATH=C:/Program     Files/CodeBlocks/MinGW/bin/../libexec/gcc/x86_64-w64-    mingw32/8.1.0/;C:/Program     Files/CodeBlocks/MinGW/bin/../libexec/gcc/;C:/Program     Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-    mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/
        LIBRARY_PATH=C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/;C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/;C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/Program     Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-    mingw32/8.1.0/../../../../lib/;C:/Program     Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/;C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../
        COLLECT_GCC_OPTIONS='-Wall' '-v' '-fexceptions' '-O2' '-I' 'include' '-c' '-o' 'obj\Release\main.o' '-shared-libgcc' '-mtune=core2' '-    march=nocona'
        Using built-in specs.
        COLLECT_GCC=g++.exe
        COLLECT_LTO_WRAPPER=C:/Program\         Files/CodeBlocks/MinGW/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-    wrapper.exe
        Target: x86_64-w64-mingw32
        Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --    prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-seh-rt_v6-    rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-    languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-    threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-    graphite --enable-checking=release --enable-fully-dynamic-string --enable-    version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-    debug --enable-bootstrap --disable-rpath --disable-win32-registry --    disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld     --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --    with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-    mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-    mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-    isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-    pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-    bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-    ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -    I/c/mingw810/prerequisites/x86_64-zlib-static/include -    I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2     -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-    rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-    static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-    static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-seh-rt_v6-    rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-    static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-    static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-posix-    seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-    static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
        Thread model: posix
    gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 
        COMPILER_PATH=C:/Program Files/CodeBlocks/MinGW/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/;C:/Program Files/CodeBlocks/MinGW/bin/../libexec/gcc/;C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/
    LIBRARY_PATH=C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/;C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/;C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib/;C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/;C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../
        COLLECT_GCC_OPTIONS='-o' 'bin\Release\GraphicsC++.exe' '-v' '-s' '-shared-libgcc' '-mtune=core2' '-march=nocona'
         C:/Program Files/CodeBlocks/MinGW/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/collect2.exe -plugin C:/Program Files/CodeBlocks/MinGW/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/liblto_plugin-0.dll -plugin-opt=C:/Program Files/CodeBlocks/MinGW/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\ALEX\AppData\Local\Temp\ccXKJKe8.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-liconv -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 -m i386pep -Bdynamic -o bin\Release\GraphicsC++.exe -s C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/crtbegin.o -LC:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0 -LC:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc -LC:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib -LC:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib -LC:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../.. obj\Release\main.o ..\..\..\..\Windows\SysWOW64\glu32.dll -lstdc++ -    lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-    w64-mingw32/8.1.0/crtend.o
        collect2.exe: error: ld returned 5 exit status
        Process terminated with status 1 (0 minute(s), 0 second(s))
        1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I've tried various troubleshooting steps such as granting full control permissions to the entire Code::Blocks folder for all users and temporarily disabling my antivirus software. However, none of these solutions resolved the issue.

Interestingly, I discovered that running Code::Blocks as an administrator and then using the file manager to navigate to the .cpp file, followed by building and running the code, works fine. However, this workaround doesn't apply when opening a project that includes external libraries.

I'm using the default GNU GCC compiler in Code::Blocks.

Initially, I attempted to resolve the issue by granting full control permissions to the entire Code::Blocks folder for all users and temporarily disabling my antivirus software. However, these efforts did not resolve the error. My expectation was that these troubleshooting steps would rectify the issue and allow me to build C++ code without encountering the "Error: id returned 5 exit status" message.

I appreciate any suggestions or insights on how to resolve this issue. Thank you!


Solution

  • Here:

    g++.exe  -o bin\Release\GraphicsC++.exe obj\Release\main.o  -s  ..\..\..\..\Windows\SysWOW64\glu32.dll
    

    You are trying to statically link a DLL (glu32.dll). You cannot do that, and your "simple code snippet" does not need OpenGL in any event.

    Moreover you cannot normally statically link code built using a different incompatible toolchain. If you do need to link the OpenGL Utility library in your code, you should link the MinGW provided export library with the command line switch -lglu32. That will cause the appropriate Windows provided DLL to be loaded at runtime. The linker will look in various places to find the export library - all those places specified by -L <path> switches in the "verbose" log. That will work for OS provided DLLs. If you add third-party libraries you will need to add your own -L <path> switches (there will be a place for that in the IDE rather then specifying them directly nod doubt).

    You should not try to link a specific DLL path - and using a relative path is bound to fail at some time, it rather assumes that your project will always be in the same place relative to the DLL.

    Linking the OpenGL Utility library on its own with no other OpenGL support probably won't be useful either - but that is a different issue.