codec2 icon indicating copy to clipboard operation
codec2 copied to clipboard

pkg-config includedir and source code includes do not match

Open lukasostendorf opened this issue 1 year ago • 2 comments

Summary

If the codec2 library is not installed in the default library/include path, other projects cannot properly include it via pkg-config. E.g. I get include errors in my application on MacOS when having codec2 installed via brew.

  • using #include <config2/config2.h leads to an error, the file cannot be found.
  • using #include <config2.h> leads to an error inside config2.h: it cannot find <config2/version.h>

the pkg-config file defines the include path as includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/codec2 But config2.h itself refers to other files using the codec2/XY.h.

This mismatch does not cause a problem on most Linux distress, as the lib will be installed inside the default include dir (/usr/include), so together with pkg-config, codec2.h and codec2/codec2.h and codec2/version.h are in the include path

Steps to reproduce Install codec2 in a non-default path. E.g. $HOME/. Try to compile this application.

#include <codec2/codec2.h>
int main() {
  return 0;
}

Proposed fix

  1. in codec2.pc, includedir could be set to @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@. Then, all applications must include codec2/codec2.h. This would be a breaking change to the existing include behaviour, some applications currently could include codec2.h

  2. We could add both paths to the include dir: Cflags: -I${includedir}:${includedir}/codec2. This keeps the existing include behaviour and fixes the issue for non-standard install paths.

I created a pull request for the second option.

lukasostendorf avatar Apr 19 '24 16:04 lukasostendorf

@lukasostendorf - thanks, I'm currently traveling but will review this and the proposed fix in a few weeks.

@tmiw - do you have any comments?

drowe67 avatar Apr 19 '24 23:04 drowe67

@lukasostendorf - thanks, I'm currently traveling but will review this and the proposed fix in a few weeks.

@tmiw - do you have any comments?

Seems fine to me.

tmiw avatar Apr 20 '24 01:04 tmiw