Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Regarding using 3rd party libraries: you don't simply "reference a library". You include their source code into your project, and compile them together.

Ideally, both your project and the referenced library should be using CMake, and the library's CMake file should be referenced from your project's CMake file. If the library doesn't use CMake, you write a CMake file for it.

This is the only approach that worked well for me on all platforms. So, save yourself the trouble and just use CMake. Yes, I know it has a horrible language, but it's like the PHP of build systems: it works and lots of existing libraries use it, making it easier to use them in your own project.



Yap pretty much. I used C++ for a while then switched to C and Python and other languages for a decade then had to do some C++ for a bit again. And I was desperately trying to properly reference and link against some libraries. And then finally just dropped the source tree in my project and everything worked. It felt so dirty.


Git submodules work pretty great for this IMO. Rather than incorporate a snapshot of the source, pick a commit hash. Still frozen at a point in time, but you get to move which one you're using (or point to your own fork!) whenever you like.


With Cmake one can keep around an archive of the library which is then unarchived, compiled and linked into the project. Cleaner and quite easy too.

Edit: this is done with ExternalProject.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: