Author Topic: Wont Build C code  (Read 39304 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 Jenna

  • 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: 7588
    • 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 Jenna

  • 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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Wont Build C code
« Reply #15 on: January 28, 2013, 02:59:01 pm »
I would say, it should work there.
Please verify that mingw32-g++.exe exists (in the bin-folder below the toolvhains masterpath) and is executable.

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Wont Build C code
« Reply #16 on: January 28, 2013, 03:20:53 pm »
The only partition i have on the local machine is C:\

Running as administrator makes no difference

Looking into the directors for MinGW

The directory being ,

C:\MinGW\bin\ ( supposed file )

in this dir i have the following

mingw32-cc.exe
mingw32-gcc.exe
mingw32-gcc-4.6.2.exe
mingw32-make.exe

Cheers

Rich


Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Wont Build C code
« Reply #17 on: January 28, 2013, 03:41:04 pm »
You (obviously) miss mingw32-g++.exe.
Pleaee install also the c++ compiler or (if you are really sure, that you never want to use c++) you can use migw32-gcc.exe as dynamic linker.

If you have installed codeblocks-12.11mingw-setup.exe, make sure the compilers masterpath points to the correct directoy.
It should be the MinGW-folder below C::B's installation directory.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Wont Build C code
« Reply #18 on: January 28, 2013, 03:46:08 pm »
You (obviously) miss mingw32-g++.exe.
Pleaee install also the c++ compiler or (if you are really sure, that you never want to use c++) you can use migw32-gcc.exe as dynamic linker.

If you have installed codeblocks-12.11mingw-setup.exe, make sure the compilers masterpath points to the correct directoy.
It should be the MinGW-folder below C::B's installation directory.

Remember most Mingw Installations will NOT work if there is a C:\MinGW MinGW installation in addition to the installation trying to be used.

Tim S.
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 #19 on: January 28, 2013, 04:25:07 pm »
OK Guys

I am getting confused here and i have to apologise for my lack of experience,

I have now uninstalled C:B and removed any trace of MinGW from my computer,

I have downloaded the latest version of CodeBlocks  , codeblocks-12.11mingw-setup

Is this all i need to get started? or do i need to download something else?

Can you advise ?

Jens, Where do i get the C++ compiler from? do i need to download it?

Tim, i have now removed all trace, there was a MinGW folder in C:\ but i am pretty sure that CodeBlocks installed that there,

Thanks so far guys :)

Rich
Thanks

Rich

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Wont Build C code
« Reply #20 on: January 28, 2013, 04:40:46 pm »
OK Guys , i am starting to win,

After reinstalling C::B  ( in admin mode ) :)

and checking all file paths, and clicking reset on the the compiler settings, i now have a working compilier,

I checked using a project i half built before, and it can compile and run,

When i tried to create a NEW project, and building it, i get this..


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

Linking stage skipped (build target has no object files to link)
Nothing to be done (all items are up-to-date).



I am not sure what a "linker" is, so maybe you could direct me

thankyou so much

Rich

Offline Rich_P

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Wont Build C code
« Reply #21 on: January 28, 2013, 05:01:04 pm »
Right, I have twigged it now

:-)

Its simply my complete lack of experience, i needed to add the source file to the project file for it to link and compile,

Thankyou guys, for all of the patience and help,

I am sure i willbe back to ask more questions,

I will try my hardest to work the answer out myself first :)

Thanks again

Rich