Click here to Skip to main content
15,882,209 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Finding the Parent Process Pin
Richard Andrew x6415-Dec-23 12:41
professionalRichard Andrew x6415-Dec-23 12:41 
SuggestionRe: Finding the Parent Process Pin
David Crow15-Dec-23 10:53
David Crow15-Dec-23 10:53 
GeneralRe: Finding the Parent Process Pin
Richard Andrew x6415-Dec-23 11:00
professionalRichard Andrew x6415-Dec-23 11:00 
GeneralRe: Finding the Parent Process Pin
jschell18-Dec-23 5:43
jschell18-Dec-23 5:43 
AnswerRe: Finding the Parent Process Pin
jschell18-Dec-23 5:46
jschell18-Dec-23 5:46 
GeneralRe: Finding the Parent Process Pin
Richard Andrew x6418-Dec-23 6:23
professionalRichard Andrew x6418-Dec-23 6:23 
Questionlinker cannot find shared library... Pin
Salvatore Terress12-Dec-23 6:49
Salvatore Terress12-Dec-23 6:49 
AnswerRe: linker cannot find shared library... Pin
k505412-Dec-23 9:13
mvek505412-Dec-23 9:13 
Assuming Linux:

1: Tell the linker where to look for the library using LD_LIBRARY_PATH
Terminal
$ LD_LIBRARY_PATH=$HOME/project1/lib:$HOME/project2/lib project3/bin/program
alternatively, you can export LD_LIBRARY_PATH:
Terminal
$ export LD_LIBRARY_PATH=$HOME/project1/lib:$HOME/project2/lib
$ project3/bin/program1
$ project3/bin/program2
If you are going to be using it a lot, you may want to add the export to your shells init scripts. For bash, that would either be $HOME/.bash_profile, or $HOME/.bashrc Other shell programs use different init scripts - sometimes called rc (or .rc) scripts

2: you can use the linker option -Wl,-rpath=$HOME/project1/lib at compile time, which will add "magic" to the executable, so it knows where to look for the library. I've not used this to specify how to check more than one directory. I expect that -Wl,-rpath=location1 -Wl,-rpath=location2 will work, but you'll have to do some research to find out. You'd use this like
Terminal
$ gcc file1.c file2.c file3.c -o program -Wl,-rpath=project/lib
Check with your IDE on how you might change CFLAGS, or LDFLAGS

3: If you have root, you can add the library locations on a more permanent basis by adding to /etc/ld.so.conf.d
These files are just text files that list additional places for the linker to look. Assuming that you have your libraries in /home/user/project/lib then /etc/ld.so.conf.d/project would just contain the single line /home/user/project/lib. After creating that file, you need to remember to run ldconfig, as root, so the system updates its list of places to look. After that, when you launch your program, the linker should be able to find the necessary libraries.

You can check that you've got things covered by using the program ldd. This will list all the shared libraries a given program uses, and where they are located. If a given library can not be found ldd output shows "not found"
Terminal
[k5054@localhost]$ ldd /usr/bin/vim
        linux-vdso.so.1 (0x00007ffefb5e4000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fc6a2520000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fc6a2a9c000)
        libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007fc6a2a68000)
        libsodium.so.23 => /lib64/libsodium.so.23 (0x00007fc6a2a0f000)
        libacl.so.1 => /lib64/libacl.so.1 (0x00007fc6a2516000)
        libgpm.so.2 => /lib64/libgpm.so.2 (0x00007fc6a250e000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fc6a232f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fc6a2ae7000)
        libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fc6a2292000)
        libattr.so.1 => /lib64/libattr.so.1 (0x00007fc6a228a000)
[k5054@localhost]$ 
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown

GeneralRe: linker cannot find shared library... Pin
Salvatore Terress12-Dec-23 17:32
Salvatore Terress12-Dec-23 17:32 
GeneralRe: linker cannot find shared library... Pin
Richard MacCutchan12-Dec-23 22:03
mveRichard MacCutchan12-Dec-23 22:03 
GeneralRe: linker cannot find shared library... Pin
k505413-Dec-23 5:32
mvek505413-Dec-23 5:32 
GeneralRe: linker cannot find shared library... Pin
Richard MacCutchan13-Dec-23 5:58
mveRichard MacCutchan13-Dec-23 5:58 
AnswerRe: linker cannot find shared library... Pin
jschell13-Dec-23 3:47
jschell13-Dec-23 3:47 
GeneralRe: linker cannot find shared library... Pin
Richard MacCutchan13-Dec-23 3:51
mveRichard MacCutchan13-Dec-23 3:51 
GeneralRe: linker cannot find shared library... Pin
Salvatore Terress13-Dec-23 12:24
Salvatore Terress13-Dec-23 12:24 
GeneralRe: linker cannot find shared library... Pin
Richard MacCutchan13-Dec-23 22:03
mveRichard MacCutchan13-Dec-23 22:03 
GeneralRe: linker cannot find shared library... Pin
jschell14-Dec-23 4:24
jschell14-Dec-23 4:24 
GeneralRe: linker cannot find shared library... Pin
Salvatore Terress15-Dec-23 11:47
Salvatore Terress15-Dec-23 11:47 
GeneralRe: linker cannot find shared library... Pin
Salvatore Terress16-Dec-23 10:03
Salvatore Terress16-Dec-23 10:03 
GeneralRe: linker cannot find shared library... Pin
k505416-Dec-23 12:13
mvek505416-Dec-23 12:13 
GeneralRe: linker cannot find shared library... Pin
Salvatore Terress17-Dec-23 11:19
Salvatore Terress17-Dec-23 11:19 
GeneralRe: linker cannot find shared library... Pin
Richard MacCutchan16-Dec-23 21:16
mveRichard MacCutchan16-Dec-23 21:16 
Questionhow to add full path #include ? Pin
Salvatore Terress10-Dec-23 5:57
Salvatore Terress10-Dec-23 5:57 
AnswerRe: how to add full path #include ? Pin
Dave Kreskowiak10-Dec-23 6:19
mveDave Kreskowiak10-Dec-23 6:19 
GeneralRe: how to add full path #include ? Pin
Mircea Neacsu10-Dec-23 8:06
Mircea Neacsu10-Dec-23 8:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.