Debug and Release builds using the same settings

Debug and Release builds using the same settings

481
Basic UserBasic User
481

    Jul 19, 2013#1

    Hi,

    I'm using UES 13 as a replacement for VS2010 (and it's going well so far!).

    I'm in an environment where I'm building a DLL that in debug configuration links against "foo_D.lib", but for the release config has to link against plain old "foo.lib". The problem is that the Linker->General->Libraries section (and a number of other sections as it happens) under Compiler Options seems to be sharing the setting, meaning that I can choose either a Debug or Release setup, but not both. So, does anyone have any suggestions as to how I might work around this?

    Thanks for reading - Brad

    6,680583
    Grand MasterGrand Master
    6,680583

      Jul 20, 2013#2

      There are debug and release related options for C/C++ compiler, the preprocessor and the linker. But if those configuration related options are not enough for you, you can extend them by your own configuration related options.

      I suggest to do that not on the installed configuration file for the dynamic linked library with Visual C/C++ 2010 compiler. Therefore click in menu Build - Select Compiler, click on button Edit Configuration and click next on button Make Configuration Local (Save in Project Directory).

      UEStudio creates now in your project directory the directory tree Configs\Visual Studio 2010\Visual C++ Compiler\ and puts into this directory the configuration file Win32 Dynamic-Link Library or MFC Dynamic-Link Library depending on the type of library you have selected.

      As you can see in the dialog, you can already directly edit the configuration within the dialog. But as you most likely have to make several changes on the configuration file with several build trials to get finally what you want, I suggest to close the dialog now and open the configuration file which is a text file directly in UEStudio for editing.

      Further I suggest to enable the option Show build commands when executing in the dialog opened by clicking on Build - Advanced Build Options. It is useful on editing/extending a configuration to see in output window also the commands with all the arguments executed during the build process.

      In the local configuration file take first a look on section

      [Build]
      Out = $T
      Depends = $FGO
      ReleaseFlag = $(LRFLAG)
      DebugFlag = $(LDFLAG)
      Cmd0 = LINK $(LOPT) $R /OUT:$O $FGO $FGL

      As you can see there is $R on the command line which is a variable holding either value of DebugFlag or ReleaseFlag depending active configuration on build. The other variables are explained briefly at top of the configuration file.

      Most sections [...] are explained unfortunately not as comprehensive as often needed in help of UEStudio. Click on Help - Index, select tab Index and you see already the sections at top of the list.

      The string after $ references always a named variable defined anywhere above. So you have to go up and search for LRFLAG and LDFLAG. You can edit one of those variables or even add a new variable which is added to the command line and the value is defined above. It is up to you if you make the additional options invisible for the compiler options dialog by adding them fix to the configuration file or make the additional options customizable in the set compiler options dialog.

      Hm, your problem is that the additional lib files your library depends on have different names depending on configuration. Debug libraries have a name matched by the pattern *_D.lib and the release library files are just *.lib. So Linker - General - Libraries in the compiler options dialog is not the right place for you to add the additional libraries your code depends on as those libraries are appended to the linker command line via

      [Settings]
      Libraries =

      [InsertFiles]
      group0 = $(Libraries)

      [FileGroups]
      FGO = .obj;.res;
      FGL = .lib;
      FGD = .def;

      [GroupFormats]
      FGO = %s
      FGL = %s

      [Build]
      Out = $T
      Depends = $FGO
      ReleaseFlag = $(LRFLAG)
      DebugFlag = $(LDFLAG)
      Cmd0 = LINK $(LOPT) $R /OUT:$O $FGO $FGL

      After thinking a while on your specific problem and making some trials, I think the easiest would be to extend the local configuration as follows:

      [Settings]
      Project Debug Libraries =
      Project Release Libraries =

      [SettingsInfo]
      Project Debug Libraries = Provides a space for you to specify project related libraries for debug build. Separate file names with a space.
      Project Release Libraries = Provides a space for you to specify project related libraries for release build. Separate file names with a space.

      [Build]
      Out = $T
      Depends = $FGO
      ReleaseFlag = $(LRFLAG) $(Project Release Libraries)
      DebugFlag = $(LDFLAG) $(Project Debug Libraries)
      Cmd0 = LINK $(LOPT) $R /OUT:$O $FGO $FGL

      You can now configure in compiler options dialog foo.lib for Project Release Libraries and foo_D.lib for Project Debug Libraries.
      I hope this works as I'm currently writing this on a computer with UEStudio installed, but not having installed VS2010. So I could only look on linker command line in output window if the configured libraries are added on command line correct.

      I tried first a smarter approach with inserting _D to the library file names by using %p%n_D%e instead of %s in [GroupFormats], but that is applied to all *.lib and independent on active configuration. Sure, it would be possible to define two additional file groups to FGL, but it looks like it is not possible to define which files with extension *.lib should belong to which of the 3 file groups for libraries. Therefore my simple solution which forces the user to configure the libraries for release and debug configuration separately.

      481
      Basic UserBasic User
      481

        Jul 22, 2013#3

        Thanks very much for the super comprehensive response!

        I'll get a chance to try this out later this afternoon. I'll be sure to report back.