-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
Hi all!
I'm playing around with this library trying to use it from a node addon but I couldn't do it. I don't have experience with C++ and I know that it sounds like weird. But I really want to make some experiments running this library from nodejs. To do it, I'm trying to implement an addon that brings some bindings between JavaScript and C++.
After introduce you, I would like to ask if it's possible to get some help from you. Right now, I'm being able to build my addon but when I run the code I get:
node: symbol lookup error:
async-addon/build/Release/async.node: undefined symbol: tld_domain_to_lowercase
This is the code where I'm trying to use it:
#include <napi.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include "include/libtld/include/libtld/tld.h"
using namespace std;
Napi::Boolean TestingTld(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
std::string arg = info[0].As<Napi::String>();
const char *uri = arg.c_str();
char *uri_lowercase = tld_domain_to_lowercase(uri);
struct tld_info tldinfo;
enum tld_result r;
r = tld(uri_lowercase, &tldinfo);
if(r == TLD_RESULT_SUCCESS) {
const char *s = uri_lowercase + tldinfo.f_offset - 1;
while(s > uri_lowercase)
{
if(*s == '.')
{
++s;
break;
}
--s;
}
printf("Sub-domain(s): \"%.*s\"\n", (int)(s - uri_lowercase), uri_lowercase);
printf("Domain: \"%.*s\"\n", (int)(tldinfo.f_tld - s), s);
printf("TLD: \"%s\"\n", tldinfo.f_tld);
}
return Napi::Boolean::New(env, true);
}
Napi::Object init(Napi::Env env, Napi::Object exports) {
exports.Set(Napi::String::New(env, "TestingTld"), Napi::Function::New(env, TestingTld));
return exports;
};
NODE_API_MODULE(async, init);
Thanks!