[nodejs] error compiling nodejs v0.8

2012-06-25 Thread rhasson
I downloaded the latest v.0.8 tar file and tried to compile it on my Fedora 
14 and I got this error:

  LINK(target) /home/users/roy/node-v0.8.0/out/Release/mksnapshot
  LINK(target) /home/users/roy/node-v0.8.0/out/Release/mksnapshot: Finished
  ACTION v8_snapshot_run_mksnapshot 
/home/users/roy/node-v0.8.0/out/Release/obj.target/v8_snapshot/geni/snapshot.cc
/bin/sh: line 1: 27974 Segmentation fault 
 "/home/users/roy/node-v0.8.0/out/Release/mksnapshot" 
--log-snapshot-positions --logfile 
"/home/users/roy/node-v0.8.0/out/Release/obj.target/v8_snapshot/geni/snapshot.log"
 
"/home/users/roy/node-v0.8.0/out/Release/obj.target/v8_snapshot/geni/snapshot.cc"
make[1]: *** 
[/home/users/roy/node-v0.8.0/out/Release/obj.target/v8_snapshot/geni/snapshot.cc]
 
Error 139
make[1]: Leaving directory `/home/users/roy/node-v0.8.0/out'
make: *** [node] Error 2

Any ideas what could be causing this error?

Thanks,
Roy

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] error compiling nodejs v0.8

2012-06-25 Thread rhasson
roy@mainserver1 node-v0.8.0]$ uname -a
Linux mainserver1 2.6.35.4-rscloud #8 SMP Mon Sep 20 15:54:33 UTC 2010 
x86_64 x86_64 x86_64 GNU/Linux
[roy@mainserver1 node-v0.8.0]$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.5.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla 
--enable-bootstrap --enable-shared --enable-threads=posix 
--enable-checking=release --with-system-zlib --enable-__cxa_atexit 
--disable-libunwind-exceptions --enable-gnu-unique-object 
--enable-linker-build-id 
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin 
--enable-java-awt=gtk --disable-dssi 
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre 
--enable-libgcj-multifile --enable-java-maintainer-mode 
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib 
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC)

So I ran it with --without-snapshot and got this:

make[1]: Leaving directory `/home/users/roy/node-v0.8.0/out'
ln -fs out/Release/node node
[roy@mainserver1 node-v0.8.0]$ sudo make install
make -C out BUILDTYPE=Release
make[1]: Entering directory `/home/users/roy/node-v0.8.0/out'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/users/roy/node-v0.8.0/out'
ln -fs out/Release/node node
out/Release/node tools/installer.js install 
make: *** [install] Segmentation fault
[roy@mainserver1 node-v0.8.0]$ 

[roy@mainserver1 node-v0.8.0]$ out/Release/node node
Segmentation fault
[roy@mainserver1 node-v0.8.0]$ 

After this failed, I did "make clean" and ran again like this:
[roy@mainserver1 node-v0.8.0]$ ./configure 
--prefix=/home/users/roy/share/node-v0.8 --without-snapshot
[roy@mainserver1 node-v0.8.0]$ make -C out BUILDTYPE=Debug

it complied fine with no errors and worked.
[roy@mainserver1 node-v0.8.0]$ out/Debug/node
> process.version
'v0.8.0'
> 

now to the last suggestion you made:
I made the change to deps/v8/build/common.gypi
and run:
[roy@mainserver1 node-v0.8.0]$ ./configure 
--prefix=/home/users/roy/share/node-v0.8 --without-snapshot
[roy@mainserver1 node-v0.8.0]$ sudo make

[roy@mainserver1 node-v0.8.0]$ out/Release/node
> process.version
'v0.8.0'
>

sudo make install

[roy@mainserver1 node-v0.8.0]$ /home/users/roy/share/node-v0.8/bin/node
> process.version
'v0.8.0'
> 

This seems to have solved the problem.  

Thanks,
Roy

On Monday, June 25, 2012 7:01:23 PM UTC-4, Ben Noordhuis wrote:
>
> On Tue, Jun 26, 2012 at 12:48 AM, rhasson <> wrote: 
> > I downloaded the latest v.0.8 tar file and tried to compile it on my 
> Fedora 
> > 14 and I got this error: 
> > 
> >   LINK(target) /home/users/roy/node-v0.8.0/out/Release/mksnapshot 
> >   LINK(target) /home/users/roy/node-v0.8.0/out/Release/mksnapshot: 
> Finished 
> >   ACTION v8_snapshot_run_mksnapshot 
> > 
> /home/users/roy/node-v0.8.0/out/Release/obj.target/v8_snapshot/geni/snapshot.cc
>  
>
> > /bin/sh: line 1: 27974 Segmentation fault 
> >  "/home/users/roy/node-v0.8.0/out/Release/mksnapshot" 
> > --log-snapshot-positions --logfile 
> > 
> "/home/users/roy/node-v0.8.0/out/Release/obj.target/v8_snapshot/geni/snapshot.log"
>  
>
> > 
> "/home/users/roy/node-v0.8.0/out/Release/obj.target/v8_snapshot/geni/snapshot.cc"
>  
>
> > make[1]: *** 
> > 
> [/home/users/roy/node-v0.8.0/out/Release/obj.target/v8_snapshot/geni/snapshot.cc]
>  
>
> > Error 139 
> > make[1]: Leaving directory `/home/users/roy/node-v0.8.0/out' 
> > make: *** [node] Error 2 
> > 
> > Any ideas what could be causing this error? 
>
> It could be a number of things. 
>
> - Can you post the output of `uname -a` and `g++ -v`? It might be a 
> compiler bug, see e.g. [1]. 
>
> - Does the debug build work? `make -C out BUILDTYPE=Debug` 
>
> - Does `./configure --without-snapshot` produce a working binary? 
>
> - What happens when you set v8_no_strict_aliasing% to 1 in 
> deps/v8/build/common.gypi? 
>
> [1] https://github.com/joyent/node/issues/2912 
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] error compiling nodejs v0.8

2012-06-29 Thread rhasson
Ben, 

I tried compiling 0.8.1 today and I was only able to successfuly compile a 
Debug build.  I tried a Release build using --without-snapshot and changing 
the bit in the v8/common.gypi as suggested previously and both times I get 
"segmentation fault" when I run node.

I prefer not to run a debug build on my production system.  Any ideas why 
this is happening?

Thanks,
Roy

On Thursday, June 28, 2012 12:38:09 PM UTC-4, James Thornton wrote:
>
> I had the same issue with Node 0.8.0 on Fedora 14:
>
> Linux life 2.6.35.14-106.fc14.x86_64 #1 SMP Wed Nov 23 13:07:52 UTC 2011 
> x86_64 x86_64 x86_64 GNU/Linux
>
> ...but was able to compile with...
>
> $ make clean
> $ ./configure 
> $ make -C out BUILDTYPE=Debug
>
> - James
>
> On Monday, June 25, 2012 7:07:01 PM UTC-5, rhasson wrote:
>>
>>
>> now to the last suggestion you made:
>> I made the change to deps/v8/build/common.gypi
>> and run:
>> [roy@mainserver1 node-v0.8.0]$ ./configure 
>> --prefix=/home/users/roy/share/node-v0.8 --without-snapshot
>> [roy@mainserver1 node-v0.8.0]$ sudo make
>>
>> [roy@mainserver1 node-v0.8.0]$ out/Release/node
>> > process.version
>> 'v0.8.0'
>>
>> sudo make install
>>
>> [roy@mainserver1 node-v0.8.0]$ /home/users/roy/share/node-v0.8/bin/node
>> > process.version
>> 'v0.8.0'
>>
>> This seems to have solved the problem.  
>>
>
>  
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] error compiling nodejs v0.8

2012-06-30 Thread rhasson
it's not working with the changes to common.gypi.  I guess I'll have to 
upgrade GCC since I'm assuming I'll have this problem with future versions 
of Node too.

Thanks,
Roy

On Saturday, June 30, 2012 10:57:28 AM UTC-4, Ben Noordhuis wrote:
>
> On Sat, Jun 30, 2012 at 5:58 AM, rhasson <> wrote: 
> > Ben, 
> > 
> > I tried compiling 0.8.1 today and I was only able to successfuly compile 
> a 
> > Debug build.  I tried a Release build using --without-snapshot and 
> changing 
> > the bit in the v8/common.gypi as suggested previously and both times I 
> get 
> > "segmentation fault" when I run node. 
> > 
> > I prefer not to run a debug build on my production system.  Any ideas 
> why 
> > this is happening? 
>
> The most likely culprit is a bug in gcc's optimizer that affects (at 
> least) 4.5. People have also reported problems with gcc 4.4 but I've 
> never been able to reproduce that myself. 
>
> Check your common.gypi - v8_no_strict_aliasing should be true while 
> strict_aliasing should be false (I've renamed the second one in the 
> master branch to node_no_strict_aliasing for the sake of consistency.) 
>
> If all else fails, upgrade to gcc 4.6 or 4.7 or compile with clang. 
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Web scraping and Memory leaking issue

2012-07-02 Thread rhasson
Have you looked at Cheerio (https://github.com/MatthewMueller/cheerio) ? 
 I've been using it over JSDom and it's faster and lightweight.  If you're 
doing heaving scraping I would recommend checking it out.

On Monday, July 2, 2012 10:30:25 AM UTC-4, ec.developer wrote:
>
> Charles, Thanks for your suggestion. About global links_grabbed - I am 
> sure there could be a better solution, but in my case it is not so 
> significant. 
> I have tried, just for testing, to store 200 thousands of large links in an 
> array, and then I've outputed the used memory, and it's amount is very 
> small. So I didn't focused on this :)*
> *
> *
> *
>
> On Monday, July 2, 2012 4:44:24 PM UTC+3, Charles Care wrote:
>>
>> Hi, 
>>
>> I had a play with your code and found a couple of things. It's 
>> probably worth trying to avoid the global variable links_grabbed as 
>> it's just getting larger and larger as you crawl. I know you need it 
>> to avoid parsing the same site twice, but perhaps you could find a 
>> more lightweight data structure? I'd probably be tempted to keep this 
>> state in a Redis set (or something similar). 
>>
>> Also, I'm not an expert on scraper, but I *seemed* to get a 
>> performance improvement when I modified the code that pushed new urls 
>> onto your links stack. 
>>
>> I added a String() conversion: e.g. 
>>
>> ... 
>> links.push(String(link)); 
>> ... 
>>
>> which meant I wasn't keeping the jquery link around in a stack. Hope that 
>> helps, 
>>
>> Charles 
>>
>>
>>
>> On 2 July 2012 14:08, ec.developer  wrote: 
>> > Hi all, 
>> > I've created a small app, which searches for Not Found [404] exceptions 
>> on a 
>> > specified website. I use the node-scraper module 
>> > (https://github.com/mape/node-scraper/), which uses native node's 
>> request 
>> > module and jsdom for parsing the html). 
>> > My app recursively searches for links on the each webpage, and then 
>> calls 
>> > the Scraping stuff for each found link. The problem is that after 
>> scanning 
>> > 100 pages (and collecting over 200 links to be scanned) the RSS memory 
>> usage 
>> > is >200MB (and it still increases on each iteration). So after scanning 
>> over 
>> > 300-400 pages, I got memory allocation error. 
>> > The code is provided below. 
>> > Any hints? 
>> > 
>> > var scraper = require('scraper'), 
>> > util = require('util'); 
>> > 
>> > var checkDomain = process.argv[2].replace("https://";, 
>> "").replace("http://";, 
>> > ""), 
>> > links = [process.argv[2]], 
>> > links_grabbed = []; 
>> > 
>> > var link_check = links.pop(); 
>> > links_grabbed.push(link_check); 
>> > scraper(link_check, parseData); 
>> > 
>> > function parseData(err, jQuery, url) 
>> > { 
>> > var ramUsage = bytesToSize(process.memoryUsage().rss); 
>> > process.stdout.write("\rLinks checked: " + 
>> > (Object.keys(links_grabbed).length) + "/" + links.length + " ["+ 
>> ramUsage 
>> > +"] "); 
>> > 
>> > if( err ) { 
>> > console.log("%s [%s], source - %s", err.uri, err.http_status, 
>> > links_grabbed[err.uri].src); 
>> > } 
>> > else { 
>> > jQuery('a').each(function() { 
>> > var link = jQuery(this).attr("href").trim(); 
>> > 
>> > if( link.indexOf("/")==0 ) 
>> > link = "http://"; + checkDomain + link; 
>> > 
>> > if( links.indexOf(link)==-1 && links_grabbed.indexOf(link)==-1 && ["#", 
>> > ""].indexOf(link)==-1 && (link.indexOf("http://"; + checkDomain)==0 || 
>> > link.indexOf("https://"+checkDomain)==0) ) 
>> > links.push(link); 
>> > }); 
>> > } 
>> > 
>> > if( links.length>0 ) { 
>> > var link_check = links.pop(); 
>> > links_grabbed.push(link_check); 
>> > scraper(link_check, parseData); 
>> > } 
>> > else { 
>> > util.log("Scraping is done. Bye bye =)"); 
>> > process.exit(0); 
>> > } 
>> > } 
>> > 
>> > -- 
>> > 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 nodejs@googlegroups.com 
>> > To unsubscribe from this group, send email to 
>> > nodejs+unsubscr...@googlegroups.com 
>> > For more options, visit this group at 
>> > http://groups.google.com/group/nodejs?hl=en?hl=en 
>>
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: v0.8.* make failed under Linux x64

2012-07-12 Thread rhasson
did you run "make clean" before trying with --without-snapshots ?

I had a build problem (older g++ version) and it didn't compile v8.1. but 
compiles v8.2 great with the --without-snapshots flag.

On Wednesday, July 11, 2012 6:46:45 PM UTC-4, Michael Smith wrote:
>
> On Wednesday, July 11, 2012 2:48:05 PM UTC-7, Ben Noordhuis wrote:
>>
>>
>>
>> It seems the overarching theme with your machine is that generating 
>> code or post-processing object files somehow doesn't work (both 
>> debug-support.o and snapshot.o are the result of actions that do 
>> that). 
>>
>> What happens when you run configure with --without-snapshots? 
>>
>
> Interesting. So, data point followed by dumb question: I'm able to compile 
> 0.6.20 from source without problems. Is this consistent with the above 
> hypothesis?
>
> Trying --without-snapshot I get the following, which appears to work, but 
> only trivially (nothing is compiled):
>
> # ./configure --without-snapshot
> { 'target_defaults': { 'cflags': [],
>'default_configuration': 'Release',
>'defines': [],
>'include_dirs': [],
>'libraries': []},
>   'variables': { 'host_arch': 'ia32',
>  'node_install_npm': 'true',
>  'node_install_waf': 'true',
>  'node_no_strict_aliasing': 1,
>  'node_prefix': '',
>  'node_shared_openssl': 'false',
>  'node_shared_v8': 'false',
>  'node_shared_zlib': 'false',
>  'node_use_dtrace': 'false',
>  'node_use_etw': 'false',
>  'node_use_openssl': 'true',
>  'target_arch': 'ia32',
>  'v8_no_strict_aliasing': 1,
>  'v8_use_snapshot': 'false'}}
> creating  ./config.gypi
> creating  ./config.mk
> LDDORCFSL02:~/node-v0.8.2 # make
> make -C out BUILDTYPE=Release
> make[1]: Entering directory `/root/node-v0.8.2/out'
> make[1]: Nothing to be done for `all'.
> make[1]: Leaving directory `/root/node-v0.8.2/out'
> ln -fs out/Release/node node
>
> (note that "node" is a link to a file that doesn't exist.)
>
> Thanks again,
> Mike
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Trying to understand streams and child processes

2012-07-30 Thread rhasson
"stdin" and "stdout" available on the child process are buffer that inherit 
from EventEmitter (well they are streams, unless you change their behavior 
when creating the spawned child).  As mentioned by Dominic you need to add 
event listeners to the data events of the stdout and stderr so you can see 
what the FTP process writes.  You then need to parse it and write to the 
stdin stream while again listening to the stdout and making sure you 
received the complete response to the command you sent.

just  be careful not to get into a situation, as you have in your example, 
where you register multiple listeners to the same event performing 
different tasks.  In your example, the outer and inner listeners on stdout 
data event will be called when you write "ls" and when you write "rename". 
 You'll get into an infinite loop very quickly.

I think you need to create a single data handler that will deal with 
processing of all expected output from the FTP process based on all 
possible FTP commands you plan to use.  Try to make it as generic as 
possible so regardless if you did "ls /tmp" or "ls /home" the processing 
within the data handler will be the same.  You'll need to maintain some 
structure outside of the data handler to deal with passing that information 
back to the calling function (via callbacks or events).

If you really want to you can build a TCP server instead that implements 
the FTP protocol.  Maybe even easier is to copy what other FTP modules did 
and just refresh the code and make it your own.

Roy

On Monday, July 30, 2012 7:01:43 AM UTC-4, carlton wrote:
>
> Hi there,
>
> I am trying to implent a nodejs script that connects to one of our servers 
> using sftp.
>
> So far I can connect using child process and spawning a command such as...
>
> sftp -o Port=22-o PasswordAuthentication=no-o 
> UserKnownHostsFile=/home/carlton/.ssh/known_hosts-o 
> IdentityFile=private_key-o StrictHostKeyChecking=no-o 
> BatchMode=nodeploy@46.x.x.x:/home/carlton/to_process
>
> Now this is the part that has me confused...
>
> I then need to execute commands on the ftp server (e.g. list files, rename 
> files) so I listen to the 'data' event
>
> sftp.stdout.on('data', function (data) {
> console.log('stdout: ' + data);
>
> sftp.stdin.write("ls -l\r\n");
>
> sftp.stdout.on('data', function(data){
> console.log('File list:', data.toString());
> 
>  // Parse file names here
>  
> sftp.stdin.write("rename 
> /home/carlton/FTP_test/to_process/old.php /home/ carlton 
> /FTP_test/processed/new.php\n");
> });
> });
>
> Is this the correct way to structure things (i.e. creatiung event listener 
> again for the 'data' event within the callback of the previous 'data' event 
> listener)?
> I found it hard to find any examples similar to what I need to do which 
> made me think I haven't built this as it should have been.
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Trying to understand streams and child processes

2012-08-01 Thread rhasson
In all honesty this is a hacky way of building an FTP service.  Ideally 
you'd build a TCP server and properly handle FTP commands but with a 
cleaner interface for your application.  If you use this .spawn way you 
need to manage state (which commands were issued, did they complete 
successfully or failed, what data was sent, etc.) and passing the complete 
data back to the application.

It seems as tho node-sftp is fairly complete but I don't know how well it 
works.  I think it's worth giving a try especially if you have simple use 
cases.

Good luck
Roy

On Tuesday, July 31, 2012 4:24:08 AM UTC-4, carlton wrote:
>
> Thanks for the responses, after reading those and doing some additional 
> reading on the tube I understand the difference between callbacks and 
> eventEmitters better.
>
> I'll go away and have a think about how to handle the data event, I'll 
> also try and kick start the node-sftp library that I was using, I think it 
> was fairly close to working properly.
>
> So am I right in thinking that I need to parse the stdout data to figure 
> out what command has been run and handle it accordingly? I think that's 
> what the node-sftp library does (example code below).
> This seems like an alien way of doing things for me but I guess it's 
> similar to handling a request from a browser and determining what script 
> needs to handle the request.
>
> /**
>  * Parse the STDOUT of the sftp child process, collect the lines of 
> data for
>  * the active command and detect if the active command has finished 
> executing.
>  * If the active command is done, respective callbacks are called.
>  * 
>  * @param {String} data
>  * @type  {void}
>  * @private
>  */
> function parseReply(data) {
> //console.log("data: ", data, data.split("\n").length + " parts");
> this.emit("data", data);
> if (!this.activeCmd && !(this.state & Sftp.STATE_CONNECTING))
> return;
> var cbdone, cbprogress;
> if (data.indexOf("sftp>") > -1 || (this.activeCmd == "bye" && 
> data.indexOf("bye") > -1)) {
> if (this.state & Sftp.STATE_CONNECTING && 
> this.callbacks["connect"]) {
> this.callbacks["connect"]();
> delete this.callbacks["connect"];
> }
> // check if a command has finished executing:
> else if (cbdone = this.callbacks[this.activeCmd]) {
> delete this.callbacks[this.activeCmd];
> delete this.callbacks[this.activeCmd + "_progress"];
> this.activeCmd = null;
> cbdone((this.activeCmdBuffer + 
> data).split(/[\n\r]+/).filter(function(line) {
> return line.indexOf("sftp>") === -1;
> }));
> this.activeCmdBuffer = "";
> }
> if (!this.activeCmd && this.queue.length && this.state & 
> Sftp.STATE_CONNECTED)
> this.exec.apply(this, this.queue.shift());
> }
> else if (cbprogress = this.callbacks[this.activeCmd + 
> "_progress"]) {
> this.activeCmdBuffer += data;
> cbprogress(data);
> }
> }
>
>
> On Monday, 30 July 2012 21:23:35 UTC+1, rhasson wrote:
>>
>> "stdin" and "stdout" available on the child process are buffer that 
>> inherit from EventEmitter (well they are streams, unless you change their 
>> behavior when creating the spawned child).  As mentioned by Dominic you 
>> need to add event listeners to the data events of the stdout and stderr so 
>> you can see what the FTP process writes.  You then need to parse it and 
>> write to the stdin stream while again listening to the stdout and making 
>> sure you received the complete response to the command you sent.
>>
>> just  be careful not to get into a situation, as you have in your 
>> example, where you register multiple listeners to the same event performing 
>> different tasks.  In your example, the outer and inner listeners on stdout 
>> data event will be called when you write "ls" and when you write "rename". 
>>  You'll get into an infinite loop very quickly.
>>
>> I think you need to create a single data handler that will deal with 
>> processing of all expected output from the FTP process based on all 
>> possible FTP commands you plan to use.  Try to make it as generic as 
>> possible so regardless if you did

[nodejs] how to link multiple dependencies with node-gyp

2012-08-20 Thread rhasson
I'm building a native-addon and I'm using an external dependency that when 
compiles outputs an object file (.o).  I want my project to compile, then 
compile the external dependency (via makefile not gyp) and then link the 
resulting objects together to create my addon.

Is there a way to do that?

Thanks,
Roy

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] how to link multiple dependencies with node-gyp

2012-08-20 Thread rhasson
Fairly simple library ( http://www.five-ten-sg.com/libpst/packages/ ).  I 
never tried porting to gyp before but it can't hurt to try.

On Monday, August 20, 2012 4:22:33 PM UTC-4, Nathan Rajlich wrote:
>
> What is the external library / addon in question? 
>
> If the library is simple enough, the best way is to write a .gyp file 
> for it and do it the "gyp way". I would highly encourage you to 
> attempt to do that. An example of this is node-sqlite3's sqlite3.gyp 
> file: 
> https://github.com/developmentseed/node-sqlite3/blob/7d763404079c47319f870ea1d11636517f1f0821/deps/sqlite3/sqlite3.gyp#L40-68
>  
>
> However, sometimes that's not an option, maybe because the library's 
> configuration is too complicated or whatever, and the only solution 
> I've come up with is rather nasty. See node-ffi: 
> https://github.com/rbranson/node-ffi/blob/master/binding.gyp#L45-66 
>
> On Mon, Aug 20, 2012 at 12:56 PM, rhasson > 
> wrote: 
> > I'm building a native-addon and I'm using an external dependency that 
> when 
> > compiles outputs an object file (.o).  I want my project to compile, 
> then 
> > compile the external dependency (via makefile not gyp) and then link the 
> > resulting objects together to create my addon. 
> > 
> > Is there a way to do that? 
> > 
> > Thanks, 
> > Roy 
> > 
> > -- 
> > 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 
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] node-ffi ref-struct question

2012-08-23 Thread rhasson
Nathan, 

I started using node-ffi which works great.  I need to create some structs 
so I'm using ref-struct.  Now some of my structs have pointers to 
themselves like this:

typedef struct pst_block_recorder {
struct pst_block_recorder  *next;
int64_t offset;
size_t  size;
int readcount;
} pst_block_recorder;

I tried to recreate this with ref-struct like this:
var pst_block_recorder = Struct ({
//struct pst_block_recorder  *next;
'next': ref.refType(pst_block_recorder),
//int64_t offset;
'offset': 'int64',
//size_t  size;
'size': 'size_t',
//int readcount;
'readcount': 'int'
});

But I get the following error:
assert.js:102
  throw new assert.AssertionError({
^
AssertionError: could not determine a proper "type" from: undefined
at Object.coerceType (/home/roy/node_modules/ref/lib/ref.js:389:3)
at Object.refType (/home/roy/node_modules/ref/lib/ref.js:304:23)


I also tried making those struct fields "pointer" types but the C library 
doesn't seem to populate them correctly.

Any thoughts?

Thanks,
Roy

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] node-ffi ref-struct question

2012-08-23 Thread rhasson
Good point.  I'll do that.


Another question, 
In C I do this:
typedef struct pst_file {
pst_desc_tree  *d_head
} pst_file;

pst_desc_tree *d_ptr;  //this is another struct
d_ptr = pstfile.d_head;

How do I make this assignment with ref-struct?

On Thursday, August 23, 2012 12:34:26 PM UTC-4, Nathan Rajlich wrote:
>
> So basically when you're calling "ref.refType(pst_block_recorder)", 
> pst_block_recorder is still undefined. I ran into this problem with a 
> struct that libffi uses, and the solution is to progressively create 
> the struct instance using the "defineProperty()" function. Try 
> something like this: 
>
>   var pst_block_recorder = Struct(); 
>   pst_block_recorder.defineProperty('next', 
> ref.refType(pst_block_recorder)); 
>   pst_block_recorder.defineProperty('offset', 'int64'); 
>   pst_block_recorder.defineProperty('size', 'size_t'); 
>   pst_block_recorder.defineProperty('readcount', 'int'); 
>
> On Thu, Aug 23, 2012 at 7:53 AM, rhasson > 
> wrote: 
> > Nathan, 
> > 
> > I started using node-ffi which works great.  I need to create some 
> structs 
> > so I'm using ref-struct.  Now some of my structs have pointers to 
> themselves 
> > like this: 
> > 
> > typedef struct pst_block_recorder { 
> > struct pst_block_recorder  *next; 
> > int64_t offset; 
> > size_t  size; 
> > int readcount; 
> > } pst_block_recorder; 
> > 
> > I tried to recreate this with ref-struct like this: 
> > var pst_block_recorder = Struct ({ 
> > //struct pst_block_recorder  *next; 
> > 'next': ref.refType(pst_block_recorder), 
> > //int64_t offset; 
> > 'offset': 'int64', 
> > //size_t  size; 
> > 'size': 'size_t', 
> > //int readcount; 
> > 'readcount': 'int' 
> > }); 
> > 
> > But I get the following error: 
> > assert.js:102 
> >   throw new assert.AssertionError({ 
> > ^ 
> > AssertionError: could not determine a proper "type" from: undefined 
> > at Object.coerceType (/home/roy/node_modules/ref/lib/ref.js:389:3) 
> > at Object.refType (/home/roy/node_modules/ref/lib/ref.js:304:23) 
> > 
> > 
> > I also tried making those struct fields "pointer" types but the C 
> library 
> > doesn't seem to populate them correctly. 
> > 
> > Any thoughts? 
> > 
> > Thanks, 
> > Roy 
> > 
> > -- 
> > 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 
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] node-ffi ref-struct question

2012-08-23 Thread rhasson
Sorry for not being very clear.  You're correct, pst_file is a struct with 
d_head being a pointer to another struct.  Within libpst (the C library I'm 
working with), when you call pst_open() you pass pst_file by reference 
which opens the PST file (MS outlook file) and populates the pst_file 
struct.  d_head is a pointer to another struct that holds individual 
records pulled out of the PST file.  When the pst_open() call returns I 
need to take the d_head pointer, assign it to another pointer variable of 
type pst_desc_tree and use that to pass into another function.

pst_item *item = NULL;
pst_desc_tree *d_ptr;

pst_open(&pstfile, file_name, NULL);
d_ptr = pstfile.d_head; // first record is main record
item  = pst_parse_item(&pstfile, d_ptr, NULL);

The way I did it which seems to work is:

var f = new pst_file();  //the main pst_file struct
var pstdesctree_Ptr = ref.refType(pst_desc_tree);
var d_ptr = ref.alloc(pstdesctree_Ptr);
ref.writePointer(d_ptr, 0, f.d_head);

This seems to copy the correct pointer, however when I do:
ref.deref(d_ptr) 
I get a segmentation fault.
How would I get access to the variables stored in that struct inside node?

Here is my code:  https://github.com/rhasson/node-libpst
I didn't finish converting all the structs yet but give you an idea of what 
the code looks like.  In the SRC directory I included the .c and .h files 
so you can see the structures.

Thanks,
Roy

On Thursday, August 23, 2012 1:15:15 PM UTC-4, Nathan Rajlich wrote:
>
> > In C I do this: 
> > typedef struct pst_file { 
> > pst_desc_tree  *d_head 
> > } pst_file; 
> > 
> > pst_desc_tree *d_ptr;  //this is another struct 
> > d_ptr = pstfile.d_head; 
>
> It's a pointer to a struct actually. I think you need to explain more 
> what you intend to do with the variable after. Are you trying to make 
> a duplicate of the struct? It seems to me that what you have above 
> would be achieved with "pstfile.d_head.slice(0)" but I can't really 
> imagine what you would need that for. 
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] node-struct

2012-09-04 Thread rhasson
Nate, 

I'm back with some more questions about node-struct and handling nested 
structures.

In the example below, I created one simple struct with a single Int and 
another struct with an Int and a pointer to the first struct.
What I noticed is that I can't access the int inside the nested structure. 
 Another thing I noticed is that if I do something like this:
var myStruct = Struct();
myStruct.defineProperty('someProp', ref.refType('int'));

var t = new myStruct();

accessing t.someProp fails.  If I change the definition above to 
('someProp', ref.types.int), I can access t.someProp with no problem.

Why is this and how to deal with this?

Below you can see I'm running into the same issue, however since I'm 
defining the property is a refType(struct_one) I can't figure out how to 
access its propertied.  It seems like it's an unrecognized type.

I have this .js file:

var ffi = require('ffi');
var ref = require('ref');
var Struct = require('ref-struct');

//define a simple struct
var t = Struct({
  't_i': 'int'
});

//define a second stuct with a pointer to an instance of the first struct
var f = new Struct();
  f.defineProperty('fp_i', ref.types.int);
  f.defineProperty('t_p', ref.refType(t));

var tPtr = ref.refType(t);
var fPtr = ref.refType(f);

var lib = './libffi.so.1.0.1';

var l = ffi.Library(lib, {
'setT': ['void', [fPtr]]
});

var _f = new f();
var x = null, d = null;
console.log(_f);  //I see the buffer that's created
l.setT(_f.ref());

console.log(_f);  //I see the updated buffer

console.log('fp_i: ', _f.fp_i);  //works great, returns the expected value

console.log('t_i: ', _f.t_p.t_i); //this is undefined, not sure how to 
access the nested struct's members.

My .c file looks like this:

#include 
#include 

typedef struct t {
  int t_i;
} t;

typedef struct f {
  int fp_i;
  struct t *t_p;
} f;

void setT(f *i) {
  t *tt;
  
  i->fp_i = 5;
  tt->t_i = 6;
  i->t_p = tt;
  printf("\tThis is a test: %i\n", i->t_p->t_i);  //successfully prints 6
}

void main(){}


-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] node-struct

2012-09-05 Thread rhasson
Thanks, that actually got me much closer, however now I'm getting back an 
incorrect value now.

This is the console output:
{ _pointer:  }  //the first f 
struct I instantiated, then I call the library setT method
This is a test: 6  //printf test from within the C library to show that the 
correct value is stored in the struct
{ _pointer:  }  //the returned f 
struct with the correct first variable set to 5 and the second a pointer
{ _pointer:  }  //this is the returned 
buffer from calling _f.t_p.deref() 
-1074344436  //this is t_i which should be 6

within my C library I'm setting the struct variables like this:

void setT(f *i) {
  t *tt;

  i->fp_i = 5;
  tt->t_i = 6;
  i->t_p = tt;
  printf("\tThis is a test: %i\n", i->t_p->t_i);
}



On Wednesday, September 5, 2012 1:02:40 PM UTC-4, Nathan Rajlich wrote:
>
> You examples are a little confusing, but I believe you are needing to 
> call .deref() in these cases. 
>
> Like here: `_f.t_p` that would be a pointer (a Buffer instance) to a 
> "t" struct, so to turn that back into the "t" struct instance to you 
> need to call `_f.t_p.deref()`. Then you can access `t_i` as expected. 
>
> Let me know if that's what you needed! 
>
> On Tue, Sep 4, 2012 at 10:09 PM, rhasson > 
> wrote: 
> > Nate, 
> > 
> > I'm back with some more questions about node-struct and handling nested 
> > structures. 
> > 
> > In the example below, I created one simple struct with a single Int and 
> > another struct with an Int and a pointer to the first struct. 
> > What I noticed is that I can't access the int inside the nested 
> structure. 
> > Another thing I noticed is that if I do something like this: 
> > var myStruct = Struct(); 
> > myStruct.defineProperty('someProp', ref.refType('int')); 
> > 
> > var t = new myStruct(); 
> > 
> > accessing t.someProp fails.  If I change the definition above to 
> > ('someProp', ref.types.int), I can access t.someProp with no problem. 
> > 
> > Why is this and how to deal with this? 
> > 
> > Below you can see I'm running into the same issue, however since I'm 
> > defining the property is a refType(struct_one) I can't figure out how to 
> > access its propertied.  It seems like it's an unrecognized type. 
> > 
> > I have this .js file: 
> > 
> > var ffi = require('ffi'); 
> > var ref = require('ref'); 
> > var Struct = require('ref-struct'); 
> > 
> > //define a simple struct 
> > var t = Struct({ 
> >   't_i': 'int' 
> > }); 
> > 
> > //define a second stuct with a pointer to an instance of the first 
> struct 
> > var f = new Struct(); 
> >   f.defineProperty('fp_i', ref.types.int); 
> >   f.defineProperty('t_p', ref.refType(t)); 
> > 
> > var tPtr = ref.refType(t); 
> > var fPtr = ref.refType(f); 
> > 
> > var lib = './libffi.so.1.0.1'; 
> > 
> > var l = ffi.Library(lib, { 
> > 'setT': ['void', [fPtr]] 
> > }); 
> > 
> > var _f = new f(); 
> > var x = null, d = null; 
> > console.log(_f);  //I see the buffer that's created 
> > l.setT(_f.ref()); 
> > 
> > console.log(_f);  //I see the updated buffer 
> > 
> > console.log('fp_i: ', _f.fp_i);  //works great, returns the expected 
> value 
> > 
> > console.log('t_i: ', _f.t_p.t_i); //this is undefined, not sure how to 
> > access the nested struct's members. 
> > 
> > My .c file looks like this: 
> > 
> > #include  
> > #include  
> > 
> > typedef struct t { 
> >   int t_i; 
> > } t; 
> > 
> > typedef struct f { 
> >   int fp_i; 
> >   struct t *t_p; 
> > } f; 
> > 
> > void setT(f *i) { 
> >   t *tt; 
> > 
> >   i->fp_i = 5; 
> >   tt->t_i = 6; 
> >   i->t_p = tt; 
> >   printf("\tThis is a test: %i\n", i->t_p->t_i);  //successfully prints 
> 6 
> > } 
> > 
> > void main(){} 
> > 
> > 
> > -- 
> > 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 
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: node-struct

2012-09-05 Thread rhasson
I figured out my problem.  I was allocating on the stack and needed to use 
malloc.

Here is the correct C function:

void setT(f *i) {
  t *tt = malloc(sizeof(t));

  i->fp_i = 5;
  tt->t_i = 6;
  i->t_p = tt;
  printf("\tThis is a test: %i\n", i->t_p->t_i);
}

Here is the correct output:

{ _pointer:  }
This is a test: 6
{ _pointer:  }
{ _pointer:  }
6

Thanks,
Roy


On Wednesday, September 5, 2012 1:09:48 AM UTC-4, rhasson wrote:
>
> Nate, 
>
> I'm back with some more questions about node-struct and handling nested 
> structures.
>
> In the example below, I created one simple struct with a single Int and 
> another struct with an Int and a pointer to the first struct.
> What I noticed is that I can't access the int inside the nested structure. 
>  Another thing I noticed is that if I do something like this:
> var myStruct = Struct();
> myStruct.defineProperty('someProp', ref.refType('int'));
>
> var t = new myStruct();
>
> accessing t.someProp fails.  If I change the definition above to 
> ('someProp', ref.types.int), I can access t.someProp with no problem.
>
> Why is this and how to deal with this?
>
> Below you can see I'm running into the same issue, however since I'm 
> defining the property is a refType(struct_one) I can't figure out how to 
> access its propertied.  It seems like it's an unrecognized type.
>
> I have this .js file:
>
> var ffi = require('ffi');
> var ref = require('ref');
> var Struct = require('ref-struct');
>
> //define a simple struct
> var t = Struct({
>   't_i': 'int'
> });
>
> //define a second stuct with a pointer to an instance of the first struct
> var f = new Struct();
>   f.defineProperty('fp_i', ref.types.int);
>   f.defineProperty('t_p', ref.refType(t));
>
> var tPtr = ref.refType(t);
> var fPtr = ref.refType(f);
>
> var lib = './libffi.so.1.0.1';
>
> var l = ffi.Library(lib, {
> 'setT': ['void', [fPtr]]
> });
>
> var _f = new f();
> var x = null, d = null;
> console.log(_f);  //I see the buffer that's created
> l.setT(_f.ref());
>
> console.log(_f);  //I see the updated buffer
>
> console.log('fp_i: ', _f.fp_i);  //works great, returns the expected value
>
> console.log('t_i: ', _f.t_p.t_i); //this is undefined, not sure how to 
> access the nested struct's members.
>
> My .c file looks like this:
>
> #include 
> #include 
>
> typedef struct t {
>   int t_i;
> } t;
>
> typedef struct f {
>   int fp_i;
>   struct t *t_p;
> } f;
>
> void setT(f *i) {
>   t *tt;
>   
>   i->fp_i = 5;
>   tt->t_i = 6;
>   i->t_p = tt;
>   printf("\tThis is a test: %i\n", i->t_p->t_i);  //successfully prints 6
> }
>
> void main(){}
>
>
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: node-struct

2012-09-05 Thread rhasson
Now, the issue I'm having is in trying to port this methodology to an 
external library out of my control (libpst) which does not use malloc on 
local structs that then have pointers assigned to the main struct that was 
passed in by reference which are then overwritten.  Is there a way to 
address this using node-ref and node-struct ?

On Wednesday, September 5, 2012 1:09:48 AM UTC-4, rhasson wrote:
>
> Nate, 
>
> I'm back with some more questions about node-struct and handling nested 
> structures.
>
> In the example below, I created one simple struct with a single Int and 
> another struct with an Int and a pointer to the first struct.
> What I noticed is that I can't access the int inside the nested structure. 
>  Another thing I noticed is that if I do something like this:
> var myStruct = Struct();
> myStruct.defineProperty('someProp', ref.refType('int'));
>
> var t = new myStruct();
>
> accessing t.someProp fails.  If I change the definition above to 
> ('someProp', ref.types.int), I can access t.someProp with no problem.
>
> Why is this and how to deal with this?
>
> Below you can see I'm running into the same issue, however since I'm 
> defining the property is a refType(struct_one) I can't figure out how to 
> access its propertied.  It seems like it's an unrecognized type.
>
> I have this .js file:
>
> var ffi = require('ffi');
> var ref = require('ref');
> var Struct = require('ref-struct');
>
> //define a simple struct
> var t = Struct({
>   't_i': 'int'
> });
>
> //define a second stuct with a pointer to an instance of the first struct
> var f = new Struct();
>   f.defineProperty('fp_i', ref.types.int);
>   f.defineProperty('t_p', ref.refType(t));
>
> var tPtr = ref.refType(t);
> var fPtr = ref.refType(f);
>
> var lib = './libffi.so.1.0.1';
>
> var l = ffi.Library(lib, {
> 'setT': ['void', [fPtr]]
> });
>
> var _f = new f();
> var x = null, d = null;
> console.log(_f);  //I see the buffer that's created
> l.setT(_f.ref());
>
> console.log(_f);  //I see the updated buffer
>
> console.log('fp_i: ', _f.fp_i);  //works great, returns the expected value
>
> console.log('t_i: ', _f.t_p.t_i); //this is undefined, not sure how to 
> access the nested struct's members.
>
> My .c file looks like this:
>
> #include 
> #include 
>
> typedef struct t {
>   int t_i;
> } t;
>
> typedef struct f {
>   int fp_i;
>   struct t *t_p;
> } f;
>
> void setT(f *i) {
>   t *tt;
>   
>   i->fp_i = 5;
>   tt->t_i = 6;
>   i->t_p = tt;
>   printf("\tThis is a test: %i\n", i->t_p->t_i);  //successfully prints 6
> }
>
> void main(){}
>
>
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: node-struct

2012-09-05 Thread rhasson
So the example I used here was just for the sake of understanding how ref 
and struct work.  I think I get it now.

Now I started all this because I wanted to create FFI bindings to libpst 
(http://www.five-ten-sg.com/libpst/).  I started by creating all the 
necessary structs and made a call to the first function which opens the 
.PST file (outlook personal file), followed by calls to create the indexes. 
 The basic members of the struct are populated fine, however the nested 
structs are not.  They come back with strange memory addresses 
which obviously cause seg fault when I try to access them.

The main code is here 
https://github.com/rhasson/node-libpst/blob/master/ffi_nodepst.js#L1153-L1175 
scrolling to the top of the source you will see all the struct declarations.

Here is the output of GDB:

(gdb) run
Starting program: /usr/local/bin/node ffi_nodepst.js
Reading symbols for shared libraries 
.
 
done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
File outlook.pst was opened successfully  //outlook.pst is the file I'm 
opening and is populated within the pst_file struct and returned correctly
Loading index...
index ret:  0  //0 means that the indexes were loaded correctly, however 
here is where the nested structs are malloced and populated by the library
Loading extended attributes...
extended ret:  1  //1 means that the extended attributes where loaded 
correctly, again I can't access them
f:  { _pointer:  }
i_head:  false  //this is just a ref.isNull() test on each of the nested 
structs
i_tail:  false
d_head:  false
d_tail:  false
x_head:  false
block_head:  false

Program received signal EXC_BAD_ACCESS, Could not access memory.   //here I 
try to do f.i_head.deref() which fails since the memory location is not 
valid, but I can't figure out why.
Reason: KERN_INVALID_ADDRESS at address: 0x7600
0x000100167dcc in 
v8::internal::ElementsAccessorBase >::Get ()
(gdb) 


On Wednesday, September 5, 2012 5:12:55 PM UTC-4, Nathan Rajlich wrote:
>
> Glad you're figuring it out on your own :p 
>
> I don't get your latest question: you're already passing a struct in 
> by reference in the setT() function so I'm not sure what's different. 
>
> On Wed, Sep 5, 2012 at 1:44 PM, rhasson > 
> wrote: 
> > Now, the issue I'm having is in trying to port this methodology to an 
> > external library out of my control (libpst) which does not use malloc on 
> > local structs that then have pointers assigned to the main struct that 
> was 
> > passed in by reference which are then overwritten.  Is there a way to 
> > address this using node-ref and node-struct ? 
> > 
> > 
> > On Wednesday, September 5, 2012 1:09:48 AM UTC-4, rhasson wrote: 
> >> 
> >> Nate, 
> >> 
> >> I'm back with some more questions about node-struct and handling nested 
> >> structures. 
> >> 
> >> In the example below, I created one simple struct with a single Int and 
> >> another struct with an Int and a pointer to the first struct. 
> >> What I noticed is that I can't access the int inside the nested 
> structure. 
> >> Another thing I noticed is that if I do something like this: 
> >> var myStruct = Struct(); 
> >> myStruct.defineProperty('someProp', ref.refType('int')); 
> >> 
> >> var t = new myStruct(); 
> >> 
> >> accessing t.someProp fails.  If I change the definition above to 
> >> ('someProp', ref.types.int), I can access t.someProp with no problem. 
> >> 
> >> Why is this and how to deal with this? 
> >> 
> >> Below you can see I'm running into the same issue, however since I'm 
> >> defining the property is a refType(struct_one) I can't figure out how 
> to 
> >> access its propertied.  It seems like it's an unrecognized type. 
> >> 
> >> I have this .js file: 
> >> 
> >> var ffi = require('ffi'); 
> >> var ref = require('ref'); 
> >> var Struct = require('ref-struct'); 
> >> 
> >> //define a simple struct 
> >> var t = Struct({ 
> >>   't_i': 'int' 
> >> }); 
> >> 
> >> //define a second stuct with a pointer to an instance of the first 
> struct 
> >> var f = new Struct(); 
> >>   f.defineProperty('fp_i', ref.types.int); 
> >>   f.defineProperty('t_p', ref.refType(t)); 
> &

Re: [nodejs] Re: node-struct

2012-09-08 Thread rhasson
Thanks to the awesome help from Benvie, we figured out the issue.

When declaring the structs, I wanted to create a property that is a pointer 
to another struct.  Following my intuition and my understanding of 
ref-struct I did:
pst_desc_tree.defineProperty('next', ref.refType(pst_desc_tree));  The 
assumption here is that ref.refType(struct_name) will return a pointer to 
that struct.  However struct_name was already a pointer to the struct so in 
fast ref.refType was returning a pointer to a pointer to a struct.
Therefore the correct definition is:  pst_desc_tree.defineProperty('next', 
pst_desc_tree); which means "next" is a pointer to struct named 
pst_desc_tree which is defined by simply: var pst_desc_tree = new Struct();

Anyways, I thought I'd circle back and provide the answer in case anyone 
else is interested in delving into the awesome world of FFI.

Roy

On Thursday, September 6, 2012 1:21:59 AM UTC-4, rhasson wrote:
>
> So the example I used here was just for the sake of understanding how ref 
> and struct work.  I think I get it now.
>
> Now I started all this because I wanted to create FFI bindings to libpst (
> http://www.five-ten-sg.com/libpst/).  I started by creating all the 
> necessary structs and made a call to the first function which opens the 
> .PST file (outlook personal file), followed by calls to create the indexes. 
>  The basic members of the struct are populated fine, however the nested 
> structs are not.  They come back with strange memory addresses 
> which obviously cause seg fault when I try to access them.
>
> The main code is here 
> https://github.com/rhasson/node-libpst/blob/master/ffi_nodepst.js#L1153-L1175scrolling
>  to the top of the source you will see all the struct declarations.
>
> Here is the output of GDB:
>
> (gdb) run
> Starting program: /usr/local/bin/node ffi_nodepst.js
> Reading symbols for shared libraries 
> .
>  
> done
> Reading symbols for shared libraries . done
> Reading symbols for shared libraries . done
> Reading symbols for shared libraries . done
> File outlook.pst was opened successfully  //outlook.pst is the file I'm 
> opening and is populated within the pst_file struct and returned correctly
> Loading index...
> index ret:  0  //0 means that the indexes were loaded correctly, however 
> here is where the nested structs are malloced and populated by the library
> Loading extended attributes...
> extended ret:  1  //1 means that the extended attributes where loaded 
> correctly, again I can't access them
> f:  { _pointer:  00 00 00 d0 04 20 02 01 00 00 00 00 00 00 00 00 00 00 00 90 0d 20 02 01 00 
> 00 00 30 12 20 02 01 00 00 00 60 12 20 ...> }
> i_head:  false  //this is just a ref.isNull() test on each of the nested 
> structs
> i_tail:  false
> d_head:  false
> d_tail:  false
> x_head:  false
> block_head:  false
>
> Program received signal EXC_BAD_ACCESS, Could not access memory.   //here 
> I try to do f.i_head.deref() which fails since the memory location is not 
> valid, but I can't figure out why.
> Reason: KERN_INVALID_ADDRESS at address: 0x7600
> 0x000100167dcc in 
> v8::internal::ElementsAccessorBase  
> v8::internal::ElementsKindTraits<(v8::internal::ElementsKind)9> >::Get ()
> (gdb) 
>
>
> On Wednesday, September 5, 2012 5:12:55 PM UTC-4, Nathan Rajlich wrote:
>>
>> Glad you're figuring it out on your own :p 
>>
>> I don't get your latest question: you're already passing a struct in 
>> by reference in the setT() function so I'm not sure what's different. 
>>
>> On Wed, Sep 5, 2012 at 1:44 PM, rhasson  wrote: 
>> > Now, the issue I'm having is in trying to port this methodology to an 
>> > external library out of my control (libpst) which does not use malloc 
>> on 
>> > local structs that then have pointers assigned to the main struct that 
>> was 
>> > passed in by reference which are then overwritten.  Is there a way to 
>> > address this using node-ref and node-struct ? 
>> > 
>> > 
>> > On Wednesday, September 5, 2012 1:09:48 AM UTC-4, rhasson wrote: 
>> >> 
>> >> Nate, 
>> >> 
>> >> I'm back with some more questions about node-struct and handling 
>> nested 
>> >> structures. 
>> >> 
>> >> In the example below, I created one simple struct with a single Int 
>> and 
>> >> another struct with an Int and a pointer to the first struct. 
>> >> What I noticed is that

Re: [nodejs] Forever with ssh

2012-10-16 Thread rhasson
use "screen"

On Tuesday, October 16, 2012 10:24:40 AM UTC-4, Chad Engler wrote:
>
> Just use: 
>
> > forever start 

[nodejs] NODE_MODULE error

2012-03-25 Thread rhasson
I'm writing a native module that wraps a C program.  Below is my
module declaration but when I build it with node-waf I get the
following error:

error: ‘node_module_struct’ in class ‘node’ does not name a type

#define FREELING_BINDING
#include 
#include 
#include "freeling_tokenizer.h"

void InitAll(v8::Handle target) {
FreeLingTokenizer::Init(target);
}

NODE_MODULE(freeling, InitAll)

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: NODE_MODULE error

2012-03-25 Thread rhasson
I figured it out.  in my wscript, I should have added my
"freeling_tokenizer.cc to the source array.

On Mar 25, 8:44 am, rhasson  wrote:
> I'm writing a native module that wraps a C program.  Below is my
> module declaration but when I build it with node-waf I get the
> following error:
>
> error: ‘node_module_struct’ in class ‘node’ does not name a type
>
> #define FREELING_BINDING
> #include 
> #include 
> #include "freeling_tokenizer.h"
>
> void InitAll(v8::Handle target) {
>         FreeLingTokenizer::Init(target);
>
> }
>
> NODE_MODULE(freeling, InitAll)

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Unable to load shared library

2012-03-27 Thread rhasson
Nathan, 

I'm having a similar problem.  I tried node-waf and node-gyp but both 
result in the same error (unable to load share library).  I'm running 
Fedora 14 (in VM) with node 0.6.7 and 0.6.13.

I checked that my NODE_MODULE declaration is correct and it is.

Here is my module declaration:

#define FREE_LING_BINDING
#include 
#include 
#include "freeling_tokenizer.h"

void InitAll(v8::Handle target) {
FreeLingTokenizer::Init(target);
}

NODE_MODULE(freeling, InitAll)

Here is my Init:

#define FREE_LING_TOKENIZER

#include 
#include 

#include "freeling_tokenizer.h"

FreeLingTokenizer::FreeLingTokenizer() {};
FreeLingTokenizer::~FreeLingTokenizer() {};

void FreeLingTokenizer::Init(v8::Handle target) {
v8::HandleScope scope;
//using the functionTemplate, create a function FreeLingTokenizer
v8::Local tpl = v8::FunctionTemplate::New(New);
tpl->SetClassName(v8::String::NewSymbol("FreeLingTokenizer"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);

//create prototype chain for above function
tpl->PrototypeTemplate()->Set(v8::String::NewSymbol("tokenize"),
v8::FunctionTemplate::New(Tokenize)->GetFunction());
v8::Persistent constructor = 
v8::Persistent::New(tpl->GetFunction());
 target->Set(v8::String::NewSymbol("FreeLingTokenizer"), constructor);
}

Here is my binding.gyp:

{
  'targets': [
{
  'target_name': 'freeling',
  'conditions': [
  ['OS=="linux"', {
  'cflags': ['-I/home/roy/freeling/free3/include']
  }]
  ],
  'sources': [ 'freeling.cc', 'freeling_tokenizer.cc' ]
}
  ]
}


Thanks,
Roy

On Tuesday, March 27, 2012 1:20:35 PM UTC-4, Nathan Rajlich wrote:
>
> You should have something like this in your .cc file: 
> https://github.com/joyent/node/blob/master/test/addons/hello-world/binding.cc#L15
>
> On Tue, Mar 27, 2012 at 9:05 AM, SteveCronin wrote:
>
>> Nathan;
>>
>> I don't understand the 'NODE_MODULE' comment.
>> I don't have any such macro...
>> My module wraps a class written in C++...
>> Can you point me to something which would provide more details on what 
>> you meant?
>>
>> Steve
>>
>>
>> On Monday, March 26, 2012 8:01:00 PM UTC-5, Nathan Rajlich wrote:
>>>
>>> I'm still using node-waf to manually compile modules -- is that the 
 problem?

>>>
>>> Give node-gyp a shot: 
>>> https://github.com/**TooTallNate/node-gyp
>>>
>>> Also note that the "target_name" property (the "obj.target" in the 
>>> wscript) must match the first argument to the NODE_MODULE macro in your 
>>> module's entry point.
>>>  
>>  -- 
>> 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 nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] namespace conflict with "node"

2012-03-27 Thread rhasson
I'm building a native module that wraps a library which declares a "node" 
class.  This class is used everywhere in the library so changing it is very 
tedious.  Nodejs uses a "node" namespace.  Because of this when I build my 
module I get name conflict errors everywhere.  To test my theory, I renamed 
the "node" namespace to "nodejs" in node.h and node_object_wrap.h and it 
resolved all the error, complied, but now it won't load from within nodejs. 
 Not sure this is related but at least I know it's a namespace issue at 
first.

How can I get around this issue within my module declaration?  I prefer not 
to touch the nodejs sources as well as not to touch the native library 
sources.

Is that possible?

Thanks,
Roy

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Unable to load shared library

2012-03-27 Thread rhasson
Ok, so I installed 0.7.6 and compiled with node-gyp fine and this time a 
little more details but I'm not sure how to resolve this issue.

> process.version
'v0.7.6'
> l = require('./freeling.node')
Error: /home/roy/freeling/node_bind/build/Debug/freeling.node: undefined 
symbol: _ZN17FreeLingTokenizer10GetWStringEN2v86HandleINS0_6StringEEE
at Object..node (module.js:476:11)
at Module.load (module.js:352:32)
at Function._load (module.js:310:12)
at Module.require (module.js:358:17)
at require (module.js:374:17)
at repl:1:6
at REPLServer.eval (repl.js:85:21)
at Interface. (repl.js:202:12)
at Interface.emit (events.js:67:17)
at Interface._onLine (readline.js:169:10)

Inside my class declaration under private I have this:
 static std::wstring GetWString(v8::Handle str);

Then in my .cc file I have the actual function:
// Convert a V8 string to a wide string.
std::wstring GetWString(v8::Handle str) {
  v8::HandleScope scope;

  uint16_t* buf = new uint16_t[str->Length()+1];
  str->Write(buf);
  std::wstring value = reinterpret_cast(buf);
  delete [] buf;
  
  return value;
}

I'm not sure why the error is "undefined symbol".

Thanks,
Roy

On Monday, March 26, 2012 5:30:29 PM UTC-4, SteveCronin wrote:
>
> I'm getting an error when I 'require' a module I have built.
>
> Is this a 32/64bit issue?  If so how do I best correct for future node 
> compatibility?
>
> node 0.6.13 on Mac OS X 10.7.3
>
> I'm still using node-waf to manually compile modules -- is that the 
> problem?
> Here's the wscript:
> srcdir = '.'
> blddir = 'build'
> VERSION = '1.0.0'
> APPNAME = 'XYZ-ABC-utils'
>
> def set_options(opt):
> opt.tool_options('compiler_cxx')
>
> def configure(conf):
> conf.check_tool('compiler_cxx')
> conf.check_tool('node_addon')
>
> def build(bld):
> obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
> obj.source = 'node-ABC-support.cc', 'ABC1-support.cc', 
> 'ABC2-support.cc',  'ABC3-support.cc'
> obj.libpath = [ bld.path.abspath() ]
> obj.lib = 'GHJ.o'
> bld.env.append_value('LINKFLAGS', '-lcrypto -lssl -lz'.split())
> obj.target = 'XYZ-ABC-utils'
>
> Even if I add this line to the script I still get the same errors:
>
> obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE"]
>

On Monday, March 26, 2012 5:30:29 PM UTC-4, SteveCronin wrote:
>
> I'm getting an error when I 'require' a module I have built.
>
> Is this a 32/64bit issue?  If so how do I best correct for future node 
> compatibility?
>
> node 0.6.13 on Mac OS X 10.7.3
>
> I'm still using node-waf to manually compile modules -- is that the 
> problem?
> Here's the wscript:
> srcdir = '.'
> blddir = 'build'
> VERSION = '1.0.0'
> APPNAME = 'XYZ-ABC-utils'
>
> def set_options(opt):
> opt.tool_options('compiler_cxx')
>
> def configure(conf):
> conf.check_tool('compiler_cxx')
> conf.check_tool('node_addon')
>
> def build(bld):
> obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
> obj.source = 'node-ABC-support.cc', 'ABC1-support.cc', 
> 'ABC2-support.cc',  'ABC3-support.cc'
> obj.libpath = [ bld.path.abspath() ]
> obj.lib = 'GHJ.o'
> bld.env.append_value('LINKFLAGS', '-lcrypto -lssl -lz'.split())
> obj.target = 'XYZ-ABC-utils'
>
> Even if I add this line to the script I still get the same errors:
>
> obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE"]
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Unable to load shared library

2012-03-27 Thread rhasson
Never mind, I found the problem.

In my .cc file I was declaring the function as GetWString() instead of 
FreeLingTokenizer::GetWString().  After adding the scope it was ok.  Now I 
have another bug but I'll spare you my debugging unless I get stuck.

Thank you, switching to 0.7.6 and node-gyp was a great idea, at least now I 
get real error messages that I can debug.

Roy

On Wednesday, March 28, 2012 12:29:48 AM UTC-4, rhasson wrote:
>
> Ok, so I installed 0.7.6 and compiled with node-gyp fine and this time a 
> little more details but I'm not sure how to resolve this issue.
>
> > process.version
> 'v0.7.6'
> > l = require('./freeling.node')
> Error: /home/roy/freeling/node_bind/build/Debug/freeling.node: undefined 
> symbol: _ZN17FreeLingTokenizer10GetWStringEN2v86HandleINS0_6StringEEE
> at Object..node (module.js:476:11)
> at Module.load (module.js:352:32)
> at Function._load (module.js:310:12)
> at Module.require (module.js:358:17)
> at require (module.js:374:17)
> at repl:1:6
> at REPLServer.eval (repl.js:85:21)
> at Interface. (repl.js:202:12)
> at Interface.emit (events.js:67:17)
> at Interface._onLine (readline.js:169:10)
>
> Inside my class declaration under private I have this:
>  static std::wstring GetWString(v8::Handle str);
>
> Then in my .cc file I have the actual function:
> // Convert a V8 string to a wide string.
> std::wstring GetWString(v8::Handle str) {
>   v8::HandleScope scope;
>
>   uint16_t* buf = new uint16_t[str->Length()+1];
>   str->Write(buf);
>   std::wstring value = reinterpret_cast(buf);
>   delete [] buf;
>   
>   return value;
> }
>
> I'm not sure why the error is "undefined symbol".
>
> Thanks,
> Roy
>
> On Monday, March 26, 2012 5:30:29 PM UTC-4, SteveCronin wrote:
>>
>> I'm getting an error when I 'require' a module I have built.
>>
>> Is this a 32/64bit issue?  If so how do I best correct for future node 
>> compatibility?
>>
>> node 0.6.13 on Mac OS X 10.7.3
>>
>> I'm still using node-waf to manually compile modules -- is that the 
>> problem?
>> Here's the wscript:
>> srcdir = '.'
>> blddir = 'build'
>> VERSION = '1.0.0'
>> APPNAME = 'XYZ-ABC-utils'
>>
>> def set_options(opt):
>> opt.tool_options('compiler_cxx')
>>
>> def configure(conf):
>> conf.check_tool('compiler_cxx')
>> conf.check_tool('node_addon')
>>
>> def build(bld):
>> obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
>> obj.source = 'node-ABC-support.cc', 'ABC1-support.cc', 
>> 'ABC2-support.cc',  'ABC3-support.cc'
>> obj.libpath = [ bld.path.abspath() ]
>> obj.lib = 'GHJ.o'
>> bld.env.append_value('LINKFLAGS', '-lcrypto -lssl -lz'.split())
>> obj.target = 'XYZ-ABC-utils'
>>
>> Even if I add this line to the script I still get the same errors:
>>
>> obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE"]
>>
>
> On Monday, March 26, 2012 5:30:29 PM UTC-4, SteveCronin wrote:
>>
>> I'm getting an error when I 'require' a module I have built.
>>
>> Is this a 32/64bit issue?  If so how do I best correct for future node 
>> compatibility?
>>
>> node 0.6.13 on Mac OS X 10.7.3
>>
>> I'm still using node-waf to manually compile modules -- is that the 
>> problem?
>> Here's the wscript:
>> srcdir = '.'
>> blddir = 'build'
>> VERSION = '1.0.0'
>> APPNAME = 'XYZ-ABC-utils'
>>
>> def set_options(opt):
>> opt.tool_options('compiler_cxx')
>>
>> def configure(conf):
>> conf.check_tool('compiler_cxx')
>> conf.check_tool('node_addon')
>>
>> def build(bld):
>> obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
>> obj.source = 'node-ABC-support.cc', 'ABC1-support.cc', 
>> 'ABC2-support.cc',  'ABC3-support.cc'
>> obj.libpath = [ bld.path.abspath() ]
>> obj.lib = 'GHJ.o'
>> bld.env.append_value('LINKFLAGS', '-lcrypto -lssl -lz'.split())
>> obj.target = 'XYZ-ABC-utils'
>>
>> Even if I add this line to the script I still get the same errors:
>>
>> obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE"]
>>
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Unable to load shared library

2012-03-28 Thread rhasson
Nathan, 

I have a question about node-gyp.  I have a native library that I'm 
building a node binding for.  that library (freeling) has been 
built separately and in the build directory has an include and lib folders 
with the headers and .so files.
I built my module (the node binding to freeling), everything compiles fine 
but when I try to require the module in node I get the following error:
> require('./freeling')
Error: libfreeling-3.0-alfa1.so: cannot open shared object file: No such 
file or directory
at Object..node (module.js:476:11)
at Module.load (module.js:352:32)
at Function._load (module.js:310:12)
at Module.require (module.js:358:17)
at require (module.js:374:17)
at repl:1:2
at REPLServer.eval (repl.js:85:21)
at Interface. (repl.js:202:12)
at Interface.emit (events.js:67:17)
at Interface._onLine (readline.js:169:10)

Here is my binding.gyp file:

{
  'targets': [
{
  'target_name': 'freeling',
  'type': 'loadable_module',
  'product_extension': 'node',
  'product_prefix': '',
  'include_dirs': ['/home/roy/freeling/free3/include'],
  'libraries': [
  '/home/roy/freeling/free3/lib/libfreeling.so',
  '/home/roy/freeling/free3/lib/libfreeling-3.0-alfa1.so'
  ],
  'sources': ['freeling.cc', 'freeling_tokenizer.cc']
}
  ]
}

I'm not sure I'm doing this correctly.  Basically, I need to link by module 
to the freeling headers and object files so it recognizes the freeling 
classes and functions I'll be calling from within my module.

Thanks,
Roy

On Wednesday, March 28, 2012 12:38:29 AM UTC-4, rhasson wrote:
>
> Never mind, I found the problem.
>
> In my .cc file I was declaring the function as GetWString() instead of 
> FreeLingTokenizer::GetWString().  After adding the scope it was ok.  Now I 
> have another bug but I'll spare you my debugging unless I get stuck.
>
> Thank you, switching to 0.7.6 and node-gyp was a great idea, at least now 
> I get real error messages that I can debug.
>
> Roy
>
> On Wednesday, March 28, 2012 12:29:48 AM UTC-4, rhasson wrote:
>>
>> Ok, so I installed 0.7.6 and compiled with node-gyp fine and this time a 
>> little more details but I'm not sure how to resolve this issue.
>>
>> > process.version
>> 'v0.7.6'
>> > l = require('./freeling.node')
>> Error: /home/roy/freeling/node_bind/build/Debug/freeling.node: undefined 
>> symbol: _ZN17FreeLingTokenizer10GetWStringEN2v86HandleINS0_6StringEEE
>> at Object..node (module.js:476:11)
>> at Module.load (module.js:352:32)
>> at Function._load (module.js:310:12)
>> at Module.require (module.js:358:17)
>> at require (module.js:374:17)
>> at repl:1:6
>> at REPLServer.eval (repl.js:85:21)
>> at Interface. (repl.js:202:12)
>> at Interface.emit (events.js:67:17)
>> at Interface._onLine (readline.js:169:10)
>>
>> Inside my class declaration under private I have this:
>>  static std::wstring GetWString(v8::Handle str);
>>
>> Then in my .cc file I have the actual function:
>> // Convert a V8 string to a wide string.
>> std::wstring GetWString(v8::Handle str) {
>>   v8::HandleScope scope;
>>
>>   uint16_t* buf = new uint16_t[str->Length()+1];
>>   str->Write(buf);
>>   std::wstring value = reinterpret_cast(buf);
>>   delete [] buf;
>>   
>>   return value;
>> }
>>
>> I'm not sure why the error is "undefined symbol".
>>
>> Thanks,
>> Roy
>>
>> On Monday, March 26, 2012 5:30:29 PM UTC-4, SteveCronin wrote:
>>>
>>> I'm getting an error when I 'require' a module I have built.
>>>
>>> Is this a 32/64bit issue?  If so how do I best correct for future node 
>>> compatibility?
>>>
>>> node 0.6.13 on Mac OS X 10.7.3
>>>
>>> I'm still using node-waf to manually compile modules -- is that the 
>>> problem?
>>> Here's the wscript:
>>> srcdir = '.'
>>> blddir = 'build'
>>> VERSION = '1.0.0'
>>> APPNAME = 'XYZ-ABC-utils'
>>>
>>> def set_options(opt):
>>> opt.tool_options('compiler_cxx')
>>>
>>> def configure(conf):
>>> conf.check_tool('compiler_cxx')
>>> conf.check_tool('node_addon')
>>>
>>> def build(bld):
>>> obj = bld.new_task_gen('cxx&#x

Re: [nodejs] Re: Unable to load shared library

2012-03-29 Thread rhasson
[root@localdev Debug]# ldd freeling.node 
linux-gate.so.1 =>  (0x00ee2000)
libfreeling-3.0-alfa1.so => not found
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x0011)
libm.so.6 => /lib/libm.so.6 (0x00c29000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00ae7000)
libpthread.so.0 => /lib/libpthread.so.0 (0x008d)
libc.so.6 => /lib/libc.so.6 (0x0023b000)
/lib/ld-linux.so.2 (0x0021c000)

Did I use the wrong binding.gyp command to point to it?

On Thursday, March 29, 2012 3:06:44 AM UTC-4, Nathan Rajlich wrote:
>
> What does `ldd freeling.node` say (assuming you're on Linux)?
>
> On Wed, Mar 28, 2012 at 10:51 PM, rhasson <> wrote:
>
>> Nathan, 
>>
>> I have a question about node-gyp.  I have a native library that I'm 
>> building a node binding for.  that library (freeling) has been 
>> built separately and in the build directory has an include and lib folders 
>> with the headers and .so files.
>> I built my module (the node binding to freeling), everything compiles 
>> fine but when I try to require the module in node I get the following error:
>> > require('./freeling')
>> Error: libfreeling-3.0-alfa1.so: cannot open shared object file: No such 
>> file or directory
>> at Object..node (module.js:476:11)
>> at Module.load (module.js:352:32)
>> at Function._load (module.js:310:12)
>> at Module.require (module.js:358:17)
>> at require (module.js:374:17)
>> at repl:1:2
>> at REPLServer.eval (repl.js:85:21)
>> at Interface. (repl.js:202:12)
>> at Interface.emit (events.js:67:17)
>> at Interface._onLine (readline.js:169:10)
>>
>> Here is my binding.gyp file:
>>
>> {
>>   'targets': [
>> {
>>   'target_name': 'freeling',
>>   'type': 'loadable_module',
>>   'product_extension': 'node',
>>   'product_prefix': '',
>>   'include_dirs': ['/home/roy/freeling/free3/include'],
>>   'libraries': [
>>   '/home/roy/freeling/free3/lib/libfreeling.so',
>>   '/home/roy/freeling/free3/lib/libfreeling-3.0-alfa1.so'
>>   ],
>>   'sources': ['freeling.cc', 'freeling_tokenizer.cc']
>> }
>>   ]
>> }
>>
>> I'm not sure I'm doing this correctly.  Basically, I need to link by 
>> module to the freeling headers and object files so it recognizes the 
>> freeling classes and functions I'll be calling from within my module.
>>
>> Thanks,
>> Roy
>>
>> On Wednesday, March 28, 2012 12:38:29 AM UTC-4, rhasson wrote:
>>>
>>> Never mind, I found the problem.
>>>
>>> In my .cc file I was declaring the function as GetWString() instead of 
>>> FreeLingTokenizer::GetWString(**).  After adding the scope it was ok. 
>>>  Now I have another bug but I'll spare you my debugging unless I get stuck.
>>>
>>> Thank you, switching to 0.7.6 and node-gyp was a great idea, at least 
>>> now I get real error messages that I can debug.
>>>
>>> Roy
>>>
>>> On Wednesday, March 28, 2012 12:29:48 AM UTC-4, rhasson wrote:
>>>>
>>>> Ok, so I installed 0.7.6 and compiled with node-gyp fine and this time 
>>>> a little more details but I'm not sure how to resolve this issue.
>>>>
>>>> > process.version
>>>> 'v0.7.6'
>>>> > l = require('./freeling.node')
>>>> Error: /home/roy/freeling/node_bind/**build/Debug/freeling.node: 
>>>> undefined symbol: _**ZN17FreeLingTokenizer10GetWStr**
>>>> ingEN2v86HandleINS0_6StringEEE
>>>> at Object..node (module.js:476:11)
>>>> at Module.load (module.js:352:32)
>>>> at Function._load (module.js:310:12)
>>>> at Module.require (module.js:358:17)
>>>> at require (module.js:374:17)
>>>> at repl:1:6
>>>> at REPLServer.eval (repl.js:85:21)
>>>> at Interface. (repl.js:202:12)
>>>> at Interface.emit (events.js:67:17)
>>>> at Interface._onLine (readline.js:169:10)
>>>>
>>>> Inside my class declaration under private I have this:
>>>>  static std::wstring GetWString(v8::Handle str);
>>>>
>>>> Then in my .cc file I have the actual function:
>>>> // Convert a V8 string to a wide string.
>>>> std::wstring GetWString(v8:

Re: [nodejs] Re: Unable to load shared library

2012-03-29 Thread rhasson
yes I did.  I placed in the same directory as my library .cc files, I 
placed it in the freeling.node directory.

I'm suspicious to how I'm setting up my binding.gyp file.  I can't figure 
out how to tell in my binding.gyp file that I need my library to link with 
an external .so file.  Can you provide a sample .gyp file that show that?

This is what I have but it still doesn't like libfreeling-3.0-alfa1.so 
properly.

{
  'targets': [
{
  'target_name': 'freeling',
  'type': 'loadable_module',
  'product_extension': 'node',
  'product_prefix': '',
  'include_dirs': ['/home/roy/freeling/free3/include'],
  'link_settings': {
  'libraries': ['libfreeling-3.0-alfa1.so'],
  'library_dirs': ['/home/roy/freeling/free3/lib'],
   },
  'sources': ['freeling.cc', 'freeling_tokenizer.cc'],
},
  ],
}


On Thursday, March 29, 2012 11:43:24 AM UTC-4, Nathan Rajlich wrote:
>
>
> libfreeling-3.0-alfa1.so => not found
>>
>
> So that needs to be fixed :p
>
> Did you try placing libfreeling-3.0-alfa1.so in the same directory as 
> freeling.node?
>  

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Unable to load shared library

2012-03-29 Thread rhasson
If I was to get a static version of the library, how would I configure the 
binding.gyp to take advantage of it?

On Thursday, March 29, 2012 1:48:55 PM UTC-4, Nathan Rajlich wrote:
>
> All my experience has been with static compiled modules. That's what I'm 
> doing with node-ffi. If libfreeling offers precompiled static versions of 
> the library for you to use, I would suggest going that route. Another such 
> option is bundling libfreeling in your repo and compiling it during your 
> module's build (by converting it to gyp; this is sometimes easy, sometimes 
> hard/impossible).
>
> On Thu, Mar 29, 2012 at 9:15 AM, rhasson <> wrote:
>
>> yes I did.  I placed in the same directory as my library .cc files, I 
>> placed it in the freeling.node directory.
>>
>> I'm suspicious to how I'm setting up my binding.gyp file.  I can't figure 
>> out how to tell in my binding.gyp file that I need my library to link with 
>> an external .so file.  Can you provide a sample .gyp file that show that?
>>
>> This is what I have but it still doesn't like 
>> libfreeling-3.0-alfa1.soproperly.
>>
>> {
>>'targets': [
>> {
>>   'target_name': 'freeling',
>>   'type': 'loadable_module',
>>   'product_extension': 'node',
>>   'product_prefix': '',
>>   'include_dirs': ['/home/roy/freeling/free3/include'],
>>   'link_settings': {
>>   'libraries': ['libfreeling-3.0-alfa1.so'],
>>   'library_dirs': ['/home/roy/freeling/free3/lib'],
>>},
>>   'sources': ['freeling.cc', 'freeling_tokenizer.cc'],
>> },
>>   ],
>> }
>>
>>
>> On Thursday, March 29, 2012 11:43:24 AM UTC-4, Nathan Rajlich wrote:
>>>
>>>
>>> libfreeling-3.0-alfa1.so => not found
>>>>
>>>
>>> So that needs to be fixed :p
>>>
>>> Did you try placing libfreeling-3.0-alfa1.so in the same directory as 
>>> freeling.node?
>>>  
>>  -- 
>> 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 nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Unable to load shared library

2012-03-30 Thread rhasson
Nathan, 

Thanks for the help.  I was finally able to link my static library with my 
module but now I'm again getting an undefined symbol error but this time on 
my own module's methods.
I can't seem to get away from this problem.

[root@localdev Release]# ldd freeling.node 
linux-gate.so.1 =>  (0x00a4e000)
libfreeling-3.0-alfa1.so => 
/home/roy/freeling/free3/lib/libfreeling-3.0-alfa1.so (0x00b6b000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00542000)
libm.so.6 => /lib/libm.so.6 (0x0011)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x0092b000)
libpthread.so.0 => /lib/libpthread.so.0 (0x0013a000)
libc.so.6 => /lib/libc.so.6 (0x0023b000)
libboost_regex.so.1.44.0 => /usr/lib/libboost_regex.so.1.44.0 (0x0042d000)
libboost_filesystem.so.1.44.0 => /usr/lib/libboost_filesystem.so.1.44.0 
(0x00155000)
/lib/ld-linux.so.2 (0x0021c000)
libicuuc.so.44 => /usr/lib/libicuuc.so.44 (0x00631000)
libicui18n.so.44 => /usr/lib/libicui18n.so.44 (0xb7533000)
libboost_system.so.1.44.0 => /usr/lib/libboost_system.so.1.44.0 (0x00ab)
libicudata.so.44 => /usr/lib/libicudata.so.44 (0xb66f5000)
libdl.so.2 => /lib/libdl.so.2 (0x00207000)
[root@localdev Release]# node
> require('./freeling')
Error: /home/roy/freeling/node_bind/build/Release/freeling.node: undefined 
symbol: _ZN17FreeLingTokenizer2tkE
at Object..node (module.js:476:11)
at Module.load (module.js:352:32)
at Function._load (module.js:310:12)
at Module.require (module.js:358:17)
at require (module.js:374:17)
at repl:1:2
at REPLServer.eval (repl.js:85:21)
at Interface. (repl.js:202:12)
at Interface.emit (events.js:67:17)
at Interface._onLine (readline.js:169:10)
> 

FreeLingTokenizer is my class, but I'm not sure why now it can't find its 
symbols.

Here is my binding.gyp file:

{
  'targets': [
{
  'target_name': 'freeling',
  'type': 'loadable_module',
  'product_extension': 'node',
  'product_prefix': '',
  'include_dirs': ['.','/home/roy/freeling/free3/include'],
  'conditions': [
 ['OS=="linux"', {
'libraries': ['/home/roy/freeling/free3/lib/libfreeling.so'],
 }],
   ],
  'sources': ['freeling.cc', 'freeling_tokenizer.cc', 'freeling.h', 
'freeling_tokenizer.h'],
},
  ],
}


On Thursday, March 29, 2012 2:55:43 PM UTC-4, Nathan Rajlich wrote:
>
> Here's how node-ffi is doing it: 
> https://github.com/rbranson/node-ffi/blob/master/binding.gyp#L25-27
>
> On Thu, Mar 29, 2012 at 10:54 AM, rhasson <> wrote:
>
>> If I was to get a static version of the library, how would I configure 
>> the binding.gyp to take advantage of it?
>>
>>
>> On Thursday, March 29, 2012 1:48:55 PM UTC-4, Nathan Rajlich wrote:
>>
>>> All my experience has been with static compiled modules. That's what I'm 
>>> doing with node-ffi. If libfreeling offers precompiled static versions of 
>>> the library for you to use, I would suggest going that route. Another such 
>>> option is bundling libfreeling in your repo and compiling it during your 
>>> module's build (by converting it to gyp; this is sometimes easy, sometimes 
>>> hard/impossible).
>>>
>>> On Thu, Mar 29, 2012 at 9:15 AM, rhasson <> wrote:
>>>
>>>> yes I did.  I placed in the same directory as my library .cc files, I 
>>>> placed it in the freeling.node directory.
>>>>
>>>> I'm suspicious to how I'm setting up my binding.gyp file.  I can't 
>>>> figure out how to tell in my binding.gyp file that I need my library to 
>>>> link with an external .so file.  Can you provide a sample .gyp file that 
>>>> show that?
>>>>
>>>> This is what I have but it still doesn't like 
>>>> libfreeling-3.0-alfa1.soproperly.
>>>>
>>>> {
>>>>'targets': [
>>>> {
>>>>   'target_name': 'freeling',
>>>>   'type': 'loadable_module',
>>>>   'product_extension': 'node',
>>>>   'product_prefix': '',
>>>>   'include_dirs': ['/home/roy/freeling/free3/**include'],
>>>>   'link_settings': {
>>>>   'libraries': ['libfreeling-3.0-alfa1.so'],
>>>>   'library_dirs': ['/home/roy/freeling/free3/**lib'],
>>>>},
&

Re: [nodejs] Re: Unable to load shared library

2012-03-30 Thread rhasson
So I commented out everything and slowly uncommented things until I got the 
error.  I found out that when I try to save something to my object I get 
the undefined symbol error.  Here is my code, see the note marked with 
*:

v8::Handle FreeLingTokenizer::New(const v8::Arguments& args) {
v8::HandleScope scope;

v8::Handle dir = args[0]->IsUndefined() ? 
v8::String::New("/usr/local/share/FreeLing/en/") : args[0]->ToString();

FreeLingTokenizer* obj = new FreeLingTokenizer();
 v8::Handle file = v8::String::New("tokenizer.dat");
obj->path = v8::String::Concat(dir, file); * When I leave this in, i 
get the error.  when I comment this line out, it works **

obj->Wrap(args.This());

return args.This();
}

As a side note, in order to build my project and link to the shared 
library, I had to set the LD_LIBRARY_PATH environment variable to the 
directory where the shared library I was linking to resides, then it works.

Roy

On Friday, March 30, 2012 5:35:29 PM UTC-4, Nathan Rajlich wrote:
>
> Perhaps use a fully qualified reference to your class 
> (FreeLingTokenizer::FreeLingTokenizer) 
> ? I'm not really sure without seeing your code.
>
> On Fri, Mar 30, 2012 at 2:31 PM, rhasson <> wrote:
>
>> Nathan, 
>>
>> Thanks for the help.  I was finally able to link my static library with 
>> my module but now I'm again getting an undefined symbol error but this time 
>> on my own module's methods.
>> I can't seem to get away from this problem.
>>
>> [root@localdev Release]# ldd freeling.node 
>> linux-gate.so.1 =>  (0x00a4e000)
>>  libfreeling-3.0-alfa1.so => /home/roy/freeling/free3/lib/
>> libfreeling-3.0-alfa1.so (0x00b6b000)
>>  libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00542000)
>> libm.so.6 => /lib/libm.so.6 (0x0011)
>> libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x0092b000)
>>  libpthread.so.0 => /lib/libpthread.so.0 (0x0013a000)
>> libc.so.6 => /lib/libc.so.6 (0x0023b000)
>> libboost_regex.so.1.44.0 => /usr/lib/libboost_regex.so.1.44.0 (0x0042d000)
>>  libboost_filesystem.so.1.44.0 => /usr/lib/libboost_filesystem.so.1.44.0 
>> (0x00155000)
>> /lib/ld-linux.so.2 (0x0021c000)
>>  libicuuc.so.44 => /usr/lib/libicuuc.so.44 (0x00631000)
>> libicui18n.so.44 => /usr/lib/libicui18n.so.44 (0xb7533000)
>>  libboost_system.so.1.44.0 => /usr/lib/libboost_system.so.1.44.0 
>> (0x00ab)
>> libicudata.so.44 => /usr/lib/libicudata.so.44 (0xb66f5000)
>>  libdl.so.2 => /lib/libdl.so.2 (0x00207000)
>> [root@localdev Release]# node
>> > require('./freeling')
>> Error: /home/roy/freeling/node_bind/build/Release/freeling.node: 
>> undefined symbol: _ZN17FreeLingTokenizer2tkE
>> at Object..node (module.js:476:11)
>> at Module.load (module.js:352:32)
>> at Function._load (module.js:310:12)
>> at Module.require (module.js:358:17)
>> at require (module.js:374:17)
>> at repl:1:2
>> at REPLServer.eval (repl.js:85:21)
>> at Interface. (repl.js:202:12)
>> at Interface.emit (events.js:67:17)
>> at Interface._onLine (readline.js:169:10)
>> > 
>>
>> FreeLingTokenizer is my class, but I'm not sure why now it can't find its 
>> symbols.
>>
>> Here is my binding.gyp file:
>>
>> {
>>   'targets': [
>> {
>>   'target_name': 'freeling',
>>   'type': 'loadable_module',
>>   'product_extension': 'node',
>>   'product_prefix': '',
>>   'include_dirs': ['.','/home/roy/freeling/free3/include'],
>>   'conditions': [
>>  ['OS=="linux"', {
>> 'libraries': ['/home/roy/freeling/free3/lib/libfreeling.so'],
>>  }],
>>],
>>   'sources': ['freeling.cc', 'freeling_tokenizer.cc', 'freeling.h', 
>> 'freeling_tokenizer.h'],
>> },
>>   ],
>> }
>>
>>
>> On Thursday, March 29, 2012 2:55:43 PM UTC-4, Nathan Rajlich wrote:
>>
>>> Here's how node-ffi is doing it: https://github.com/**
>>> rbranson/node-ffi/blob/master/**binding.gyp#L25-27<https://github.com/rbranson/node-ffi/blob/master/binding.gyp#L25-27>
>>>
>>> On Thu, Mar 29, 2012 at 10:54 AM, rhasson <> wrote:
>>>
>>>> If I was to get a static version of the library, how would I configure 
>>>> the binding.gyp to take advantage of it?
>&g

[nodejs] is my object being garbage collected within a native plugin

2012-04-07 Thread rhasson
I'm creating a binding to a C++ library for NLP.  You can see the basic of 
it here:   https://gist.github.com/2331101#

My problem right now is, in Node when the user instantiates my object with 
the "new" command, in C++ land I instantiate my module's object and then 
instantiate the Freeling NLP library object so I can call its methods.
I try to save that Freeling object inside my module object so I can use it 
later on within other methods such as tokenize (in this example). I use 
node::Wrap and node::UnWrap but it seems like either the Freeling object is 
wrapped properly, garbage collected or I'm left with a dangling pointer to 
nothing.

As a side note, I had a std::string private member on my object just to 
store some text that I receive as one of my arguments to the "new" command. 
 That was also not saved by the wrap/unwrap methods.  I had to make this 
variable a v8::Persistent in order for it to be properly 
wrapped.

if I can create the Freeling object and call the tokenize method all in one 
place then it works.  If I create the Freeling object in my "new" class 
method and call the tokenize method in my "tokenize" class method it 
doesn't work.  My library just hangs.

I'm running node v.0.7.6 on a Fedora 14 Linux (in a VM on top of Windows)

Any help would be greatly appreciated.

Thanks,
Roy

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: is my object being garbage collected within a native plugin

2012-04-07 Thread rhasson
I forgot to add, in the gist, I tried to store the Freeling object in a 
vector that is a class member of my module but that still didn't work.

Roy

On Saturday, April 7, 2012 2:30:16 PM UTC-4, rhasson wrote:
>
> I'm creating a binding to a C++ library for NLP.  You can see the basic of 
> it here:   https://gist.github.com/2331101#
>
> My problem right now is, in Node when the user instantiates my object with 
> the "new" command, in C++ land I instantiate my module's object and then 
> instantiate the Freeling NLP library object so I can call its methods.
> I try to save that Freeling object inside my module object so I can use it 
> later on within other methods such as tokenize (in this example). I use 
> node::Wrap and node::UnWrap but it seems like either the Freeling object is 
> wrapped properly, garbage collected or I'm left with a dangling pointer to 
> nothing.
>
> As a side note, I had a std::string private member on my object just to 
> store some text that I receive as one of my arguments to the "new" command. 
>  That was also not saved by the wrap/unwrap methods.  I had to make this 
> variable a v8::Persistent in order for it to be properly 
> wrapped.
>
> if I can create the Freeling object and call the tokenize method all in 
> one place then it works.  If I create the Freeling object in my "new" class 
> method and call the tokenize method in my "tokenize" class method it 
> doesn't work.  My library just hangs.
>
> I'm running node v.0.7.6 on a Fedora 14 Linux (in a VM on top of Windows)
>
> Any help would be greatly appreciated.
>
> Thanks,
> Roy
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] is my object being garbage collected within a native plugin

2012-04-07 Thread rhasson
I'll give that a try.

Roy

On Saturday, April 7, 2012 5:21:21 PM UTC-4, Ben Noordhuis wrote:
>
> On Sat, Apr 7, 2012 at 20:30, rhasson <> wrote:
> > I'm creating a binding to a C++ library for NLP.  You can see the basic 
> of
> > it here:   https://gist.github.com/2331101#
> >
> > My problem right now is, in Node when the user instantiates my object 
> with
> > the "new" command, in C++ land I instantiate my module's object and then
> > instantiate the Freeling NLP library object so I can call its methods.
> > I try to save that Freeling object inside my module object so I can use 
> it
> > later on within other methods such as tokenize (in this example). I use
> > node::Wrap and node::UnWrap but it seems like either the Freeling object 
> is
> > wrapped properly, garbage collected or I'm left with a dangling pointer 
> to
> > nothing.
> >
> > As a side note, I had a std::string private member on my object just to
> > store some text that I receive as one of my arguments to the "new" 
> command.
> >  That was also not saved by the wrap/unwrap methods.  I had to make this
> > variable a v8::Persistent in order for it to be properly
> > wrapped.
> >
> > if I can create the Freeling object and call the tokenize method all in 
> one
> > place then it works.  If I create the Freeling object in my "new" class
> > method and call the tokenize method in my "tokenize" class method it 
> doesn't
> > work.  My library just hangs.
> >
> > I'm running node v.0.7.6 on a Fedora 14 Linux (in a VM on top of Windows)
> >
> > Any help would be greatly appreciated.
>
> There's nothing in your gist that springs out as being obviously
> wrong. I don't have freeling installed so I can't test it but run it
> in a debugger and put a breakpoint on the destructor, that will tell
> you if the destructor runs before Tokenize().
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: is my object being garbage collected within a native plugin

2012-04-08 Thread rhasson
After doing some debugging I found out that the failure is with iswspace() 
in libc.  tracking it back to freeling, I figured out that I need to set 
the locale prior to instantiating the tokenizer class otherwise the 
string/wstring conversations get screwed up and the subsequent operations 
fail.

Roy

On Saturday, April 7, 2012 2:30:16 PM UTC-4, rhasson wrote:
>
> I'm creating a binding to a C++ library for NLP.  You can see the basic of 
> it here:   https://gist.github.com/2331101#
>
> My problem right now is, in Node when the user instantiates my object with 
> the "new" command, in C++ land I instantiate my module's object and then 
> instantiate the Freeling NLP library object so I can call its methods.
> I try to save that Freeling object inside my module object so I can use it 
> later on within other methods such as tokenize (in this example). I use 
> node::Wrap and node::UnWrap but it seems like either the Freeling object is 
> wrapped properly, garbage collected or I'm left with a dangling pointer to 
> nothing.
>
> As a side note, I had a std::string private member on my object just to 
> store some text that I receive as one of my arguments to the "new" command. 
>  That was also not saved by the wrap/unwrap methods.  I had to make this 
> variable a v8::Persistent in order for it to be properly 
> wrapped.
>
> if I can create the Freeling object and call the tokenize method all in 
> one place then it works.  If I create the Freeling object in my "new" class 
> method and call the tokenize method in my "tokenize" class method it 
> doesn't work.  My library just hangs.
>
> I'm running node v.0.7.6 on a Fedora 14 Linux (in a VM on top of Windows)
>
> Any help would be greatly appreciated.
>
> Thanks,
> Roy
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Meteor,what you think

2012-04-11 Thread rhasson
Overall very interesting and looks promising.  Like many on here already 
stated, how they address security will be interesting.  Talking directly to 
the DB (as shown in the screencast) opens the door to a lot of concern. In 
a client->server->db model at least you have the server abstracting access 
to the db.  yes it can also be hacked but at least you made it a little bit 
more difficult and can easily apply access rules rather than try to do it 
directly on the db side.

My main concern is that this makes it very easy for people with little 
understanding of the underlying systems to build somewhat comprehensive 
applications.  It's too easy to make mistakes and assumptions that will 
bite them and their users later on.  If someone sees that screencast, copy 
a simple example and build a small eCommerce site.  They could potentially 
put their users and personal data in serious risk.

It's not to say that the Meteor guys can't fix this, it just means they 
need to pay very close attention to it early on rather than wait or it will 
be a big problem and jeopardize the project.

Besides these concerns, I love what they did.  The hot code push is awesome 
and simple, the API is simple and easy to use.  Really did a good job. 
 Just please pay attention to security.

Roy

On Wednesday, April 11, 2012 3:16:28 AM UTC-4, Nikolay Yasinskiy wrote:
>
> meteor.com/screencast 
> meteor.com/examples

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] handling streams in native c++ addons

2012-04-15 Thread rhasson
I'm working on a C++ NLP binding and wanted to implemented a streaming 
interface so that text could be added to a stream in JS, my native binding 
will receive it, extract the text process it and emit a "data"events with 
the responses.

How would I go about reading a stream that was either passed in as an 
argument or was piped in via "pipe"?  I'm assuming I'll have to implement 
the pipe interface as well which I'm not sure how to do yet

Thanks,
Roy

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: handling streams in native c++ addons

2012-04-16 Thread rhasson
Isaac and Nathan, 

Thanks for the feedback, I'll follow your guidance by keeping the binding a 
simple 1-1 mapping and doing the streaming interface in JS.

Roy

On Sunday, April 15, 2012 11:39:16 PM UTC-4, rhasson wrote:
>
> I'm working on a C++ NLP binding and wanted to implemented a streaming 
> interface so that text could be added to a stream in JS, my native binding 
> will receive it, extract the text process it and emit a "data"events with 
> the responses.
>
> How would I go about reading a stream that was either passed in as an 
> argument or was piped in via "pipe"?  I'm assuming I'll have to implement 
> the pipe interface as well which I'm not sure how to do yet
>
> Thanks,
> Roy
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Examples of C++ modules, for Node.js

2012-04-22 Thread rhasson
Just to add to Nathan's comments, you're missing a "libraries" that points 
to the the HDF5 shared library that was compiled separately.  for example: 
 'libraries': ['/home/user/hdf5/lib/hdf5.so']

Also, I noticed that when compiling with node-gyp (which I love btw) you 
need to set LD_LIBRARY_PATH environment variable to the directory where the 
HDF5 shared library is located.  for example:   
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/hdf5/lib

after you do that, try building your project again.

Roy

On Saturday, April 21, 2012 9:50:49 PM UTC-4, Ryan Cole wrote:
>
> Hello,
>
> I'm learning how to write C++ modules, for Node.js. I'm sort of 
> brute-forcing my learning by looking at examples, referencing the 
> documentation for v8 and trial and error. The only two modules that I can 
> seem to think of, as a reference, are hiredis-node and node.bcrypt.js. Both 
> have helped me get to where I am now, which is able to compile a base 
> skeleton module, using node-gyp. Are there any other modules that are 
> written in C++ that would be simple + good to reference?
>
> For example, I'm currently trying to write a module that simply wraps and 
> exposes a class from an existing third-party lib, HDF5. I've got it all 
> written to the point where I think I am supposed to initialize an object of 
> that class I want to expose, but when I include the code to initialize it, 
> I cannot `require` it from within Node. It will compile, but I cannot 
> require it. I do not think it is actually compiling properly. The HDF5 lib 
> comes with a special wrapper binary around g++ that sets up the compile 
> environment for you, so I guess I need to figure out how to tell node-gyp 
> to use that.
>
> My code is here, if anyone wants to take a peek: 
> https://github.com/ryancole/node-hdf5
>
> Thanks
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Examples of C++ modules, for Node.js

2012-04-23 Thread rhasson
I found out that I needed to set up my LD_LIBRARY_PATH env variable 
otherwise it will not find the path to the shared library.  set it up like 
this:  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/hdf5/lib

Then rebuild the project.  Once rebuilt type: ldd build/Release/hdf5.node 
(or whatever your module name is) and see if your HDF5 shared library you 
trying to link to is listed. If not than it didn't link correctly.

Roy

On Monday, April 23, 2012 12:57:44 AM UTC-4, Ryan Cole wrote:
>
> I have adjusted the binding.gyp file to include the linker settings 
> required for including the HDF5 libs I need. I believe that the current gyp 
> file mirrors a Makefile that I am able to get working, for HDF5's stand 
> alone compile. The only difference is that you're supposed to run the HDF5 
> Makefile with this custom binary, h5c++, that I think does some additional 
> build configurations for you.
>
> I only see two options here, I think. One option would be to compile this 
> node lib using that h5c++ binary. The other option would be to figure out 
> what that h5c++ binary does, and reproduce it within the binding.gyp file.
>
> Currently, using this binding.gyp file, my node lib will compile and I 
> assume it also links with hdf5 lib now. (
> https://github.com/ryancole/node-hdf5/blob/master/binding.gyp) I have 
> updated to a node version 0.7+, and can see the error message when I try to 
> require my node lib, now. It looks like this:
>
> ryan@ryan-server:~/repos/node-hdf5$ node
>>
>> > require('./build/Release/hdf5')
>>
>> Error: libhdf5.so.7: cannot open shared object file: No such file or 
>>> directory
>>
>> at Object..node (module.js:475:11)
>>
>> at Module.load (module.js:351:32)
>>
>> at Function._load (module.js:309:12)
>>
>> at Module.require (module.js:357:17)
>>
>> at require (module.js:373:17)
>>
>> at repl:1:2
>>
>> at REPLServer.eval (repl.js:110:21)
>>
>> at Interface. (repl.js:249:12)
>>
>> at Interface.emit (events.js:87:17)
>>
>> at Interface._onLine (readline.js:178:10)
>>
>>
> That's with my .gyp file as-is. When I try to run this command, "node-gyp 
> build CXX=/path/to/h5c++", I get an error saying that I need to try again 
> using the -fPIC parameter. No matter where I specify that parameter, it 
> just seems to tell me to try again using -fPIC. I think I may be heading 
> down the wrong path with that -fPIC, though.
>
> Anyway, just wanted to document my leaving-off-spot so that I can pick up 
> with it tomorrow. Also, so that if anybody has any suggestions they could 
> share them too! :)
>
> Thanks all,
> Ryan
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[nodejs] Re: Examples of C++ modules, for Node.js

2012-04-23 Thread rhasson
I'm using node-gyp and ldflags didn't work for me either.  Maybe Nathan has 
an idea, but I found out that I needed to set the LD_LIBRARY_PATH otherwise 
my shared library wouldn't link.

On Monday, April 23, 2012 11:21:06 AM UTC-4, Ryan Cole wrote:
>
> Roy,
>
> I notice you mentioned this early in the email chain. I should have tried 
> it earlier. It fixes the issue. I wonder why the ldflags in binding.gyp 
> does not properly set this up, in my case? Or, is LD_LIBRARY_PATH just 
> another required step no matter what? Also, I did not know about the ldd 
> command - very handy!
>
> Thanks,
> Ryan
>
> On Monday, April 23, 2012 3:29:38 AM UTC-5, rhasson wrote:
>>
>> I found out that I needed to set up my LD_LIBRARY_PATH env variable 
>> otherwise it will not find the path to the shared library.  set it up like 
>> this:  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/hdf5/lib
>>
>> Then rebuild the project.  Once rebuilt type: ldd build/Release/hdf5.node 
>> (or whatever your module name is) and see if your HDF5 shared library you 
>> trying to link to is listed. If not than it didn't link correctly.
>>
>> Roy
>>
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Examples of C++ modules, for Node.js

2012-04-23 Thread rhasson
ok that makes sense.  So the question is, once gyp compiled and the linker 
linked the shared library into the .node module using ldflags.  How do you 
require the module without needing to set the LD_LIBRARY_PATH ?

Now if I set the LD_LIBRARY_PATH I can require the module and it works. 
 But if I don't set it, require fails saying it can't find the shared 
library.

Roy

On Monday, April 23, 2012 11:03:15 PM UTC-4, Ben Noordhuis wrote:
>
> On Tue, Apr 24, 2012 at 04:46, rhasson <> wrote:
> > I'm using node-gyp and ldflags didn't work for me either.  Maybe Nathan 
> has
> > an idea, but I found out that I needed to set the LD_LIBRARY_PATH 
> otherwise
> > my shared library wouldn't link.
>
> The ldflags setting is what is passed to the linker at the time of
> compilation. LD_LIBRARY_PATH affects the search path of the dynamic
> linker, which is what is run when a program starts up.
>
> What I mean to say is that a linker is not the same thing as a dynamic
> linker (though they're related) and that gyp is only involved in the
> compilation phase.
>
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Examples of C++ modules, for Node.js

2012-04-23 Thread rhasson
Ben, 

When I get rid of LD_LIBRARY_PATH and include the ldflags and libraries 
lines in by binding.gyp file the shared library is not linked as shown by 
ldd.  If I set the LD_LIBRARY_PATH then it links it correctly.

Is ldflags not parsed correctly? 

Here is my gyp file:

{
  'targets': [
{
  'target_name': 'freeling',
  'type': 'loadable_module',
  'product_extension': 'node',
  'product_prefix': '',
  'include_dirs': ['.','/home/roy/freeling/free3/include', 
'/home/roy/cvv8/include/cvv8'],
  'conditions': [
 ['OS=="linux"', {
  'link_settings': {
'ldflags': ['-L/home/roy/freeling/free3/lib/'],
'libraries': ['/home/roy/freeling/free3/lib/libfreeling.so']
},
 }],
   ],
  'sources': ['freeling.cc', 'freeling_tokenizer.cc', 
'freeling_splitter.cc', 'helper.cc'],
},
  ],
}



On Monday, April 23, 2012 11:03:15 PM UTC-4, Ben Noordhuis wrote:
>
> On Tue, Apr 24, 2012 at 04:46, rhasson <> wrote:
> > I'm using node-gyp and ldflags didn't work for me either.  Maybe Nathan 
> has
> > an idea, but I found out that I needed to set the LD_LIBRARY_PATH 
> otherwise
> > my shared library wouldn't link.
>
> The ldflags setting is what is passed to the linker at the time of
> compilation. LD_LIBRARY_PATH affects the search path of the dynamic
> linker, which is what is run when a program starts up.
>
> What I mean to say is that a linker is not the same thing as a dynamic
> linker (though they're related) and that gyp is only involved in the
> compilation phase.
>
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Examples of C++ modules, for Node.js

2012-04-23 Thread rhasson
I found out that for Solaris ELF executables you can pass a 
"-R/path/to/lib" argument which will record the path and library name into 
the executable which will allow it to find it at runtime without needing to 
update the LD_LIBRARY_PATH.  Is there an equivalent argument for Linux?

On Monday, April 23, 2012 11:48:33 PM UTC-4, Ben Noordhuis wrote:
>
> On Tue, Apr 24, 2012 at 05:45, rhasson <> wrote: 
> > Ben, 
> > 
> > When I get rid of LD_LIBRARY_PATH and include the ldflags and libraries 
> > lines in by binding.gyp file the shared library is not linked as shown 
> by 
> > ldd.  If I set the LD_LIBRARY_PATH then it links it correctly. 
> > 
> > Is ldflags not parsed correctly? 
> > 
> > Here is my gyp file: 
> > 
> > { 
> >   'targets': [ 
> > { 
> >   'target_name': 'freeling', 
> >   'type': 'loadable_module', 
> >   'product_extension': 'node', 
> >   'product_prefix': '', 
> >   'include_dirs': ['.','/home/roy/freeling/free3/include', 
> > '/home/roy/cvv8/include/cvv8'], 
> >   'conditions': [ 
> >  ['OS=="linux"', { 
> >   'link_settings': { 
> > 'ldflags': ['-L/home/roy/freeling/free3/lib/'], 
> > 'libraries': ['/home/roy/freeling/free3/lib/libfreeling.so'] 
> > }, 
> >  }], 
> >], 
> >   'sources': ['freeling.cc', 'freeling_tokenizer.cc', 
> > 'freeling_splitter.cc', 'helper.cc'], 
> > }, 
> >   ], 
> > } 
> > 
>
> You should set it like this: 
>
>   'link_settings': { 
> 'ldflags': ['-L/home/roy/freeling/free3/lib/', '-lfreeling'], 
>   }, 
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Re: [nodejs] Re: Examples of C++ modules, for Node.js

2012-04-23 Thread rhasson
I found out that for Solaris ELF executables you can pass a 
"-R/path/to/lib" argument which will record the path and library name into 
the executable which will allow it to find it at runtime without needing to 
update the LD_LIBRARY_PATH.  Is there an equivalent argument for Linux?

On Monday, April 23, 2012 11:48:33 PM UTC-4, Ben Noordhuis wrote:
>
> On Tue, Apr 24, 2012 at 05:45, rhasson <> wrote: 
> > Ben, 
> > 
> > When I get rid of LD_LIBRARY_PATH and include the ldflags and libraries 
> > lines in by binding.gyp file the shared library is not linked as shown 
> by 
> > ldd.  If I set the LD_LIBRARY_PATH then it links it correctly. 
> > 
> > Is ldflags not parsed correctly? 
> > 
> > Here is my gyp file: 
> > 
> > { 
> >   'targets': [ 
> > { 
> >   'target_name': 'freeling', 
> >   'type': 'loadable_module', 
> >   'product_extension': 'node', 
> >   'product_prefix': '', 
> >   'include_dirs': ['.','/home/roy/freeling/free3/include', 
> > '/home/roy/cvv8/include/cvv8'], 
> >   'conditions': [ 
> >  ['OS=="linux"', { 
> >   'link_settings': { 
> > 'ldflags': ['-L/home/roy/freeling/free3/lib/'], 
> > 'libraries': ['/home/roy/freeling/free3/lib/libfreeling.so'] 
> > }, 
> >  }], 
> >], 
> >   'sources': ['freeling.cc', 'freeling_tokenizer.cc', 
> > 'freeling_splitter.cc', 'helper.cc'], 
> > }, 
> >   ], 
> > } 
> > 
>
> You should set it like this: 
>
>   'link_settings': { 
> 'ldflags': ['-L/home/roy/freeling/free3/lib/', '-lfreeling'], 
>   }, 
>

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en