Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Mac OS #1

Open
m-bob opened this issue Dec 1, 2023 · 2 comments
Open

Issues with Mac OS #1

m-bob opened this issue Dec 1, 2023 · 2 comments

Comments

@m-bob
Copy link

m-bob commented Dec 1, 2023

Hi!

Thanks for your Medium article and for this site!

I am unable to run this on my Mac (macOS Monterey 12.7.1).

Fit, the link step fails to find the glut library. I can workaround that by placing a call to -framework GLUT appropriately. So far I have to do the manually in the Makefile (actually in a link.txt file) because I can't figure out how to make cake do it for me.

Second, and more fatally (?), when the program links correctly, it segfaults.

Any clue as to what might be going on?

Thanks for your help and thanks for this project!

Murray

@m-bob
Copy link
Author

m-bob commented Dec 6, 2024

Got boids to run on my M1 MacBook Air! (Thanks, Rael!) The problem seems to be that glViewport is a macro on the Mac. I added the line

#define glViewport (x, y, width, height)

immediately before the definition of main() in main.cpp and the app no longer segfaults. It runs, but more slowly that I expected. Lowering the number of boids helps.

The problem with the link.txt file still remains. Sometimes it's necessary to add -framework GLUT to the last line in the file

boids/build/app/CMakefiles/main.dir/link.txt

and other times it's already there. Regardless, I always need to save the file with an external editor. Presumably just touching the file would work if the -framework GLUT flag is present. So, after making the above change to main.cpp, my procedure for building boids is:

cd build
cmake ..
save build/app/CMakefiles/main.dir/link.txt using an editor. Make sure the -framework GLUT flag is present. (Presumably touch would work.)
make

Unless I do this workaround., the make step always fails because the GLUT functions don't link.

Presumably the CMakeLists.txt can be edited to make the problem disappear, but my cmake skills are unfortunately lacking.

@m-bob
Copy link
Author

m-bob commented Dec 6, 2024

I did some more Googling and I believe the link.txt problem is fixed! Modify the file boids/app/CMakeLists.txt by changing the target_link_library statement to:

target_link_libraries(main ${GLUT_LIBRARY} GLUT::GLUT m ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} Eigen3::Eigen)

(Found this in https://stackoverflow.com/questions/70314595/cmake-cant-link-glut-library-after-system-update .)

Now the expected
cmake ..
make

process works as it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant