Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: cbnewbie on April 08, 2017, 11:01:07 pm

Title: cannot set default compiler
Post by: cbnewbie on April 08, 2017, 11:01:07 pm
Whenever I start codeblocks I see the dialog box to set the default compiler (gcc) but I cannot save the settings. Next time I start codeblocks it will ask me again...

I am using codeblocks svn build  rev 11045 Apr  8 2017, 17:13:43 - wx3.0.2 (Linux, unicode) - 64 bit. gcc is installed in /bin:

$ which ar g++ gcc make
/bin/ar
/bin/g++
/bin/gcc
/bin/make
$
Title: Re: cannot set default compiler
Post by: oBFusCATed on April 09, 2017, 12:49:40 am
Does c::b crash when you close it? Does it have proper permissions to save the default.conf file in ~/.config/codeblocks/default.conf?
Title: Re: cannot set default compiler
Post by: cbnewbie on April 09, 2017, 01:03:57 am
No, it does not crash.

$ ls -l .config/codeblocks/default.conf
-rw-r--r-- 1 mer mer 54727 Apr  9 02:02 .config/codeblocks/default.conf
$

I am user "mer".
Title: Re: cannot set default compiler
Post by: stahta01 on April 09, 2017, 01:13:55 am
Did you scroll down on the screen and see if another compiler has the setting problem?

Tim S.
Title: Re: cannot set default compiler
Post by: cbnewbie on April 09, 2017, 01:37:52 am
I have just removed clang to see whether the problem remains if only gcc is installed. Nothing changed. On my system cb ist installed in $HOME/IDE. Can this cause troubles?
Title: Re: cannot set default compiler
Post by: cbnewbie on April 09, 2017, 01:59:21 am
I have just tried to change the compiler settings from inside cb. It seems that cb finds the required executables (gcc, etc.) but it does not set the path. And if I click on "Reset defaults" I get an error message:

ASSERT INFO:
./include/wx/msgdlg.h(138): assert "!(style & wxNO_DEFAULT) || (style & wxNO)" failed in SetMessageDialogStyle(): wxNO_DEFAULT is invalid without wxNO

BACKTRACE:
[1] wxMessageDialog::wxMessageDialog(wxWindow*, wxString const&, wxString const&, long, wxPoint const&)
[2] cbMessageBox(wxString const&, wxString const&, int, wxWindow*, int, int)
[3] CompilerOptionsDlg::OnResetCompilerClick(wxCommandEvent&)
[4] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const
[5] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)
[6] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[7] wxEvtHandler::TryHereOnly(wxEvent&)
[8] wxEvtHandler::ProcessEventLocally(wxEvent&)
[9] wxEvtHandler::ProcessEvent(wxEvent&)
[10] wxWindowBase::TryAfter(wxEvent&)
[11] wxWindowBase::TryAfter(wxEvent&)
[12] wxWindowBase::TryAfter(wxEvent&)
[13] wxEvtHandler::SafelyProcessEvent(wxEvent&)
[14] g_closure_invoke
[15] g_signal_emit_valist
[16] g_signal_emit
[17] g_closure_invoke
[18] g_signal_emit_valist
[19] g_signal_emit
[20] g_closure_invoke
[21] g_signal_emit_valist
[22] g_signal_emit
[23] gtk_propagate_event
[24] gtk_main_do_event
[25] g_main_context_dispatch
[26] g_main_loop_run
[27] gtk_main
[28] wxGUIEventLoop::DoRun()
[29] wxEventLoopBase::Run()
[30] wxDialog::ShowModal()
[31] MainFrame::OnSettingsCompiler(wxCommandEvent&)
[32] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const
[33] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)
[34] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[35] wxEvtHandler::TryHereOnly(wxEvent&)
[36] wxEvtHandler::DoTryChain(wxEvent&)
[37] wxEvtHandler::ProcessEvent(wxEvent&)
[38] wxWindowBase::TryAfter(wxEvent&)
[39] wxEvtHandler::SafelyProcessEvent(wxEvent&)
[40] wxMenuBase::SendEvent(int, int)
[41] g_closure_invoke
[42] g_signal_emit_valist
[43] g_signal_emit
[44] gtk_widget_activate
[45] gtk_menu_shell_activate_item
[46] g_closure_invoke
[47] g_signal_emit_valist
[48] g_signal_emit
[49] gtk_propagate_event
[50] gtk_main_do_event
[51] g_main_context_dispatch
[52] g_main_loop_run
[53] gtk_main
[54] wxGUIEventLoop::DoRun()
[55] wxEventLoopBase::Run()
[56] wxAppConsoleBase::MainLoop()
[57] CodeBlocksApp::OnRun()
[58] wxEntry(int&, wchar_t**)
[59] main
[60] __libc_start_main
[61] _start /home/iurt/rpmbuild/BUILD/glibc-2.22/csu/../sysdeps/x86_64/start.S:121
Title: Re: cannot set default compiler
Post by: BlueHazzard on April 09, 2017, 07:40:11 pm
does the date/time of the config file change if you close codeblocks?
If you set the path by hand, save and close c::b does this work?
Title: Re: cannot set default compiler
Post by: oBFusCATed on April 09, 2017, 08:52:06 pm
What happens if you click on the ignore button (don't know exact spelling) on the assert message dialog?
Title: Re: cannot set default compiler
Post by: cbnewbie on April 09, 2017, 09:44:07 pm
@BlueHazzard:

Date/time of default.conf changes when I close cb. Is it written every time when I close cb? However, the next time I start cb after explicitely setting the path cb does not remember the setting. It will again tell me that gcc has been detected and shows an empty path field.

$ cp default.conf default.conf.org

... running and closing cb after setting path to /bin ...

$ diff default.conf default.conf.org
878c878
<                                               <![CDATA]>
---
>                                               <![CDATA[fun]]>
883c883
<                                               <![CDATA[subroutine |()\n    \nend subroutine\n]]>
---
>                                               <![CDATA[function |()\n    \nend function\n]]>
895c895
<                                               <![CDATA[fun]]>
---
>                                               <![CDATA]>
900c900
<                                               <![CDATA[function |()\n    \nend function\n]]>
---
>                                               <![CDATA[subroutine |()\n    \nend subroutine\n]]>
1105c1105
<                                               <![CDATA[tday]]>
---
>                                               <![CDATA[guard]]>
1110c1110
<                                               <![CDATA[$TDAY]]>
---
>                                               <![CDATA[#ifndef $(Guard token)\n#define $(Guard token)\n\n|\n\n#endif // $(Guard token)\n]]>                                                                                                                                         
1117c1117                                                                                                                                 
<                                               <![CDATA[guard]]>                                                                         
---                                                                                                                                       
>                                               <![CDATA[tday]]>                                                                           
1122c1122                                                                                                                                 
<                                               <![CDATA[#ifndef $(Guard token)\n#define $(Guard token)\n\n|\n\n#endif // $(Guard token)\n]]>                                                                                                                                         
---                                                                                                                                       
>                                               <![CDATA[$TDAY]]>
1416,1420d1415
<                               <MASTER_PATH>
<                                       <str>
<                                               <![CDATA[/bin]]>
<                                       </str>
<                               </MASTER_PATH>
$


@oBFusCATed:

There are two buttons: Continue and Stop. If I click on Continue the error message will appear again. If I click on Stop cb will crash.
Title: Re: cannot set default compiler
Post by: oBFusCATed on April 10, 2017, 09:45:03 am
Click the second continue. What happens?
Title: Re: cannot set default compiler
Post by: cbnewbie on April 10, 2017, 11:28:52 am
If I click a second time the following happens:

Reset this compiler's settings to the defaults?
buttons: OK | Cancel

Cancel -> nothing happens

OK -> The same error (assert) appears again.
buttons: Stop | Continue

Stop -> cb crashes

Continue -> Reset this compiler's settings to the defaults? Are you REALLY sure?
buttons: OK | Cancel

Cancel -> nothing happens

OK -> Auto-detected installation path of of "GNU GCC compiler ""
buttons: OK

Title: Re: cannot set default compiler
Post by: oBFusCATed on April 10, 2017, 08:40:22 pm
Is the path correct after you click the final OK button?
Title: Re: cannot set default compiler
Post by: cbnewbie on April 10, 2017, 09:23:23 pm
No. The path is still empty. Maybe there are two problems:

GNU gcc is installed in /etc/alternatives/bin with links in /bin and /usr/bin. Does cb have difficulties to extract the path from the link?

The second problem is that default.conf is not correctly updated or not read properly. The changes I add will be ignored the next time cb starts.
Title: Re: cannot set default compiler
Post by: BlueHazzard on April 10, 2017, 11:55:52 pm
GNU gcc is installed in /etc/alternatives/bin with links in /bin and /usr/bin. Does cb have difficulties to extract the path from the link?
does this "alternatives" has some special, non ascii characters?
Title: Re: cannot set default compiler
Post by: oBFusCATed on April 11, 2017, 12:47:56 am
Do you have a compiler (gcc, g++) in /usr/bin?
Can you run codeblocks under strace to see if default.conf is written and if there is any error for the open/read/write/close calls codeblocks is doing?
If  you don't know how to read the strace log, just save it in a file and paste bin it somewhere, so we can take a look.
Title: Re: cannot set default compiler
Post by: cbnewbie on April 11, 2017, 01:24:28 am
This is interesting. I am using Mageia Linux and gcc is installed in /usr (see mageia-gcc.txt). But there are some links between /bin, /usr/bin and /etc/alternatives:

$ cd /etc/alternatives
$ ls -l gcc
lrwxrwxrwx 1 root root 18 Mär 29 21:09 gcc -> /usr/bin/gcc-5.4.0*
$ cd /usr/bin/
$ ls -l gcc
lrwxrwxrwx 1 root root 21 Mär 29 21:09 gcc -> /etc/alternatives/gcc*
$ cd /bin
$ ls -l gcc
lrwxrwxrwx 1 root root 21 Mär 29 21:09 gcc -> /etc/alternatives/gcc*
$
Title: Re: cannot set default compiler
Post by: cbnewbie on April 11, 2017, 01:31:12 am
I attached two files with the output of strace.

What I did: I started cb, selected the detected compiler as default at start up. When cb was running I tried to auto-detect the compiler because the toolchain path was still empty. After setting the path manually to /usr I closed cb.
Title: Re: cannot set default compiler
Post by: oBFusCATed on April 11, 2017, 01:59:53 am
Please - do the following:
1. start cb under strace
2. open settings -> editor
3. change some settings (switch any checkbox)
4. press ok
5. close cb

Then post the log, but first start cb again and check if the settings is saved...
Title: Re: cannot set default compiler
Post by: cbnewbie on April 11, 2017, 12:12:03 pm
This time I did the following:

1. start cb under strace
2. open settings -> editor
3. change some settings (switch any checkbox) -> check "Detect indent style" and "Use TAB character"
4. press ok
5. close cb
6. start cb again -> previously checked options have been saved!

I had to split and compress the strace output file into two parts: cb_strace_03.7z and cb_strace_04.7z
Title: Re: cannot set default compiler
Post by: oBFusCATed on April 12, 2017, 12:37:09 am
Can you please post a single file? Use a paste bin like service if the forum doesn't allow big attachments!
Title: Re: cannot set default compiler
Post by: oBFusCATed on April 12, 2017, 12:41:45 am
It seems that 03 is after 04. Is this the case?
Also it seems that the file is written successfully:
Code
stat("/home/mer/.config/codeblocks/default.conf", {st_mode=S_IFREG|0664, st_size=36236, ...}) = 0
lstat("/home/mer/.config/codeblocks/default.conf", {st_mode=S_IFREG|0664, st_size=36236, ...}) = 0
access("/home/mer/.config/codeblocks/default.conf", W_OK) = 0
lstat("/home/mer/.config/codeblocks/default.conf", {st_mode=S_IFREG|0664, st_size=36236, ...}) = 0
open("/home/mer/.config/codeblocks/default.conf.temp", O_WRONLY|O_CREAT|O_TRUNC, 0100664) = 5
write(5, "<?xml version=\"1.0\" encoding=\"UT"..., 47512) = 47512
close(5)                                = 0
rename("/home/mer/.config/codeblocks/default.conf.temp", "/home/mer/.config/codeblocks/default.conf") = 0

Do you have dropbox or something similar setup for your home folder? I've heard complaints of brokenness in such setups.
Does the modification time of the file changes?
Title: Re: cannot set default compiler
Post by: cbnewbie on April 12, 2017, 02:25:35 pm
Yes, 04 is first part, 03 is second part. Sorry!

Yes, the file (default.conf) gets a new timestamp and when I open cb again it remebers my choices (selected checkboxes). The only thing which causes problems is that whenever I try to set the toolchain path to a different folder than the "auto-detect folder" cb does not keep that path. It seems to me that cb ignores any valid path and fills in its "auto-detect folder" during start up. As mentioned before gcc is installed in /usr/bin with a link also in /bin. Since /bin is before /usr/bin in my $PATH cb finds /bin/gcc first. Obviously cb accepts the first found gcc as default - which makes sense - but it does not care whether another valid path has already been specified. So, I cannot set another toolchain path for gcc.

No, I do not have dropbox.
Title: Re: cannot set default compiler
Post by: BlueHazzard on April 12, 2017, 06:06:38 pm
Do you hit "Auto detect"?
Title: Re: cannot set default compiler
Post by: cbnewbie on April 12, 2017, 09:00:58 pm
Yes, I did. But it did not change something. During startup cb always puts the path of the first detected gcc in the edit field of the toolchain path. No matter whether I selected a different valid path or not. Maybe "auto-detect" does always run during startup? Even if it is not neccessary .
Title: Re: cannot set default compiler
Post by: oBFusCATed on April 13, 2017, 08:58:13 am
Don't know what is going on. :(
You'll have to debug it to find why it opens the dialog every time.

But it is really strange that Mageia devs have decided to place something like gcc in /bin.
Are you really sure it is there? Can you do find /bin -ls?
What happens if you set the path to /usr?
Btw have you seen the note below the path control that states that you have to remove the bin from the path you enter?
Title: Re: cannot set default compiler
Post by: cbnewbie on April 13, 2017, 12:07:21 pm
$ ls -l /bin/gcc                                                                                                           
lrwxrwxrwx 1 root root 21 Mär 29 21:09 /bin/gcc -> /etc/alternatives/gcc*                                                                 
$ ls -l /etc/alternatives/gcc                                                                                               
lrwxrwxrwx 1 root root 18 Mär 29 21:09 /etc/alternatives/gcc -> /usr/bin/gcc-5.4.0*                                                       
$ ls -l /usr/bin/gcc-5.4.0                                                                                                 
-rwxr-xr-x 1 root root 895864 Mär 26 22:02 /usr/bin/gcc-5.4.0*                                                                             
$ ls -l /usr/bin/gcc
lrwxrwxrwx 1 root root 21 Mär 29 21:09 /usr/bin/gcc -> /etc/alternatives/gcc*

Yes, I have removed "bin" from the path. But there is already something wrong because "auto-detect" should at least fill in "/" in the toolchain path. However, this field is always empty after startup - even if I select "/usr" and close cb normally.
                         
Title: Re: cannot set default compiler
Post by: oBFusCATed on April 13, 2017, 08:51:03 pm
Try a night build and if it fails you'll have to debug it yourself or demonstrate how to reproduce it in a more mainstream linux distribution.