# Tutorial Ex1 in Step2 fail to build

**URL:** <https://discourse.cmake.org/t/tutorial-ex1-in-step2-fail-to-build/9812>\
**Category:** Code\
**Created:** [January 10, 2024, 7:39am UTC](https://discourse.cmake.org/t/tutorial-ex1-in-step2-fail-to-build/9812 "2024-01-10T07:39:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbee](https://discourse.cmake.org/user_avatar/discourse.cmake.org/newbee/32/4152_2.png) [@newbee](https://discourse.cmake.org/u/newbee)\
**Post date:** [January 10, 2024, 7:39am UTC](https://discourse.cmake.org/t/tutorial-ex1-in-step2-fail-to-build/9812/1 "2024-01-10T07:39:48Z")

</div>

hi, everyone, I just started to learn CMake and run into a problem when I tried to build Excercise 1 in tutorial step2. I am running inside the terminal in VS code on ubuntu and got the following message.

cmake --build .  
Consolidate compiler generated dependencies of target MathFunctions  
[60%] Built target MathFunctions  
[80%] Linking CXX executable Tutorial  
/usr/bin/ld: cannot find -lPublic: No such file or directory  
collect2: error: ld returned 1 exit status  
gmake[2]: \*\*\* [CMakeFiles/Tutorial.dir/build.make:98: Tutorial] Error 1  
gmake[1]: \*\*\* [CMakeFiles/Makefile2:100: CMakeFiles/Tutorial.dir/all] Error 2  
gmake: \*\*\* [Makefile:91: all] Error 2

Any help is appreciated. This is the first time I post here, so I can’t attach the log file or screenshot here. Thank you for reading this!

---

<div class="post-metadata">

**Author:** ![dnglaze](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/74df32/32.png) [@dnglaze](https://discourse.cmake.org/u/dnglaze)\
**Post date:** [January 10, 2024, 7:48am UTC](https://discourse.cmake.org/t/tutorial-ex1-in-step2-fail-to-build/9812/2 "2024-01-10T07:48:07Z")

</div>

CMake is case sensitive in this situation. I think you may have written `target_link_libraries(Tutorial Public MathFunctions)` when you needed to write `target_link_libraries(Tutorial PUBLIC MathFunctions)`. Notice how the “PUBLIC” is in all caps. This is generally the case for flags and named parameters to CMake functions, so pay attention to the casing.

---

<div class="post-metadata">

**Author:** ![newbee](https://discourse.cmake.org/user_avatar/discourse.cmake.org/newbee/32/4152_2.png) [@newbee](https://discourse.cmake.org/u/newbee)\
**Post date:** [January 10, 2024, 8:19am UTC](https://discourse.cmake.org/t/tutorial-ex1-in-step2-fail-to-build/9812/3 "2024-01-10T08:19:18Z")

</div>

Thanks for the quick response. The build works and it produces the executable. But somehow the include header is flagged inside tutorial.cxx file. Any idea as to what happened? Thanks again!

// TODO 5: Include MathFunctions.h  
#include “TutorialConfig.h”  
#include “MathFunctions.h”

cannot open source file “MathFunctions.h”  
#include errors detected based on information provided by the configurationProvider setting. Squiggles are disabled for this translation unit (/home/lzpc/Downloads/cmake-3.28.1-tutorial-source/cmakeTutorSource/Step2/tutorial.cxx).  
cannot open source file “TutorialConfig.h”

---

<div class="post-metadata">

**Author:** ![dnglaze](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/74df32/32.png) [@dnglaze](https://discourse.cmake.org/u/dnglaze)\
**Post date:** [January 10, 2024, 6:31pm UTC](https://discourse.cmake.org/t/tutorial-ex1-in-step2-fail-to-build/9812/4 "2024-01-10T18:31:20Z")

</div>

Unfortunately, I don’t think I can provide much more assistance on how your IDE is behaving. If the build works, it should mean everything is configured properly as far as CMake is concerned.

---

<div class="post-metadata">

**Author:** ![newbee](https://discourse.cmake.org/user_avatar/discourse.cmake.org/newbee/32/4152_2.png) [@newbee](https://discourse.cmake.org/u/newbee)\
**Post date:** [January 11, 2024, 1:23am UTC](https://discourse.cmake.org/t/tutorial-ex1-in-step2-fail-to-build/9812/5 "2024-01-11T01:23:31Z")

</div>

Thanks!
