dev-cafe/cmake-cookbook

Cannot link to previous recipes headers

Opened this issue · 4 comments

Dear Authors,

Congratulations for your book, I consider it very interesting.

I'm not very expert in compilation,. I just simply cannot compiles the recipes of the first chapter
because it shows me the following error :

/home/mvilla/Documents/CMakeCookbook/chapter-01/recipe-02/cxx-example/hello-world.cpp:1:1: error: expected unqualified-id before ‘.’ token ../../recipe-01/cxx-example/hello-world.cpp

Your Environment

  • Version used: Cmake 3.13.4
  • Operating System and version:gcc version 6.5.0 20181026 (Ubuntu 6.5.0-2ubuntu1~16.04)

How could I fix this ?

Thanks for your answer,

Mateo

Hello @mateovilla2 and thanks for your interest in this project!
As @MicheleBe says, we use symlinks quite extensively in the repository, for two reasons:

  1. We can reuse and extend certain examples without duplicating source files (which would lead to examples diverging, in the long run)
  2. To reduce total size of the repository (though this was not the most pressing concern for our choice)

Given this preamble, on Linux it is perfectly fine to not copy/replace anything to run the examples. So to get to the bottom of this, how did you get a copy of the repository and how are you issuing the compile commands?

Thank @MicheleBe and @robertodr for your answers !!! Yes actually my question was more in the sense of what @robertodr says, I suppossed that on linux It was not necessary to copy/replace repeated code.
I got the code from the packtpub interface, and the compiling method is :

  • Create the build folder inside the recipe folder
  • cd build
  • cmake ..
  • then I tried with cmake --build . and then just with "make" and it shows the same error

I suggest you clone or download the zip file directly from this repository. I am not quite sure how the publisher uploaded code on their servers and it does seems like symbolic links were replaced by actual files whose contents are not correct.