One way to accommodate multiple libraries with distinct dependencies in a Makefile target is to create separate sub-targets for each library and its specific dependencies. Then, use these sub-targets to build the libraries and link them together into the final executable.
For example, consider two libraries, libfoo and libbar, where libfoo depends on libbaz and libbar depends on libqux. Here's an example Makefile target:
all: myprogram
libfoo:
cd libfoo && $(MAKE)
libbar:
cd libbar && $(MAKE)
myprogram: libfoo libbar
gcc -o myprogram main.c -Llibfoo -Llibbar -lfoo -lbar -lbaz -lqux
This Makefile has three targets: libfoo
, libbar
, and myprogram
. The libfoo
and libbar
targets build each library separately, using their own dependencies. The myprogram
target depends on libfoo
and libbar
, and links all the libraries together with the main code.
This way, each library can be built with its specific dependencies and the final program can use them all together.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-01-18 11:00:00 +0000
Seen: 12 times
Last updated: Jan 07 '22
How can custom-cli targets be added to the project.json file in Angular using Nx?
How can you steer clear of a target while heading towards a particular location?
Do combined media queries exist for unique viewport sizes?
Why does recv() not return SOCKET_ERROR when an ICMP message for a port unreachable is received?
What does ID2D1HwndRenderTarget::CreateBitmapFromWicBitmap() do?
How can the debug target of the cmake library be configured in Visual Studio?