Skip to content

Keep the configured libdir in pkg-config linker flags - #359

Closed
fhgffy wants to merge 3 commits into
michaelrsweet:masterfrom
fhgffy:fix-pkgconfig-libdir
Closed

fhgffy wants to merge 3 commits into
michaelrsweet:masterfrom
fhgffy:fix-pkgconfig-libdir

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 5, 2026 •

Copy link
Copy Markdown

The pkg-config linker flags omit -L${libdir} for /usr, /usr/local, or the default prefix even when --libdir or --exec-prefix installs the library elsewhere. The install succeeds, but a pkg-config consumer cannot find -lmxml4.

The final change compares the effective library directory, retaining the existing omission of -L for /usr/lib and /usr/local/lib and adding it for other directories. Expansion is confined to a subshell used for that comparison; the public install variables and the .pc file keep their original expressions. configure is regenerated exactly with Autoconf 2.71.

The narrower behavior follows the review about multiple installed library versions. An actual MiniXML v3/v4 static-library control reproduces the overly broad earlier patch selecting the wrong libmxml.a and failing on a v3-only symbol; the narrowed patch preserves the base selection and links/runs successfully.

Current Linux/GCC 13.3 validation covers 14 configurations, each with configure/build/upstream test/staged install/consumer checks. Five custom-directory base consumers fail without the missing -L and pass with that single-path control; the final patch passes all custom cases and default multi-version controls. Symbolic libdir/exec-prefix cases retain their expressions. Exact Autoconf regeneration, shell syntax, encoding, and git diff --check pass. Windows/macOS and current hosted CI are separate and were not run locally.

@michaelrsweet michaelrsweet self-assigned this Oct 6, 2026
@michaelrsweet michaelrsweet added the investigating Investigating the issue label Oct 6, 2026
@michaelrsweet

Copy link
Copy Markdown
Owner

I have concerns because I added these checks specifically because I ran into problems...

The "-L" option interacts poorly when you have multiple versions of the same library installed in different directories... :/

@fhgffy

fhgffy commented Oct 6, 2026

Copy link
Copy Markdown
Author

You are right about the version-selection risk. I reproduced the earlier patch selecting a default-directory MiniXML v4 archive over the intended v3 archive. In a4ad22c, I kept the original /usr/lib and /usr/local/lib suppression and compare the effective libdir, so only custom library directories get -L. Expansion stays in a subshell and does not freeze the install variables. All 14 configuration/build/test/install/consumer cases pass locally, including symbolic directories, and the real v3/v4 link control now selects the same library as the base.

@michaelrsweet

Copy link
Copy Markdown
Owner

Try the following changes:

[master 601f75b] Update pkg-config include/library directories (Issue #359)

@fhgffy

fhgffy commented Oct 8, 2026

Copy link
Copy Markdown
Author

Tested 601f75b. One case still reproduced the version-selection problem: --prefix=/usr --libdir='${prefix}/lib' retains -L/usr/lib because the directory comparison uses the unexpanded value. With real v3 and v4 archives in separate search directories, that selected v4 over the intended v3. Merged your changes in 821e5ba and kept a subshell expansion only for the system-directory comparison; the include/exec-prefix changes are retained, and custom directories still get -L.

On WSL Linux/GCC 13.3, all 14 configuration/build/upstream-test/install/consumer cases pass. The strict custom-directory consumers pass without LIBRARY_PATH, and removing their -L fails in all eight controls. The three real v3/v4 selection controls, including the symbolic system directory, now select the intended v3 archive. System-directory DESTDIR consumers use an explicit staging search path, and the v3 archive is the previously built fixture. Native Windows/macOS tests have not been run locally.

@michaelrsweet michaelrsweet added enhancement New feature or request and removed investigating Investigating the issue labels Oct 24, 2026
@michaelrsweet michaelrsweet added this to the Stable milestone Oct 24, 2026
@michaelrsweet

Copy link
Copy Markdown
Owner

This should take care of the case where you using "prefix" instead of "exec_prefix":

[master bbc60d7] Also check for libdir set using prefix (Issue #359)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants