psutil library for node

420 views
Skip to first unread message

christkv

unread,
Sep 6, 2012, 9:36:12 AM9/6/12
to nod...@googlegroups.com
I'm slowly working on rewriting the python lib psutil for node but I'm running into a problem on linux. It builds perfectly with clang++ but fails to link correctly with g++. The code is here


I would really really appreciate it if anyone could shed some light on the problem as I've pretty much wasted a couple of days trying to figure out and I'm sure it's something stupid I've forgot to add in the gyp file.

I published it under psutil on npm so just grab latest if you want to try it out. It's a bit barebones right now and only supports linux and darwin but I'll keep adding to it over time to have a proper full port in due time.

Paddy Byers

unread,
Sep 6, 2012, 5:19:36 PM9/6/12
to nod...@googlegroups.com
Hi,

I would really really appreciate it if anyone could shed some light on the problem as I've pretty much wasted a couple of days trying to figure out and I'm sure it's something stupid I've forgot to add in the gyp file.

If you disambiguate all references to Handle as v8::Handle then it builds for me, on Debian and Darwin. I guess there is a conflict with a definition in one of the various things you're including.


Paddy 

mscdex

unread,
Sep 6, 2012, 5:37:40 PM9/6/12
to nodejs
On Sep 6, 5:20 pm, Paddy Byers <paddy.by...@gmail.com> wrote:
> If you disambiguate all references to Handle as v8::Handle then it builds
> for me, on Debian and Darwin. I guess there is a conflict with a definition
> in one of the various things you're including.

Line 39 probably does not help any:

// using namespace v8;

christkv

unread,
Sep 7, 2012, 3:15:46 AM9/7/12
to nod...@googlegroups.com
ok cool I'll go through all the stuff with a comb. wonder why g++ is so picky while clang++ is not.

Oleg Efimov (Sannis)

unread,
Sep 7, 2012, 3:32:44 AM9/7/12
to nod...@googlegroups.com
I do not know why clang is so lenient ;) but it look like a bad idea to place all code in header files and trying to link them together.
I will try to build this on linux on the weekend.

Also, why are you place "static" declaration into binding.gyp? *.node files are dynamic libraries.

пятница, 7 сентября 2012 г., 11:15:46 UTC+4 пользователь christkv написал:

Oleg Efimov (Sannis)

unread,
Sep 7, 2012, 3:37:08 AM9/7/12
to nod...@googlegroups.com
There are many resources in www, but this is a good one: http://lists.gnu.org/archive/html/openexr-devel/2003-10/msg00035.html
Maybe clang linker is a bit entelligent, but previously I think that it use standard ld.


пятница, 7 сентября 2012 г., 11:15:46 UTC+4 пользователь christkv написал:
ok cool I'll go through all the stuff with a comb. wonder why g++ is so picky while clang++ is not.

christkv

unread,
Sep 7, 2012, 3:55:57 AM9/7/12
to nod...@googlegroups.com
Hi Oleg any help would be appreciated as none of the suggestions currently seems to work. It build correctly but if you run the a test using the lib you get.

parallels@parallels-Parallels-Virtual-Platform:~/coding/checkouts/node-psutil$ nodeunit test/networkstat_test.js 

module.js:485
  process.dlopen(filename, module.exports);
          ^
Error: /home/parallels/coding/checkouts/node-psutil/build/Release/psutil_lib_osx.node: undefined symbol: _ZTV6Worker
    at Object.Module._extensions..node (module.js:485:11)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/home/parallels/coding/checkouts/node-psutil/lib/psutil.js:1:79)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

Meaning the g++ linker is doing something differently. Also if I do nm on the .node library that reference shows up as undefined. 

Marcel Laverdet

unread,
Sep 7, 2012, 4:05:30 AM9/7/12
to nod...@googlegroups.com
Never never never never never never never put "using namespace" in a header file. Or before *any* #include.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

christkv

unread,
Sep 7, 2012, 4:39:02 AM9/7/12
to nod...@googlegroups.com
That does not help either. I've put a single "worker" version here


and it builds with g++ but does fails when running the virtual_memory_test as indicated above.

Oleg Efimov (Sannis)

unread,
Sep 7, 2012, 6:36:26 AM9/7/12
to nod...@googlegroups.com
I think the best way will be to keep original psutils files layout. It is more common to use different files for different platforms, that write hundred-lines #ifdefs.
If there was a set of *.cc + *.h files, it should be linked well.

пятница, 7 сентября 2012 г., 11:55:57 UTC+4 пользователь christkv написал:

christkv

unread,
Sep 8, 2012, 5:53:45 AM9/8/12
to nodejs
well finally fixed it had to do the separation of concerns. G++ truly
is the Yoda of C++ compilers.

Oleg Efimov (Sannis)

unread,
Sep 8, 2012, 8:02:11 AM9/8/12
to nod...@googlegroups.com
Nice!

суббота, 8 сентября 2012 г., 13:53:54 UTC+4 пользователь christkv написал:
Reply all
Reply to author
Forward
0 new messages