# Custom app compile error (Slicer\_MAIN\_PROJECT\_VERSION\_FULL undefined)

**URL:** https://discourse.slicer.org/t/custom-app-compile-error-slicer-main-project-version-full-undefined/30577
**Category:** Development
**Created:** [July 13, 2023, 9:55am UTC](https://discourse.slicer.org/t/custom-app-compile-error-slicer-main-project-version-full-undefined/30577 "2023-07-13T09:55:39Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![darabi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/darabi/32/66736_2.png) [@darabi](https://discourse.slicer.org/u/darabi)
#### Post date: [July 13, 2023, 9:55am UTC](https://discourse.slicer.org/t/custom-app-compile-error-slicer-main-project-version-full-undefined/30577/1 "2023-07-13T09:55:39Z")

</div>

Hello,  
I created a custom Slicer application using

```auto
cookiecutter gh:KitwareMedical/SlicerCustomAppTemplate

```

two days ago (main branch is at commit daaa550).

Compilation of all dependencies seems to work, but the compilation of Main.cxx of the custom app fails with

```auto
...
/opt/MyApp/Applications/MyAppApp/Main.cxx: In function ‘int {anonymous}::SlicerAppMain(int, char**)’:
/opt/MyApp/Applications/MyAppApp/Main.cxx:50:90: error: ‘Slicer_MAIN_PROJECT_VERSION_FULL’ was not declared in this scope; did you mean ‘Slicer_MAIN_PROJECT_APPLICATION_NAME’?
   50 | QString windowTitle = QString("%1 %2").arg(Slicer_MAIN_PROJECT_APPLICATION_NAME).arg(Slicer_MAIN_PROJECT_VERSION_FULL);
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | Slicer_MAIN_PROJECT_APPLICATION_NAME
make[5]: *** [Applications/MyAppApp/CMakeFiles/MyAppApp.dir/build.make:76: Applications/MyAppApp/CMakeFiles/MyAppApp.dir/Main.cxx.o] Error 1
make[4]: *** [CMakeFiles/Makefile2:17646: Applications/MyAppApp/CMakeFiles/MyAppApp.dir/all] Error 2
make[4]: *** Waiting for unfinished jobs....
...

```

I found the definition in `Slicer-build/vtkSlicerVersionConfigure.h` but no include directives in header files included directly or indirectly by Main.cxx.

As the last change of the Main.cxx file in the template project is from July 2018, I’m quite puzzled and sure that I’m doing something wrong.

Can someone please point me into the right direction?

Thank you

Kambiz

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [July 13, 2023, 3:28pm UTC](https://discourse.slicer.org/t/custom-app-compile-error-slicer-main-project-version-full-undefined/30577/2 "2023-07-13T15:28:50Z")

</div>

This could be related to the recent version macro refactoring. (Sorry I’m from phone now so will post link later)

---

<div class="post-metadata">

### Author: ![darabi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/darabi/32/66736_2.png) [@darabi](https://discourse.slicer.org/u/darabi)
#### Post date: [July 13, 2023, 3:48pm UTC](https://discourse.slicer.org/t/custom-app-compile-error-slicer-main-project-version-full-undefined/30577/3 "2023-07-13T15:48:53Z")

</div>

Thanks to your hint, I found this commit:

> <https://github.com/Slicer/Slicer/commit/8c2143ee960e4f3221485c794e943adddbb20963>
>
> List of files to update were identified using the following script:
> 
> \`\`\`
> \# Extra…ct macro specific to Slicer version headers
> cat CMake/vtkSlicerVersionConfigure.h.in CMake/vtkSlicerVersionConfigureInternal.h.in | ack "^#define Slicer" | cut -d" " -f2 \> /tmp/slicer-version-macros.txt
> 
> \# Collect source files directly using at least one of the macro define in the version headers
> (for macro in $(cat /tmp/slicer-version-macros.txt); do
> ack $macro -l | ack "\\.(cxx|cpp|h|h\\.in|txx)$" | ack -v "vtkSlicerVersion";
> done) | sort | uniq \> /tmp/slicer-file-using-version-macros.txt
> 
> \# Are these files already including the version header ?
> for file in $(cat /tmp/slicer-file-using-version-macros.txt);
> do
> echo "$file";
> cat $file | ack vtkSlicerVersionConfigure \> /dev/null && echo " yes" || echo " no";
> done
> \`\`\`
> 
> Co-authored-by: Andras Lasso \<lasso@queensu.ca\>
> Co-authored-by: Jean-Christophe Fillion-Robin \<jchris.fillionr@kitware.com\>

As `Applications/SlicerApp/Main.cxx` is modified in that commit to have

```auto
+#include "vtkSlicerVersionConfigure.h" // For Slicer_VERSION_FULL

```

I guess that the same change should be applied to ` SlicerCustomAppTemplate/{{cookiecutter.project_name}}/Applications/{{cookiecutter.app_name}}App/Main.cxx`.

Shall I create a pull request?

Thanks for your help!

Kambiz

---

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [July 13, 2023, 4:37pm UTC](https://discourse.slicer.org/t/custom-app-compile-error-slicer-main-project-version-full-undefined/30577/4 "2023-07-13T16:37:31Z")

</div>

@darabi and @cpinter Thanks for the investigative work 🙏

@darabi Could you review the following pull request:

> <https://github.com/KitwareMedical/SlicerCustomAppTemplate/pull/53>
>
> This fixes a regression introduced in 451194ac6 (COMP: Remove obsolete version h…eader includes) and apply a fix similar to 8c2143ee9 (COMP: Explicitly include version header where associated macros are used)
> 
> See https://discourse.slicer.org/t/custom-app-compile-error-slicer-main-project-version-full-undefined/30577

I also added `Co-authored-by: ` commit message trailers\[1\] to provide relevant credits, that said look like I incorrectly referenced your GitHub account, would you mind follow-up on that as well.

* * *

1. [Creating a commit with multiple authors - GitHub Docs](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors)

---

<div class="post-metadata">

### Author: ![darabi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/darabi/32/66736_2.png) [@darabi](https://discourse.slicer.org/u/darabi)
#### Post date: [July 13, 2023, 7:53pm UTC](https://discourse.slicer.org/t/custom-app-compile-error-slicer-main-project-version-full-undefined/30577/5 "2023-07-13T19:53:43Z")

</div>

LGTM, if you insist on including `vtkSlicerConfigure.h` (see comment)

---

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [July 13, 2023, 10:17pm UTC](https://discourse.slicer.org/t/custom-app-compile-error-slicer-main-project-version-full-undefined/30577/6 "2023-07-13T22:17:53Z")

</div>

Thanks for the review 🙏

Changes have now been integrated 🚀

For future reference, see [KitwareMedical/SlicerCustomAppTemplate#53](https://github.com/KitwareMedical/SlicerCustomAppTemplate/pull/53)

---

<div class="post-metadata">

### Author: ![darabi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/darabi/32/66736_2.png) [@darabi](https://discourse.slicer.org/u/darabi)
#### Post date: [July 14, 2023, 4:16am UTC](https://discourse.slicer.org/t/custom-app-compile-error-slicer-main-project-version-full-undefined/30577/7 "2023-07-14T04:16:35Z")

</div>

Many thanks for the quick reaction. Is there any CI process testing the SlicerCAT build? I don’t find anything at [slicer.cdash.org](http://slicer.cdash.org) (but I don’t even know if I should expect anything there 🙂 ).
