Author Topic: Wont Build C code  (Read 39057 times)

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Wont Build C code
« on: January 25, 2013, 11:34:13 am »
HI All,

Im a newbie on here and to C, im learning from a book and woujld like to use CodeBlocks to compile the simple programs outlined in the book,

I keep getting this error when trying to build

Execution of 'mingw32-g++.exe  -o C:\simple\Simple2.exe C:\simple\Simple2.o' in 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\CodeBlocks' failed.

I hope someone can help

Rich

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Wont Build C code
« Reply #1 on: January 25, 2013, 12:39:04 pm »
Hello!
What installer did you use?
Have you installed a compiler?
Is the path in "Settings-> Compiler -> Toolchain executables" correct?

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Wont Build C code
« Reply #2 on: January 25, 2013, 12:55:32 pm »
Hi, thanks for the reply,

I havnt installed a separate compiler, i downloaded the entire insall from Code::Blocks and assumed the compilers were included?

The compilers installation directory has C:MinGW set,
Under the toolchain variables it has mingw32-gcc.exe in the C compiler list

Hope this helps to explain my situation

Rich

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Wont Build C code
« Reply #3 on: January 25, 2013, 01:42:36 pm »
Did you installed
codeblocks-12.11-setup.exe
or
codeblocks-12.11mingw-setup.exe
?

if you installed codeblocks-12.11-setup.exe then uninstall and use codeblocks-12.11mingw-setup.exe instead. Or install the gcc from http://tdm-gcc.tdragon.net/

if you have installed codeblocks-12.11mingw-setup.exe:
Is there a mingw32-gcc.exe on your system? If not reinstall.
otherwise point the compilers installation directory to the location of your mingw32-gcc

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Wont Build C code
« Reply #4 on: January 25, 2013, 02:08:25 pm »
I had the wrong one installed, so i have installed the correct one and have this issue now

Execution of 'mingw32-g++.exe  -o "C:\simple\Simple 3.exe" "C:\simple\Simple 3.o"' in 'C:\Users\richardpel\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\CodeBlocks' failed.

i selected "C" as my starting langueage but it seems to want to build it using the g++ compiler ? and not gcc?
I have checked int he folder that C::B is pointing to for its compiler and there is the ming32-gcc.exe

im stumped,

thanks

Rich

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Wont Build C code
« Reply #5 on: January 25, 2013, 05:54:35 pm »
It looks like the ending of your file is ".o" that can never work.
Try to create a simple project with the wizard.

If you create a file make sure you type the correct ending, C::B does not create the ending automagical.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7572
    • My Best Post
Re: Wont Build C code
« Reply #6 on: January 25, 2013, 05:59:28 pm »
I had the wrong one installed, so i have installed the correct one and have this issue now

Execution of 'mingw32-g++.exe  -o "C:\simple\Simple 3.exe" "C:\simple\Simple 3.o"' in 'C:\Users\richardpel\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\CodeBlocks' failed.

i selected "C" as my starting langueage but it seems to want to build it using the g++ compiler ? and not gcc?
I have checked int he folder that C::B is pointing to for its compiler and there is the ming32-gcc.exe

im stumped,

thanks

Rich

I am guessing you choose to only install a C compiler and not the C++ compiler.
Please post a full re-build log; so, I can confirm this.

The means do a re-build instead of a build!
After that post the full compiler log; so, I can see the compiler commands.
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Edit2: The command you posted in the error message looks like a linking command using the default c++ linker exe.

Tim S.
« Last Edit: January 25, 2013, 06:02:48 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Wont Build C code
« Reply #7 on: January 28, 2013, 10:06:12 am »
HI Tim,
When i open the Hello.C program, and try and BUILD it, i get the error i posted,

I dont get the option to REBUILD it as this option is greyed out in the toolbar.

Sorry to be such a pain in the arse

Hope you can help

Rich

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Wont Build C code
« Reply #8 on: January 28, 2013, 10:07:56 am »

Hi Jens,

I open the Hello.C code from the File..open Menu,

From there, i choose build, and get the error posted, with no option to rebuild

Rich

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Wont Build C code
« Reply #9 on: January 28, 2013, 10:12:19 am »
This is the full build Log from C::B

Thanks

Rich

mingw32-gcc.exe    -c "\\fs02\users\richardpel\C Code\hello.c" -o "\\fs02\users\richardpel\C Code\hello.o"
mingw32-g++.exe  -o "\\fs02\users\richardpel\C Code\hello.exe" "\\fs02\users\richardpel\C Code\hello.o"   
Execution of 'mingw32-g++.exe  -o "\\fs02\users\richardpel\C Code\hello.exe" "\\fs02\users\richardpel\C Code\hello.o"' in 'C:\Users\richardpel\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\CodeBlocks' failed.
Nothing to be done (all items are up-to-date).

Checking for existence: \\fs02\users\richardpel\C Code\hello.exe
Executing: C:\Program Files (x86)\CodeBlocks/cb_console_runner.exe "\\fs02\users\richardpel\C Code\hello.exe" (in \\fs02\users\richardpel\C Code)
Process terminated with status -1073741510 (0 minutes, 44 seconds)


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Wont Build C code
« Reply #10 on: January 28, 2013, 12:54:23 pm »
Does the \\fs02\users\richardpel\C Code\hello.exe exist?
Have you made a project, or only opened a c file?

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Wont Build C code
« Reply #11 on: January 28, 2013, 01:17:10 pm »
HI, The exe does not exist as i assumed this is generated when i click on build?

It is a base .c file i am opening and then pressing build,

I have tried creating from a project, and choosing "c" as the language,

writing the code into the window, saving the file and then building it, buti get the same error each time,

thanks

Rich

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Wont Build C code
« Reply #12 on: January 28, 2013, 01:24:02 pm »
Try to put the file or better the project into another folder, yours looks like a network folder.
Windows >= 7 is very (very !) restrictive when you try to create executables in folders it thinks you should not do that (without telling you anything about that).

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Wont Build C code
« Reply #13 on: January 28, 2013, 02:07:37 pm »
I Will try that Jen,

Just so as i am not being silly, i will describe my process from the start

1, Open C::B
2, Select "Create New Project"
3, Select "files" from left
4, select"C/C++"
5, Select next
6, Select "C"
7, Select the filename and where i want to save it to
8, Click ok
9, Write my "Hello World" code
10, hit save,
11, hit build

Get nothing except the error?

Hmm confused,

I tried building as a project, and importing the Hello.c file and then hitting build, and i got this message

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

mingw32-gcc.exe -Wall  -g     -c C:\simple\Hello\Hello.c -o obj\Debug\Hello.o
mingw32-g++.exe  -o bin\Debug\Hello.exe obj\Debug\Hello.o   
Execution of 'mingw32-g++.exe  -o bin\Debug\Hello.exe obj\Debug\Hello.o' in 'C:\simple\Hello' failed.
Nothing to be done (all items are up-to-date).

Am i making progress? lol

Rich

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Wont Build C code
« Reply #14 on: January 28, 2013, 02:11:33 pm »
"C:\simple\Hello\Hello.c -o obj\Debug\Hello.o"
"C:" is a bad place to save/build data.
Try to put the file or better the project into another folder, yours looks like a network folder.
Windows >= 7 is very (very !) restrictive when you try to create executables in folders it thinks you should not do that (without telling you anything about that).

Windows >= 7 is a b***h with the user rights. If you don't have a second partition, to test the build process, try to run codeblocks as admin, or to put your project in your home folder.