Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to link a plugin
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Moritz Willig  
View profile  
 More options Sep 27 2012, 4:58 pm
From: Moritz Willig <moritz.wil...@gmail.com>
Date: Thu, 27 Sep 2012 13:58:41 -0700 (PDT)
Local: Thurs, Sep 27 2012 4:58 pm
Subject: [Beginner question] How to link a plugin

Hello,
I'm new to C++ and of course to the V8 engine, too. I would like to create
an javascript service to send request to a server (something similar
accessing an SQL Server). My main application code is executing without
problems (i included V8 as a static library), but every time I try
accessing an plugin in an shared library, it produces many errors like "
symbol lookup error: ./libs/testplugin.so: undefined symbol:
_ZN2v816FunctionTemplate16InstanceTemplateEv". I have really no idea how to
solve this errors. I have already searched solutions for this, but no one
worked for me. I assume that my program isn't able to find the matching v8
symbols. I have already added -Wl,-export-dynamic to the linker options,
but it still is not loading the library at runtime.

I would be very grateful for any kind of advise or solution on this problem

Regards, Moritz


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[Beginner question] How to link a plugin" by Travis Sharp
Travis Sharp  
View profile  
 More options Sep 27 2012, 5:21 pm
From: Travis Sharp <isrne...@gmail.com>
Date: Thu, 27 Sep 2012 14:21:15 -0700
Local: Thurs, Sep 27 2012 5:21 pm
Subject: Re: [v8-users] [Beginner question] How to link a plugin
http://nodejs.org/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Moritz Willig  
View profile  
 More options Sep 28 2012, 1:07 am
From: Moritz Willig <moritz.wil...@gmail.com>
Date: Thu, 27 Sep 2012 22:07:18 -0700 (PDT)
Local: Fri, Sep 28 2012 1:07 am
Subject: Re: [v8-users] [Beginner question] How to link a plugin

Hi CodeJunkie,
i know NodeJS and have already build some Projects with it. But I want to
learn how to solve this problem this in general. As far as i see does
NodeJS also provide Plugins but they have to be linked statically into the
program (or have to be written in JS itself).
Maybe I switch to NodeJS later but at the moment i would like to learn how
to do this on my own.

Am Donnerstag, 27. September 2012 23:21:18 UTC+2 schrieb CodeJunkie:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephan Beal  
View profile  
 More options Sep 28 2012, 4:56 am
From: Stephan Beal <sgb...@googlemail.com>
Date: Fri, 28 Sep 2012 10:56:32 +0200
Local: Fri, Sep 28 2012 4:56 am
Subject: Re: [v8-users] [Beginner question] How to link a plugin

On Fri, Sep 28, 2012 at 7:07 AM, Moritz Willig <moritz.wil...@gmail.com>wrote:

> i know NodeJS and have already build some Projects with it. But I want to
> learn how to solve this problem this in general. As far as i see does
> NodeJS also provide Plugins but they have to be linked statically into the
> program (or have to be written in JS itself).

FWIW: there is no "in general" solution to this problem from a v8
perspective because v8 does not define any sort of native-side plugin
interface and the behaviour of DLLs is unspecified by the C++ standard.

--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Schwartz  
View profile  
 More options Sep 28 2012, 8:36 am
From: Michael Schwartz <myk...@gmail.com>
Date: Fri, 28 Sep 2012 05:36:37 -0700
Local: Fri, Sep 28 2012 8:36 am
Subject: Re: [v8-users] [Beginner question] How to link a plugin

Both SilkJS and v8cgi support loading of dynamic libraries.  It is tricky to get working.

To the best of my knowledge:

The problem is you have v8 as a static library.  It needs to be a shared one and the shared library (testplugin) needs to be linked against libv8.so and every other library it calls.

See this for an example build script:
https://github.com/mschwartz/SilkJS-redis/blob/master/build.js

On Sep 27, 2012, at 10:07 PM, Moritz Willig <moritz.wil...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephan Beal  
View profile  
 More options Sep 28 2012, 9:21 am
From: Stephan Beal <sgb...@googlemail.com>
Date: Fri, 28 Sep 2012 15:21:31 +0200
Local: Fri, Sep 28 2012 9:21 am
Subject: Re: [v8-users] [Beginner question] How to link a plugin

On Fri, Sep 28, 2012 at 2:36 PM, Michael Schwartz <myk...@gmail.com> wrote:
> The problem is you have v8 as a static library.  It needs to be a shared
> one and the shared library (testplugin) needs to be linked against libv8.so
> and every other library it calls.

> See this for an example build script:
> https://github.com/mschwartz/SilkJS-redis/blob/master/build.js

And here's an article which covers some of the details in a
project-agnostic manner:

http://wanderinghorse.net/computing/papers/#classloading_cpp

--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Schwartz  
View profile  
 More options Sep 28 2012, 9:39 am
From: Michael Schwartz <myk...@gmail.com>
Date: Fri, 28 Sep 2012 06:39:14 -0700
Local: Fri, Sep 28 2012 9:39 am
Subject: Re: [v8-users] [Beginner question] How to link a plugin

I didn't see anything useful at the link.

The issue is you have a .so that's getting loaded via dlopen().  That .so needs to call functions in the v8 library that is statically linked into the main program.

Static linking does not, at all, guarantee all of the functions of the static library are present in the main program binary to be called by some undeterminable .so loaded via dlopen().

It's even problematic for the main program to provide a function, foo(), and call that from a .so.

I mentioned v8cgi because I know Ondras fairly well and he ran into these same issues and had to ask on mailing lists for help with the solution.  It should be easy, but it isn't.

On Sep 28, 2012, at 6:21 AM, Stephan Beal <sgb...@googlemail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephan Beal  
View profile  
 More options Sep 28 2012, 9:44 am
From: Stephan Beal <sgb...@googlemail.com>
Date: Fri, 28 Sep 2012 15:44:44 +0200
Local: Fri, Sep 28 2012 9:44 am
Subject: Re: [v8-users] [Beginner question] How to link a plugin

On Fri, Sep 28, 2012 at 3:39 PM, Michael Schwartz <myk...@gmail.com> wrote:
> I didn't see anything useful at the link.

It explains, for example, why static libs are sometimes problematic in
conjunction with C++ templates and plugins (because unreferenced symbols do
not get linked in to the client).

> The issue is you have a .so that's getting loaded via dlopen().  That .so
> needs to call functions in the v8 library that is statically linked into
> the main program.

For example. And if those do not get referenced from client code then they
don't (or might not) get linked in.

--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Schwartz  
View profile  
 More options Sep 28 2012, 10:00 am
From: Michael Schwartz <myk...@gmail.com>
Date: Fri, 28 Sep 2012 07:00:43 -0700
Local: Fri, Sep 28 2012 10:00 am
Subject: Re: [v8-users] [Beginner question] How to link a plugin

I meant no offense.  I just don't see any command line examples in it that would help with the problem at hand (his plugin not finding symbols in main with statically linked v8 library).

I also see no discussion of the loaded .so making calls to functions defined in the main program.

Peace

On Sep 28, 2012, at 6:44 AM, Stephan Beal <sgb...@googlemail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Moritz Willig  
View profile  
 More options Sep 28 2012, 3:49 pm
From: Moritz Willig <moritz.wil...@gmail.com>
Date: Fri, 28 Sep 2012 12:49:11 -0700 (PDT)
Local: Fri, Sep 28 2012 3:49 pm
Subject: Re: [v8-users] [Beginner question] How to link a plugin

Hi, i have read through the links and projects code you mentioned and also
tried to link v8 dynamically (which fails at the moment). I'm not 100%
percent sure but via "nm neptunjs | c++filt | grep v8::Throw" I looked up
the object definitions in my program and found "0805bb00 t
v8::ThrowException(v8::Handle<v8::Value>)" which is not found on dynamic
linking of the plugin. Is there any compiler/linker switch I overlooked to
make this definition public to the plugin or something else to get this
working? At the moment I'm trying to load my plugins with this code:

NativeClass* loadNMLib(string path) {
void* handle = dlopen(path.c_str(), RTLD_NOW|RTLD_GLOBAL); //It already
fails here because of "undefined symbols"
if (handle==NULL) { cout<<"Error: "<<dlerror()<<endl; return NULL; }

nld->create=(NativeClass* (*)())dlsym(handle, "createClassMapper");
...

}

Am Freitag, 28. September 2012 16:00:56 UTC+2 schrieb mschwartz:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zhao Cheng  
View profile  
 More options Sep 28 2012, 10:30 pm
From: Zhao Cheng <zcb...@gmail.com>
Date: Sat, 29 Sep 2012 10:30:54 +0800
Local: Fri, Sep 28 2012 10:30 pm
Subject: Re: [v8-users] [Beginner question] How to link a plugin

On Fri, Sep 28, 2012 at 4:58 AM, Moritz Willig <moritz.wil...@gmail.com> wrote:
> Hello,
> I'm new to C++ and of course to the V8 engine, too. I would like to create
> an javascript service to send request to a server (something similar
> accessing an SQL Server). My main application code is executing without
> problems (i included V8 as a static library), but every time I try accessing
> an plugin in an shared library, it produces many errors like " symbol lookup
> error: ./libs/testplugin.so: undefined symbol:
> _ZN2v816FunctionTemplate16InstanceTemplateEv". I have really no idea how to
> solve this errors. I have already searched solutions for this, but no one
> worked for me. I assume that my program isn't able to find the matching v8
> symbols. I have already added -Wl,-export-dynamic to the linker options, but
> it still is not loading the library at runtime.

Since you mentioned '-Wl,-export-dynamic', I assume you're compiling
under Linux environment with GCC.

Genrally, if you link with static V8, a '-rdynamic' in ldflags would
do the job, if you still get symbol lookup errors, find if you have
'-fvisibility=hidden' and '-fvisibility-inlines-hidden' in your
cflags, which will hide all symbols.

Another reason for this error is those symbols are garbage collected
by compiler, see if you have ''-fdata-sections' and in cflags, and
'-Wl,--gc-sections' in ldflags.

--
Cheng
Intel Open Source Technology Center


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Moritz Willig  
View profile  
 More options Sep 29 2012, 2:42 pm
From: Moritz Willig <moritz.wil...@gmail.com>
Date: Sat, 29 Sep 2012 11:42:24 -0700 (PDT)
Local: Sat, Sep 29 2012 2:42 pm
Subject: Re: [v8-users] [Beginner question] How to link a plugin

Hi, I have looked into the makefiles (I'm using Netbeans for C++ to manage
my project and create the makefiles) and searched for the flags you
mentioned. I found out that it uses -O2 to compile but as far as I see that
doesn't include on of this flags. Currently I compile and link with g++:
main:
compile: g++-4.6 -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/main.o
src/main.cpp
linking: g++-4.6 -o bin/neptunjs ${OBJECTFILES} -lpthread -ldl -rdynamic

shared library:
compile: g++-4.6: -O2 -fPIC  -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o
main.cpp
linking: g++-4.6 -shared -o libbasic.so -fPIC ${OBJECTFILES}
I copied this code directly from the makefiles (and replaced some
variables). I think if this isn't going to work I'm going back compiling
the plugins directly into the program.

Am Samstag, 29. September 2012 04:30:56 UTC+2 schrieb Zhao Cheng:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »