LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-30-2017, 08:29 AM   #1
SlyMaximus
LQ Newbie
 
Registered: Sep 2017
Posts: 4

Rep: Reputation: Disabled
undefined reference to `get_proc_stats'


Trying to obtain the parent process PID of a process I tried using get_proc_stats() of proc/readproc.h from libprocps-dev / libprocps3-dev / libprocps4-dev (depending on installing distribution) but each time while I am compiling with g++ or gcc I got
Code:
testprocs.cpp:(.text+0x114): undefined reference to `get_proc_stats'
even if I installed this libprocps library.

I have no idea what should I do to fix this issue (tested on Raspbian OS and Bash Ubuntu on Windows10).
One of the examples I tried is here.
https://github.com/zedtux/test_libpr...aster/main.cpp

Last edited by SlyMaximus; 09-30-2017 at 08:30 AM.
 
Old 09-30-2017, 02:35 PM   #2
SlyMaximus
LQ Newbie
 
Registered: Sep 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
I tried to compile that file expliciting calling the shared library but unfortunately is not working.
Quote:
g++ -std=c++11 -L/usr/lib/arm-linux-gnueabihf -llibprocps testprocs.cpp -o myprog -fpermissive
Trying to figure out where was searching for the lib:
Quote:
ld -lzlib --verbose
==================================================
attempt to open //usr/arm-linux-gnueabihf/lib/libibprocps.so failed
attempt to open //usr/arm-linux-gnueabihf/lib/libibprocps.a failed
attempt to open //usr/local/lib/arm-linux-gnueabihf/libibprocps.so failed
attempt to open //usr/local/lib/arm-linux-gnueabihf/libibprocps.a failed
attempt to open //usr/local/lib/libibprocps.so failed
attempt to open //usr/local/lib/libibprocps.a failed
attempt to open //lib/arm-linux-gnueabihf/libibprocps.so failed
attempt to open //lib/arm-linux-gnueabihf/libibprocps.a failed
attempt to open //lib/libibprocps.so failed
attempt to open //lib/libibprocps.a failed
attempt to open //usr/lib/arm-linux-gnueabihf/libibprocps.so failed
attempt to open //usr/lib/arm-linux-gnueabihf/libibprocps.a failed
attempt to open //usr/lib/libibprocps.so failed
attempt to open //usr/lib/libibprocps.a failed
ld: cannot find -libprocps
But it didn't find it even if it is there:
Quote:
$ ldconfig -p | grep libprocps
libprocps.so.3 (libc6,hard-float) => /lib/arm-linux-gnueabihf/libprocps.so.3
libprocps.so (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libprocps.so
It's late, I am tired and I might miss something. In case you see what's I'm doing wrong please let me know.
 
Old 10-02-2017, 02:35 PM   #3
SlyMaximus
LQ Newbie
 
Registered: Sep 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
Correcting the compile command line things have not been changed:
Code:
g++ -std=c++11 testprocs.cpp -L/usr/lib/arm-linux-gnueabihf -lprocps -o myprog -fpermissive
it seems fine cause
Code:
attempt to open //usr/lib/arm-linux-gnueabihf/libprocps.so succeeded
-lprocps (//usr/lib/arm-linux-gnueabihf/libprocps.so)
libdl.so.2 needed by //usr/lib/arm-linux-gnueabihf/libprocps.so
found libdl.so.2 at //lib/arm-linux-gnueabihf/libdl.so.2
libc.so.6 needed by //usr/lib/arm-linux-gnueabihf/libprocps.so
found libc.so.6 at //lib/arm-linux-gnueabihf/libc.so.6
ld-linux-armhf.so.3 needed by //usr/lib/arm-linux-gnueabihf/libprocps.so
found ld-linux-armhf.so.3 at //lib/arm-linux-gnueabihf/ld-linux-armhf.so.3
ld: warning: cannot find entry symbol _start; defaulting to 00010104
This method get_proc_stats() seems not to exists anymore...
Code:
$ nm -D /usr/lib/arm-linux-gnueabihf/libprocps.so | grep get_
         U __ctype_get_mb_cur_max
00007a5c T get_ns_id
00007a34 T get_ns_name
0000ae5c T get_pid_digits
00009710 T get_slabinfo
Where the hack should I find it or do really exist other methods to get the parent PID of an existing external process? This is trivial on Windows...
 
Old 10-03-2017, 01:39 AM   #4
SlyMaximus
LQ Newbie
 
Registered: Sep 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
[SOLVED] undefined reference to `get_proc_stats'

Problem solved with a workaround of not using get_proc_stats().
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ undefined reference grob115 Programming 4 01-22-2013 12:22 PM
undefined reference to... dimah Programming 3 12-27-2006 10:57 AM
Undefined reference to: ashlesha Programming 5 11-08-2006 02:07 PM
undefined reference? Sharky01252 Programming 3 11-07-2006 12:36 PM
Undefined Reference ChemicalBurn Programming 2 02-14-2005 04:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration