Author Topic: New program returns value immediately  (Read 5757 times)

Offline MichKat

  • Single posting newcomer
  • *
  • Posts: 6
New program returns value immediately
« on: December 16, 2021, 12:41:23 pm »
Hi,
I have been using codeblock here and there but today after trying to create new file I wasn't even able to build it at first. After reinstalling codeblocks I am able to build new file but after running it I get a non 0 return value and the "Hello World!" isn't printed. If anyone has some idea what might be wrong please say.

SOLUTION EDIT: Renaming the file the project is in seems to have resolved it.
« Last Edit: December 16, 2021, 09:31:44 pm by MichKat »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: New program returns value immediately
« Reply #1 on: December 16, 2021, 01:20:26 pm »
Post a full rebuild log, see this for help

Offline MichKat

  • Single posting newcomer
  • *
  • Posts: 6
Re: New program returns value immediately
« Reply #2 on: December 16, 2021, 03:21:29 pm »
Sorry for not posting original post in correct format. However, after restarting the program after restarting the program I found out that the file obj\Debug\main.o doesn't seem to be created, created few projects with different options but some files are always not there. My antivirus doesn't seem to have prevented files from being created, and even after taking away permission to do so from it, new projects still didn't create those files. Old programs have all those files so I am not sure what is preventing creation of those files nor how to find it out.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: New program returns value immediately
« Reply #3 on: December 16, 2021, 03:25:11 pm »
In that case post a full rebuild log, see this for help

Offline gd_on

  • Lives here!
  • ****
  • Posts: 796
Re: New program returns value immediately
« Reply #4 on: December 16, 2021, 03:41:43 pm »
Look also carefully to your antivirus software. Last week, my antivirus decided that some executables in my compiler directory contained viruses. That was false positives, but of courses my own executables were not created...
IF it's not your first program, I suppose that you know that it's better to create a project and to check the option "Pause when execution ends" : this is a so common error.
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline MichKat

  • Single posting newcomer
  • *
  • Posts: 6
Re: New program returns value immediately
« Reply #5 on: December 16, 2021, 04:25:55 pm »
I hope this is the rebuild log.
Code

-------------- Clean: Debug in soc (compiler: GNU GCC Compiler)---------------

Cleaned "soc - Debug"

-------------- Build: Debug in soc (compiler: GNU GCC Compiler)---------------

g++.exe  -o bin\Debug\soc.exe obj\Debug\main.o   
g++.exe: error: obj\Debug\main.o: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 


Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: New program returns value immediately
« Reply #6 on: December 16, 2021, 04:38:05 pm »
There is no command for compiling main.cpp.

Go to Project -> Properties -> Build targets and select the Debug target. Then, in the lower right corner (Build target fiiles), look for main.cpp and check it. Close and do a full rebuild again.

Offline MichKat

  • Single posting newcomer
  • *
  • Posts: 6
Re: New program returns value immediately
« Reply #7 on: December 16, 2021, 05:44:51 pm »
Already had it as checked.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: New program returns value immediately
« Reply #8 on: December 16, 2021, 06:19:22 pm »
Then zip the project and attach it here.

Offline MichKat

  • Single posting newcomer
  • *
  • Posts: 6
Re: New program returns value immediately
« Reply #9 on: December 16, 2021, 06:32:17 pm »
Here it hopefully is.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: New program returns value immediately
« Reply #10 on: December 16, 2021, 07:11:55 pm »
Works here:
Code
-------------- Clean: Debug in soc (compiler: GNU GCC Compiler)---------------

Cleaned "soc - Debug"

-------------- Build: Debug in soc (compiler: GNU GCC Compiler)---------------

g++.exe -Wall -fexceptions -g  -c C:\Users\Miguel\Desktop\soc\main.cpp -o obj\Debug\main.o
g++.exe  -o bin\Debug\soc.exe obj\Debug\main.o   
Output file is bin\Debug\soc.exe with size 63.75 KB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))

The only thing I can think of is a bad compiler configuration, go to Settings -> Compiler -> Toolchain executables -> C++ compiler and check it is g++.exe

Offline MichKat

  • Single posting newcomer
  • *
  • Posts: 6
Re: New program returns value immediately
« Reply #11 on: December 16, 2021, 07:45:17 pm »
Thanks for help but it is g++.exe for C++, will try to play with antivirus and other software a little more. Thanks for help!