RayTracing / raytracing.github.io

Main Web Site (Online Books)
https://raytracing.github.io/
Creative Commons Zero v1.0 Universal
8.84k stars 868 forks source link

"1 duplicate symbol for architecture arm64" in Xcode 13.4.1 on macOS 12.5.1 #1069

Closed erikmartinessanches closed 1 year ago

erikmartinessanches commented 2 years ago

On macbook Pro M1, after arriving at the very end of chapter 3 in RayTracing In One Weekend, I get the error mentioned in the topic. My repository.

erikmartinessanches commented 2 years ago

Not to include color.hpp in color.cpp, as well as deleting color.cpp entirely from the project solved the problem.

The question I have is: Why does the presence of vec3.cpp and its inclusion of vec3.hpp not cause a similar error?

erikmartinessanches commented 2 years ago

Note, I save the ppm file and in the beginning (the gradient) I could open the ppm file in Preview without any problems. However, now (see my repo link) at the end of chapter 3, I'm no longer able to open the ppm file in Preview.

Also: in Listing 7, where is the function pixel_color defined?

hollasch commented 2 years ago

That doesn't seem to match our source. The reference code has a single file, color.h, which contains both declarations and definitions. I believe this is specific to your particular implementation.

hollasch commented 2 years ago

In listing 7 (Final code for the first PPM image), pixel_color is a local color variable.

            color pixel_color(double(i)/(image_width-1), double(j)/(image_height-1), 0.25);

Here, the local variable pixel_color is defined as type color, and we're initializing it with the three values in the parentheses: double(i)/(image_width-1), double(j)/(image_height-1), and 0.25.

erikmartinessanches commented 2 years ago

That doesn't seem to match our source. The reference code has a single file, color.h, which contains both declarations and definitions. I believe this is specific to your particular implementation.

Indeed, your source code in color.h, main.cpp and vec3.h (and perhaps others) contain more code than my version of the files. Your files contain more code that hasn't been mentioned by the end of chapter 3, where I am located. How am I supposed to know what parts of the code I need at the end of chapter 3? Looking at the source code with all of the code doesn't help because I don't know when all that other code is supposed to enter the picture, is it code from chapter 4, 5, 6? Who knows? So I would like to argue that the state of my code is exactly as in the book (not the source code), apart from writing the file to disk, which the book doesn't do, by the end of chapter 3. Here, my problem is that the PPM image is not generated correctly. image Warning, encountered unexpected EOF.

hollasch commented 1 year ago

Revisit this with #778

trevordblack commented 1 year ago

We have created a Discussions tab along the top bar.

If you run into any more compilation problems we ask that you ask for help there. We try to have the issues tab focused on work that we need to improve the book.

We made the decision many years ago that we would have one copy of the source available. The final copy of the source. There is stuff in the github color.h that is from further along in the book series. Simply put, tracking the state of source for every part of the book is an untenable task, and we have difficulty keeping track of the duplicate state of code (in the repo and in the books) that additional copies is not an acceptable option to us.

hollasch commented 1 year ago

I think we should keep this one open. If I understand correctly, we may have an inconsistent state at the end of chapter 3. Something to at least sanity-check while doing the progressions.

hollasch commented 1 year ago

Ah, reading more carefully, I think the complaint is that we have a single set of source code for the end of book 1, instead of 79 separate sets; one for each stage. No way are we maintaining (and propagating updates through) 79 separate codebases (208 across all three books for v3.2.3).

We already have an issue scheduled to ensure that the progression of source changes works as expected for the next release — any development inconsistencies should become apparent during this process.