Author Topic: Unable to compile a first D language program  (Read 4288 times)

Offline CodeBlocky

  • Single posting newcomer
  • *
  • Posts: 6
Unable to compile a first D language program
« on: June 14, 2021, 08:38:55 am »
I installed Code:Blocks for Windows and it detected the gcc C compiler and Digital Mars D compilers on my system. But when I created a D program and went to compile it Code::Blocks had set the GNU D compiler (GDC) as the compiler to use. That is not on my system and it failed. So I went and changed the compiler for the project to the DMD compiler. However, trying to compile with the Digital Mars compiler fails because Code::Blocks is putting a compiler option of -Wall which DMD does not support. I cannot see that setting in the Project->Build Options->Compiler Settings so I don't know how to get rid of it.

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 787
Re: Unable to compile a first D language program
« Reply #1 on: June 14, 2021, 08:43:52 am »
You can look also in Settings -> Compiler

Offline CodeBlocky

  • Single posting newcomer
  • *
  • Posts: 6
Re: Unable to compile a first D language program
« Reply #2 on: June 14, 2021, 09:34:13 am »
You can look also in Settings -> Compiler

Thanks for the reply. If I go there it gives me the settings which only apply to the DMD Windows compiler and there is no -Wall option and the "Other compiler options" tab is blank.

I notice that my "cbp" file was not updated when I changed the compiler in Code::Blocks. That file still thinks I am using gdc and has the -Wall option in it:

      <Compiler>
         <Add option="-Wall" />
      </Compiler>

 And yet doing a build invokes the DMD compiler??

But apparently it is ignoring that file as when I removed -Wall from it and set the correct compiler it still invokes DMD with the -Wall option.

I got out of Code::Blocks and back in and it still wants to add -Wall to a command line that is invoking DMD, which does not support that option.
------------------------------------------
I relooked at the cbp file and while I thought I had removed the -Wall option, it was still there. I removed it (again?) and then I was able to get a successful compile.
« Last Edit: June 14, 2021, 09:44:32 am by CodeBlocky »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Unable to compile a first D language program
« Reply #3 on: June 14, 2021, 09:59:35 am »
This can be edited in the GUI using Project -> Build options -> [target or project] -> Compiler settings -> Other compiler settings
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline CodeBlocky

  • Single posting newcomer
  • *
  • Posts: 6
Re: Unable to compile a first D language program
« Reply #4 on: June 14, 2021, 11:56:22 am »
This can be edited in the GUI using Project -> Build options -> [target or project] -> Compiler settings -> Other compiler settings

Thanks for the reply.  I looked at that tab, but it was blank/empty.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Unable to compile a first D language program
« Reply #5 on: June 14, 2021, 12:19:01 pm »
Before or after editing the cbp file with a text editor?
I suppose the Compiler Flags tab doesn't have a "-Wall" option.
Keep in mind that these compilers are rarely used in codeblocks, so they might be outdated.
Also keep in mind that last time (12+ years ago) I've tried D in C::B the dependency tracking didn't work well/at all, so you might need to do full rebuilds every time you change something major.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline CodeBlocky

  • Single posting newcomer
  • *
  • Posts: 6
Re: Unable to compile a first D language program
« Reply #6 on: June 15, 2021, 01:43:48 am »
Before or after editing the cbp file with a text editor?

Before and after.

Quote
I suppose the Compiler Flags tab doesn't have a "-Wall" option.

It has one if I change the compiler back to GNU GDC. 



I may have been able to solve my problem with it using a DMD compiler and GDC flags if I had saved the project to update the project file to DMD. Although I am not sure how it would use a mix of program settings and project file settings. But I can't test that now because, while it started up initially with GDC as the default, now it won't let me switch to GDC as the default because it correctly says that it can't find it on my system.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Unable to compile a first D language program
« Reply #7 on: June 15, 2021, 02:10:01 am »
When switching compilers C::B tries to match flags set for the old compiler in the new compiler.
If a flag is found in the new compiler it is set and you see a checkbox in the Flags tab.
If it is not found it is transferred as a string option in the "Other compiler options".
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline CodeBlocky

  • Single posting newcomer
  • *
  • Posts: 6
Re: Unable to compile a first D language program
« Reply #8 on: June 16, 2021, 04:38:58 am »
I tried to duplicate the issue by uninstalling and re-installing Code::Blocks. But apparently just getting rid of C:\Program Files\CodeBlocks (via an uninstall) is not enough. There appears to be some other file which is in my user space which the uninstall misses, because this time the same install executable behaved differently. It did not tell me what compilers it had found on my system on first usage/setup. And the default compiler setting  on startup is Digital Mars D (DMD).
« Last Edit: June 16, 2021, 04:54:05 am by CodeBlocky »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Unable to compile a first D language program
« Reply #9 on: June 16, 2021, 11:32:30 am »
There is a CodeBlocks\default.conf in you AppData somewhere. Any modern software doesn't store user preferences next to the installation. They are all per user.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline CodeBlocky

  • Single posting newcomer
  • *
  • Posts: 6
Re: Unable to compile a first D language program
« Reply #10 on: June 18, 2021, 12:13:34 am »
There is a CodeBlocks\default.conf in you AppData somewhere. Any modern software doesn't store user preferences next to the installation. They are all per user.

OK. I believe some programs will ask to delete files like that during an uninstall which is ideal.

But anyway, I deleted the AppData/Roaming/CodeBlocks directory and did a reinstall and this time I did ultimately see -Wall in "Other compiler options" and when I deleted it the compile succeeded. Thanks for the assistance!

There is the minor issue that Code::Blocks only detects the GNU GCC C Compiler and Digital Mars D compiler on first startup, but when I create a D project it tries to build it with the GNU GDC D compiler.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Unable to compile a first D language program
« Reply #11 on: June 18, 2021, 09:18:03 am »
You can select the compiler while you create the project. Isn't this the case for D projects?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]