Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HEADERS variable to set public header property of libjapi. PUBLIC… #137

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

Michael-M-Baron
Copy link
Collaborator

…_HEADERS as a variable was not set and thus leading to no installed headers

…_HEADERS as a variable was not set and thus leading to no installed headers
@Michael-M-Baron Michael-M-Baron self-assigned this Nov 4, 2024
@Michael-M-Baron Michael-M-Baron linked an issue Nov 4, 2024 that may be closed by this pull request
Copy link
Collaborator

@vornkat-iis vornkat-iis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add the usage of make install in the README? Cause while you explained to me why this is necessary, I was confused as well and there is no documentation. make help also just gives you a list of possible targets without explanation

…be installed as a user module with libraries in /usr/local/lib and header files i /usr/local/include/
…ser can then decide to use either static or shared libjapi when using the installed libjapi version for building an application.
…ace pollution (A file like networking.h could potentially be also used in another library and could lead to problems). The same convention like for the json-c library is used which header files are installed at /usr/include/json-c. This change is backwards compatible since the include files were not available before this commit.
@Michael-M-Baron
Copy link
Collaborator Author

Added a new section to README.md explaining how libjapi can be installed.

@Michael-M-Baron
Copy link
Collaborator Author

Michael-M-Baron commented Nov 5, 2024

I also had a look add the linux conventions of where to install the library (See https://www.pathname.com/fhs/ and https://ubuntuforums.org/showthread.php?t=1528661 for reference).

  • /usr/include: This is where all of the system’s general-use include files for the C programming language should be placed. Libraries in this folder are usually managed by the systems package manager and libraries like json-c will be installed in here.
  • /usr/local/include: This hierarchy is for use by the system administrator when compiling and installing software locally. It needs to
    be safe from being overwritten when the system software is updated.
    The same explanation can be used for /usr/lib and /usr/local/lib.

In our case libjapi will be installed in /usr/local/lib and /usr/local/include/japi which makes sense since we do not have an officially managed package and install the library locally.

The header files of libjapi will be installed in /usr/local/include/japi (into a subfolder japi) to follow the conventions used in json-c which header files are installed in /usr/include/json-c

@Michael-M-Baron
Copy link
Collaborator Author

When testing on my machine, /usr/local/lib was already present in the linker searchs path:

root@72a51fea23f0:/# ld --verbose | grep SEARCH_DIR | tr -s ' ;' \\012
SEARCH_DIR("=/usr/local/lib/arm-linux-gnueabihf")
SEARCH_DIR("=/lib/arm-linux-gnueabihf")
SEARCH_DIR("=/usr/lib/arm-linux-gnueabihf")
SEARCH_DIR("=/usr/local/lib")
SEARCH_DIR("=/lib")
SEARCH_DIR("=/usr/lib")
SEARCH_DIR("=/usr/arm-linux-gnueabihf/lib")

The include files of japi however I had to manually add to the system environemnt with:

export C_INCLUDE_PATH=/usr/local/include

I then could use the installed version of libjapi to link against my application. Libjapi header files can be included like

#include <japi/japi.h>
#include <japi/japi_pushsrv.h>

This of course depends on how you set the C_INCLUDE_PATH environment variable. When set to /usr/local/include/japi

#include <japi.h>
#include <japi_pushsrv.h>

will be enough when including

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

include files not installed with CMake
2 participants