automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C library promoted to C++ linkage due to optional C++ source module


From: Bob Friesenhahn
Subject: C library promoted to C++ linkage due to optional C++ source module
Date: Sat, 9 Mar 2024 11:48:40 -0600
User-agent: Mozilla Thunderbird

GraphicsMagick (which is primarily C code) supports optional linkage with some C++ libraries.  It is my opinion that if a library or program is linked with C++ libraries (and especially if it is a static build!) that it should be linked using the C++ linker.  Likewise, if a library or program does not depend on, or contain any C++ code, it should be linked with the C linker.

GraphicsMagick has several major build options which includes putting everything in its major library, or separating certain code into loadable modules.  Automake conditionals are used to support the several major build options.  When loadable modules are used, the C++ dependency is moved to the loadable modules and away from the major library.

The method that I am using to coax Automake into linking using the C++ linker is to include a technically empty 'acpplus.cpp' file as a component when building modules, libraries, or an executable. This approach works, but it has a problem.  The problem is that if Automake sees that a C++ source file may be *optionally* included in a target, it promotes the linkage for that target to C++.

In my builds I see a library of C files being linked together with the C++ linker, even though no C++ code was actually built!

Is there a better solution or fix for this problem?

Bob





reply via email to

[Prev in Thread] Current Thread [Next in Thread]