Create a self-contained project with external libraries
Hey guys, I want to create a self-contained C project to be machine-independent. An example? I want to "make all" my project on a machine where external libraries are not installed (but included in my project) and I want all keep working :) The library I'm talking about is the GSL, you can find it in the libgsl0-dev ubuntu package. Now, I want to include all the header and .c files in my project, unin开发者_开发百科stall the packages and the project must build and run as before :) Ideas? Thanks! Bye!
Don't forget about dependencies.
There are reasons why libraries like GSL are distributed as independant entities:
Users can upgrade the library independantly of the software that uses it saving you from having to constantly update your project when the GSL version changes.
Licensing issues.
Dependancies. If GSL has dependencies and you want to build GSL as part of your project then you will also need to include ALL the source code for ALL dependencies...and their dependencies...and their dependencies...and so on and so on. If you are going to make it a requirement that some sub-dependency need to already be installed then you may as well make it a requirement that GSL is already installed.
Other reasons I can't be bothered to think up because I have other things to do.
Just copy the library's source code somewhere into your project's hierarchy, and start either creating or modifying Makefiles (or whatever GSL uses) to get it to build.
For instance, you could have it in a directory external/libgsl
, and then set up a Makefile target for your project that does the building. Then you make your project's code dependent on the library's, so that the library is always built first.
Of course, you also need to think about any license issues that might arise if/when you distribute your project.
精彩评论