how to have a shared variable in library across all application in linux (c++)?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use POSIX shared memory to create a shared memory segment, and place the variable there. You will need to synchronise access to the shared variable using POSIX semaphores.
See the shm_overview(7) and sem_overview(7) man pages to get started.