C++ XPCOM componenet - Linker Error

View: New views
4 Messages — Rating Filter:   Alert me  

C++ XPCOM componenet - Linker Error

by veer_in :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

hey guys,

I ma making an xpcom component to listen to event generated by Mozilla
browser. It compiles fien ..but gives linker error .

MyComponent.obj : error LNK2001: unresolved external symbol "public:
virtual unsigned int __stdcall WebLock::GetWeakReference(class
nsIWeakReference * *)" (?
GetWeakReference@WebLock@@UAGIPAPAVnsIWeakReference@@@Z)
1>.\Debug\MyComponent.dll : fatal error LNK1120: 1 unresolved
externals


I am also pasting peace of code related to this error ..Please help me
get out of this error.
I am linking against xpcomglue_s.lib ,xpcom.lib ,plc4.lib nspr4.lib
and plds4,lib.

MyComponent.h
class WebLock : public nsIWebProgressListener,
public nsISupportsWeakReference,
public nsIObserver,
public iWeblock
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DELC_NSIWEBPROGRESSLISTENER
NS_DECL_NSISUPPORTSWEAKREFERENCE
...............
...............
};



MyComponent.cpp

NS_IMPL_ISUPPORTS4(WebLock, nsIWebProgressListener,
nsISupportsWeakReference,
nsIObserver,
iWeblock)
............
.............

Thanks.

_______________________________________________
dev-tech-xpcom mailing list
dev-tech-xpcom@...
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Re: C++ XPCOM componenet - Linker Error

by Nickolay Ponomarev :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

So did you implement that method? You snipped the relevant code.

Nickolay

On 8/31/07, swatipatel.20@... <swatipatel.20@...> wrote:

> hey guys,
>
> I ma making an xpcom component to listen to event generated by Mozilla
> browser. It compiles fien ..but gives linker error .
>
> MyComponent.obj : error LNK2001: unresolved external symbol "public:
> virtual unsigned int __stdcall WebLock::GetWeakReference(class
> nsIWeakReference * *)" (?
> GetWeakReference@WebLock@@UAGIPAPAVnsIWeakReference@@@Z)
> 1>.\Debug\MyComponent.dll : fatal error LNK1120: 1 unresolved
> externals
>
>
> I am also pasting peace of code related to this error ..Please help me
> get out of this error.
> I am linking against xpcomglue_s.lib ,xpcom.lib ,plc4.lib nspr4.lib
> and plds4,lib.
>
> MyComponent.h
> class WebLock : public nsIWebProgressListener,
> public nsISupportsWeakReference,
> public nsIObserver,
> public iWeblock
> {
> public:
> NS_DECL_ISUPPORTS
> NS_DECL_NSIOBSERVER
> NS_DELC_NSIWEBPROGRESSLISTENER
> NS_DECL_NSISUPPORTSWEAKREFERENCE
> ...............
> ...............
> };
>
>
>
> MyComponent.cpp
>
> NS_IMPL_ISUPPORTS4(WebLock, nsIWebProgressListener,
> nsISupportsWeakReference,
> nsIObserver,
> iWeblock)
> ............
> .............
>
> Thanks.
>
> _______________________________________________
> dev-tech-xpcom mailing list
> dev-tech-xpcom@...
> https://lists.mozilla.org/listinfo/dev-tech-xpcom
>
_______________________________________________
dev-tech-xpcom mailing list
dev-tech-xpcom@...
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Parent Message unknown Re: C++ XPCOM componenet - Linker Error

by veer_in :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

On Aug 31, 2:17 pm, "Nickolay Ponomarev" <asquee...@...> wrote:

> So did you implement that method? You snipped the relevant code.
>
> Nickolay
>
> On 8/31/07, swatipatel...@... <swatipatel...@...> wrote:
>
>
>
> > hey guys,
>
> > I ma making an xpcom component to listen to event generated by Mozilla
> > browser. It compiles fien ..but gives linker error .
>
> > MyComponent.obj : error LNK2001: unresolved external symbol "public:
> > virtual unsigned int __stdcall WebLock::GetWeakReference(class
> > nsIWeakReference * *)" (?
> > GetWeakReference@WebLock@@UAGIPAPAVnsIWeakReference@@@Z)
> > 1>.\Debug\MyComponent.dll : fatal error LNK1120: 1 unresolved
> > externals
>
> > I am also pasting peace of code related to this error ..Please help me
> > get out of this error.
> > I am linking against xpcomglue_s.lib ,xpcom.lib ,plc4.lib nspr4.lib
> > and plds4,lib.
>
> > MyComponent.h
> > class WebLock : public nsIWebProgressListener,
> > public nsISupportsWeakReference,
> > public nsIObserver,
> > public iWeblock
> > {
> > public:
> > NS_DECL_ISUPPORTS
> > NS_DECL_NSIOBSERVER
> > NS_DELC_NSIWEBPROGRESSLISTENER
> > NS_DECL_NSISUPPORTSWEAKREFERENCE
> > ...............
> > ...............
> > };
>
> > MyComponent.cpp
>
> > NS_IMPL_ISUPPORTS4(WebLock, nsIWebProgressListener,
> > nsISupportsWeakReference,
> > nsIObserver,
> > iWeblock)
> > ............
> > .............
>
> > Thanks.
>
> > _______________________________________________
> > dev-tech-xpcom mailing list
> > dev-tech-xp...@...
> >https://lists.mozilla.org/listinfo/dev-tech-xpcom- Hide quoted text -
>
> - Show quoted text -

 i didnt implement it..But i searched for code that how may i do
that ..finally i m implementing the method as follow..and things
working properly..But i doubt whether i m correct or not..

NS_IMETHODIMP WebLock::GetWeakReference(nsIWeakReference **_retval)
{
        if ( !_retval )
                return NS_ERROR_NULL_POINTER;

    *_retval = new nsWeakReference((nsSupportsWeakReference *)this);

        nsresult status;
    if ( !*_retval )
                status = NS_ERROR_OUT_OF_MEMORY;
    else
        {
         NS_ADDREF(*_retval);
         status = NS_OK;
    }

    return status;
}

_______________________________________________
dev-tech-xpcom mailing list
dev-tech-xpcom@...
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Re: C++ XPCOM componenet - Linker Error

by Nickolay Ponomarev :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

On 8/31/07, swatipatel.20@... <swatipatel.20@...> wrote:
>  i didnt implement it..But i searched for code that how may i do
> that ..finally i m implementing the method as follow..and things
> working properly..But i doubt whether i m correct or not..
>
Well, the internal classes just inherit from nsSupportsWeakReference
(which provides the implementation of GetWeakReference) when they need
to implement nsISupportsWeakReference. Since that class in xpcom/glue,
I guess you can use it in your component too, although I never worked
with it.

Nickolay

P.S. Sorry for top-posting earlier, my phone likes to do that sometimes.
_______________________________________________
dev-tech-xpcom mailing list
dev-tech-xpcom@...
https://lists.mozilla.org/listinfo/dev-tech-xpcom