-2

I am sure there is an answer out there for this but I cannot track it down.

code is simply

#include <iostream>

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

Visual Studio runs the programs fine however when trying to compile from cmd

 Directory of C:\Users\ebump\OneDrive\Documents\test

05/20/2022  12:53 AM    <DIR>          .
05/20/2022  12:53 AM    <DIR>          ..
05/08/2021  06:42 PM             9,891 asuka.jpg
05/19/2022  08:18 PM        37,583,331 asuka2.jpg
05/20/2022  01:10 AM                82 steg.cpp
02/01/2021  05:32 PM        38,903,396 wet_circuits.wav
05/19/2022  08:15 PM        37,573,440 wet_circuits.zip
               5 File(s)    114,070,140 bytes
               2 Dir(s)  440,502,870,016 bytes free

C:\Users\ebump\OneDrive\Documents\test>g++ steg.cpp
steg.cpp:6:1: fatal error: Files: No such file or directory

what exactly is going on?

tried to update using Msys2

below is the output of g++ -v stegg.cpp

Reading specs from c:/program files (x86)/codeblocks/bin/../lib/gcc/i686-w64-mingw32/4.8.3/specs
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/program\ files\ (x86)/codeblocks/bin/../libexec/gcc/i686-w64-mingw32/4.8.3/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../gcc-4.8.3/configure --prefix=/opt/windows_32 --with-sysroot=/opt/windows_32 --libdir=/opt/windows_32/lib --mandir=/opt/windows_32/man --infodir=/opt/windows_32/info --enable-shared --disable-bootstrap --disable-multilib --with-arch=pentium3 --enable-threads=posix --enable-languages=c,c++ --enable-checking=release --enable-libgomp --with-system-zlib --with-python-dir=/lib/python2.7/site-packages --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --with-gnu-ld --verbose --enable-java-home --with-java-home=/opt/windows_32/lib/jvm/jre --with-jvm-root-dir=/opt/windows_32/lib/jvm --with-jvm-jar-dir=/opt/windows_32/lib/jvm/jvm-exports --with-arch-directory=amd64 --with-antlr-jar='/home/adrien/projects/win-builds-1.5/slackware64-current/d/gcc/antlr-*.jar' --disable-java-awt --disable-gtktest --build=x86_64-slackware-linux --host=i686-w64-mingw32 --target=i686-w64-mingw32
Thread model: posix
gcc version 4.8.3 (GCC)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=pentium3'
 c:/program files (x86)/codeblocks/bin/../libexec/gcc/i686-w64-mingw32/4.8.3/cc1plus.exe -quiet -v -iprefix c:\program files (x86)\codeblocks\bin\../lib/gcc/i686-w64-mingw32/4.8.3/ -D_REENTRANT steg.cpp -quiet -dumpbase steg.cpp -mtune=generic -march=pentium3 -auxbase steg -version -IC:/Program Files (x86)/Codeblocks/include -o C:\Users\ebump\AppData\Local\Temp\ccUYYiRX.s
GNU C++ (GCC) version 4.8.3 (i686-w64-mingw32)
        compiled by GNU C version 4.8.3, GMP version 5.1.3, MPFR version 3.1.2, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/program files (x86)/codeblocks/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3"
ignoring duplicate directory "c:/program files (x86)/codeblocks/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3/i686-w64-mingw32"
ignoring duplicate directory "c:/program files (x86)/codeblocks/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3/backward"
ignoring duplicate directory "c:/program files (x86)/codeblocks/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/include"
ignoring nonexistent directory "/opt/windows_32/opt/windows_32/lib/gcc/i686-w64-mingw32/4.8.3/../../../../include"
ignoring duplicate directory "c:/program files (x86)/codeblocks/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/include-fixed"
ignoring duplicate directory "c:/program files (x86)/codeblocks/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.8.3/../../../../i686-w64-mingw32/include"
ignoring nonexistent directory "/opt/windows_32/mingw/include"
ignoring nonexistent directory "C:/Program"
#include "..." search starts here:
#include <...> search starts here:
 c:\program files (x86)\codeblocks\bin\../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3
 c:\program files (x86)\codeblocks\bin\../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3/i686-w64-mingw32
 c:\program files (x86)\codeblocks\bin\../lib/gcc/i686-w64-mingw32/4.8.3/../../../../include/c++/4.8.3/backward
 c:\program files (x86)\codeblocks\bin\../lib/gcc/i686-w64-mingw32/4.8.3/include
 c:\program files (x86)\codeblocks\bin\../lib/gcc/i686-w64-mingw32/4.8.3/include-fixed
 c:\program files (x86)\codeblocks\bin\../lib/gcc/i686-w64-mingw32/4.8.3/../../../../i686-w64-mingw32/include
End of search list.
GNU C++ (GCC) version 4.8.3 (i686-w64-mingw32)
        compiled by GNU C version 4.8.3, GMP version 5.1.3, MPFR version 3.1.2, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: c4fe4d0d4d1dfaca074c710f8d712c81
steg.cpp:6:1: fatal error: Files: No such file or directory
 }
 ^
compilation terminated.
  • Please [don't show images of text](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors-when-asking-a-question). Copy-paste text *as text* into your questions instead. Also please take some time to read [the help pages](http://stackoverflow.com/help), take the SO [tour], read [ask], as well as [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – Some programmer dude May 20 '22 at 05:22
  • There is probably something wrong with the way you installed or configured `g++`. Please explain how you did that. – Nate Eldredge May 20 '22 at 05:25
  • Honestly I cannot remember... g++ --version shows g++ (GCC) 4.8.3 – Dilli Vanilli May 20 '22 at 05:26
  • 1
    The quickest approach may just be to reinstall; you have a very old version anyway. But if you really want to fix your current installation, then try compiling with `g++ -v steg.cpp` and post the output. – Nate Eldredge May 20 '22 at 05:33
  • Is this your *actual* command and output? Did you redact it in any way? – HolyBlackCat May 20 '22 at 05:46
  • Consider updating your compiler, GCC 4.8 is ancient. [MSYS2](https://stackoverflow.com/q/30069830/2752075) provides an up-to-date version. – HolyBlackCat May 20 '22 at 05:47
  • I tried to reinstall but I don't think I got rid of the old one correctly. – Dilli Vanilli May 20 '22 at 05:47
  • Updated the original post to include the g++ -v steg.cpp output – Dilli Vanilli May 20 '22 at 05:59
  • Use `@username` when replying in comments, otherwise we don't get notifications. – HolyBlackCat May 20 '22 at 06:15
  • 1
    It's probably getting confused because of the spaces in the compiler path. But ultimately it doesn't matter, you need a new (up-to-date) compiler anyway, and MSYS2 installs to a path without spaces by default (unsure if its compiler would tolerate spaces or not). The output you're showing us is *not* from MSYS2, it's from your old compiler. – HolyBlackCat May 20 '22 at 06:16
  • @HolyBlackCat I figured it out, it was an incorrect path variable causing my issue, thank you so much for your support and suggestions through this – Dilli Vanilli May 20 '22 at 06:32

2 Answers2

0

Solved... issue was related to incorrect PATH variables

The problem was that C:\Program Files (x86)\Codeblocks\bin existed above C:\msys64\usr\bin in the system variables, so despite having updated g++ the system continued to look at the ancient version of g++ before the up to date version.

  • 1
    Can you explain more? If someone gets the same problem and finds this thread, it would be nice to have a proper answer waiting for them. – HolyBlackCat May 20 '22 at 06:39
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – KiynL May 21 '22 at 11:03
-1

If your program is working with Visual Studio IDE, you can compile it using VS Developer command prompt.

Please click the Start Menu, select "Developer Command Prompt for VS 2022" it will open a terminal window, then navigate to the directory where your source code is located and run the following command

cl /EHsc test.cpp  # to compile the pogram
test.exe           # to run the program

Visual Studio Command Prompt

Compile using cl compiler

Aamir
  • 1,974
  • 1
  • 14
  • 18