Author Topic: Ubuntu 13.04, codeblocks would not compile.  (Read 26717 times)

Offline vasilenko93

  • Single posting newcomer
  • *
  • Posts: 8
Ubuntu 13.04, codeblocks would not compile.
« on: August 19, 2013, 02:32:52 am »
I have installed build-essential, gdb, ibwxgtk2.8-0, and codeblocks from software center with all the add-ons.

But get this when I make a new console program and just build the default Hello World.

rmollenkamp

  • Guest
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #1 on: August 19, 2013, 02:36:18 am »
I have this exact same problem.  I cannot get the program to compile

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #2 on: August 19, 2013, 06:10:06 am »
Dou you have g++ installed ?
I'm not sure it is a dependency of the build-essential package.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #3 on: August 19, 2013, 06:32:53 am »
Dou you have g++ installed ?
I'm not sure it is a dependency of the build-essential package.
I just checked it, it is indeed a dependency, so please post the full error message from the build log, not tthe build messages.
And please use cut and paste and not a screenshot and put the text in code-tags (reachable via the #-button in the forums editor).

Offline vasilenko93

  • Single posting newcomer
  • *
  • Posts: 8
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #4 on: August 19, 2013, 04:45:45 pm »
I went into Environment settings and tried changing "Shell to run commands with:" to /bin/bash. Here is the result after I clicked build.
Code

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

g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programing/testProject/main.cpp -o obj/Debug/main.o
/bin/bash: g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programming/testProject/main.cpp -o obj/Debug/main.o: No such file or directory
Process terminated with status 127 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Same thing happens with the default /bin/sh.
Code

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

g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programing/testProject/main.cpp -o obj/Debug/main.o
/bin/sh: 0: Can't open g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programming/testProject/main.cpp -o obj/Debug/main.o
Process terminated with status 127 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I tried clicking both Debug and Release, with both shell programs. Still shows this error message.
« Last Edit: August 19, 2013, 05:10:42 pm by vasilenko93 »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #5 on: August 19, 2013, 04:57:52 pm »
What does g++ --version print on console ?
If it exists in path(I mean g++), can you try to run the command to compile your soucres from console ?

And of course: make sure you have read and write access to the project-folder and the subfolders.

Offline vasilenko93

  • Single posting newcomer
  • *
  • Posts: 8
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #6 on: August 19, 2013, 05:09:33 pm »
Code
g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3

Changed the permissions, now I have this.
/home/USER_NAME/Programming/testProject
the directory Programming and all of its sub-directories are with the permission rwxrwxrwx

Still has the same errors.
Code
g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programming/GDFFDF/main.cpp -o obj/Debug/main.o
/bin/bash: g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programming/GDFFDF/main.cpp -o obj/Debug/main.o: No such file or directory
"GDFFDF", I quickly made a new console application. No change.
« Last Edit: August 19, 2013, 05:11:50 pm by vasilenko93 »

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #7 on: August 19, 2013, 10:17:53 pm »
If you are dual-booting with Windows, it is a good idea to use a Linux-formatted (ext3 or ext4) partition. I've had similar strange issues when compiling on an NTFS partition from Linux.

Offline vasilenko93

  • Single posting newcomer
  • *
  • Posts: 8
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #8 on: August 19, 2013, 10:50:08 pm »
If you are dual-booting with Windows, it is a good idea to use a Linux-formatted (ext3 or ext4) partition. I've had similar strange issues when compiling on an NTFS partition from Linux.

My linux partition is ext4, and windows partition NTFS. And compiling is not the problem, I went into the folder that codeblocks created and compiled the Hell World program with g++ from terminal.
Code
g++ -o program main.cpp
It showed no errors, and I could run the program. Codeblocks could not for some reason do the same, even though the same compiler is used in both scenarios.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #9 on: August 19, 2013, 10:57:12 pm »
Please try it with the exact  same command from the projects root.
And check the user that owns the running C::B process, e.g by typing ps -eaf | grep codeblocks or by running the env command in the pre- or postbuild step of the project.

Offline Wyrm

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #10 on: August 20, 2013, 08:14:56 am »
I went into Environment settings and tried changing "Shell to run commands with:" to /bin/bash. Here is the result after I clicked build.
Code

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

g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programing/testProject/main.cpp -o obj/Debug/main.o
/bin/bash: g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programming/testProject/main.cpp -o obj/Debug/main.o: No such file or directory
Process terminated with status 127 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Same thing happens with the default /bin/sh.
Code

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

g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programing/testProject/main.cpp -o obj/Debug/main.o
/bin/sh: 0: Can't open g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programming/testProject/main.cpp -o obj/Debug/main.o
Process terminated with status 127 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I tried clicking both Debug and Release, with both shell programs. Still shows this error message.

You see this message because path "obj/Debug/main.o" is invalid on Linux. You need to change your configuration to something like "./obj/Debug/main.o" or "/full/path/to/obj/Debug/main.o".

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #11 on: August 20, 2013, 10:26:54 am »
I went into Environment settings and tried changing "Shell to run commands with:" to /bin/bash. Here is the result after I clicked build.
Code

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

g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programing/testProject/main.cpp -o obj/Debug/main.o
/bin/bash: g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programming/testProject/main.cpp -o obj/Debug/main.o: No such file or directory
Process terminated with status 127 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Same thing happens with the default /bin/sh.
Code

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

g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programing/testProject/main.cpp -o obj/Debug/main.o
/bin/sh: 0: Can't open g++ -Wall -fexceptions -g  -c /home/USER_NAME/Programming/testProject/main.cpp -o obj/Debug/main.o
Process terminated with status 127 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I tried clicking both Debug and Release, with both shell programs. Still shows this error message.

You see this message because path "obj/Debug/main.o" is invalid on Linux. You need to change your configuration to something like "./obj/Debug/main.o" or "/full/path/to/obj/Debug/main.o".

Sorry to say. but this is absolutely bullshit !!

What you mean is, that you have to prepend ./ to run executables from inside the folder they reside in.
This is not needed for the output or the input. Try e.g. redirecting with < or >.
This is also not needed if the exe is in a subfolder, in this case [relative_path_to_folder/[exe] is enough.
By the way. the single dot is just the relative path to the actual subfolder, so no difference to my last exampl.

Offline Wyrm

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #12 on: August 20, 2013, 04:45:48 pm »
Jens, you are right you can use it.

That said, I am still reasonably sure that in his case either (a) his current working directory is wrong or (b) Debug directory doesn't exists before he calls it. Directories Debug or Release may not exist if he deletes them on "make clean". Current working directory may be wrong if he calls it from another script or chain of scripts/tools.

If my conjecture is correct, please right click on the project -> Properties -> Select "Build targets" tab. On this tab, for both debug and release targets change "Objects output dir.:" to "./" and "Execution working dir.:" to "./". Remember to do it for both targets or at least for the one that you intend to test. Save settings and try compiling again. I know Jens will probably object but I'd encourage you to give it a try.
« Last Edit: August 20, 2013, 05:26:55 pm by Wyrm »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #13 on: August 20, 2013, 06:29:26 pm »
Don't do that or you get debug and release object files mixed and this might or might not work.

Try the exact same command from exact same folder (projects root folder), if that works, check the user that C::B really runs as and make sure no non-ascii characters are in the path (not even in username) given to the compiler or all discussion here is just a waste of time.

Offline vasilenko93

  • Single posting newcomer
  • *
  • Posts: 8
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #14 on: August 20, 2013, 09:56:58 pm »
Don't do that or you get debug and release object files mixed and this might or might not work.

Try the exact same command from exact same folder (projects root folder), if that works, check the user that C::B really runs as and make sure no non-ascii characters are in the path (not even in username) given to the compiler or all discussion here is just a waste of time.

Running the same command from terminal gives no errors. And when it comes to the user that runs codeblocks, its me I think.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #15 on: August 20, 2013, 10:12:22 pm »
What exactly do aou have in "Settings -> Environment -> General settings -> Shell to run commands in:" ?
Code
/bin/sh
or
Code
/bin/sh -c

The -c is a must !

By the way on systems with bash as default shell (as on Ubuntu [and many more] as far as I know)  /bin/sh is just a symlink to /bin/bash so there should not be a difference.

Offline vasilenko93

  • Single posting newcomer
  • *
  • Posts: 8
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #16 on: August 20, 2013, 10:17:07 pm »
Thank you very much, finally works. Really odd that by default it comes with /bin/sh not /bin/sh -c

You are the best jens.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #17 on: August 20, 2013, 10:24:27 pm »
The default (when created from scratch, e.g. by deleting the default.conf or using a different personality) is "/bin/sh -c".
The default is hardcoded in globals.cpp:58 as follows:
Code
const wxString DEFAULT_CONSOLE_SHELL = _T("/bin/sh -c");
If this is really not the default for the C::B from Ubuntu's repo, they must have changed it.
In this case, please file a bug-report against the Ubuntu bug-tracker.

Offline Wyrm

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #18 on: August 21, 2013, 05:28:14 am »
Looks like you guys have already resolved the issue and Jens's idea was correct. Good call.
So what's the conclusion? Everyone on Ubuntu and derivatives must go to environment settings and add "-c" or compile C::B from source?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #19 on: August 21, 2013, 09:50:28 am »
Looks like you guys have already resolved the issue and Jens's idea was correct. Good call.
So what's the conclusion? Everyone on Ubuntu and derivatives must go to environment settings and add "-c" or compile C::B from source?

The default (when created from scratch, e.g. by deleting the default.conf or using a different personality) is "/bin/sh -c".
The default is hardcoded in globals.cpp:58 as follows:
Code
const wxString DEFAULT_CONSOLE_SHELL = _T("/bin/sh -c");
If this is really not the default for the C::B from Ubuntu's repo, they must have changed it.
In this case, please file a bug-report against the Ubuntu bug-tracker.

If the Ubuntu-maintainers really changed this (I can't believe this, because it would be to stupid, on the other hand it's Ubuntu ...  ;) ), there would be no other way to fix this, until they fix this.
Please try to start C::B with -p test parameter from commandline (or any other new personality) and check the default settings.

Offline vasilenko93

  • Single posting newcomer
  • *
  • Posts: 8
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #20 on: August 21, 2013, 05:54:52 pm »
I don't know if Ubuntu really did change the settings, or I did sometimes and re-installing the program kept them. Because I actually used the synaptic package manager to remove everything that has to do with codeblocks (installed through software center), and compiled it from source with the latest SVN. That did nothing (except fix broken add-on) because I guess my old codeblocks settings where still saved. Also it is not the first time I got this, before a fresh install of Ubuntu 12.10 and codeblocks from the software center still gave me this problem. SOFTWARE CENTER PROGRAMS ARE BUGGY!

But yes, the problem has been solved, just needed that extra -c.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Ubuntu 13.04, codeblocks would not compile.
« Reply #21 on: August 21, 2013, 06:05:03 pm »
This has nothing to do with software center,.
It's normal for programs to keep user configuration if the package gets removed.

And instead of blaming Ubuntu's repo it would have been better to test whether they really changed this setting.
I gave you an advice on how to do it (e.g. different personality).