我正在为firefox创建简单的XPCOM插件,使用下面的代码。Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets代码是直截了当的,但我得到了以下错误:blog.peschla.net错误1 MSB3073:命令"xpidl-build.bat IHelloWorld.idl :VCEnd“与代码1. C:\Program 103 6 HelloWorld (我正在使用firefox 22 )一起使用,因此gecko版本22和vs2010我使用了以下文件。
我给出了上面的链接,上面包含了所有的代码,但我也给出了下面的代码。
1)HelloWorld.h .h
#include "HelloWorld.h"
NS_IMPL_ISUPPORTS1(HelloWorld, IHelloWorld)
HelloWorld::HelloWorld()
{
mName.Assign(L"Nameless");
}
HelloWorld::~HelloWorld(){}
/* attribute AString name; */
NS_IMETHODIMP HelloWorld::GetName(nsAString & aName)
{
aName.Assign(mName);
return NS_OK;
}
NS_IMETHODIMP HelloWorld::SetName(const nsAString & aName)
{
mName.Assign(aName);
return NS_OK;
}
/* long add (in long a, in long b); */
NS_IMETHODIMP HelloWorld::Add(PRInt32 a, PRInt32 b, PRInt32 *_retval NS_OUTPARAM)
{
*_retval = a + b;
return NS_OK;
}2)HelloWorld.cpp
#include "HelloWorld.h"
NS_IMPL_ISUPPORTS1(HelloWorld, IHelloWorld)
HelloWorld::HelloWorld()
{
mName.Assign(L"Nameless");
}
HelloWorld::~HelloWorld(){}
/* attribute AString name; */
NS_IMETHODIMP HelloWorld::GetName(nsAString & aName)
{
aName.Assign(mName);
return NS_OK;
}
NS_IMETHODIMP HelloWorld::SetName(const nsAString & aName)
{
mName.Assign(aName);
return NS_OK;
}
/* long add (in long a, in long b); */
NS_IMETHODIMP HelloWorld::Add(PRInt32 a, PRInt32 b, PRInt32 *_retval NS_OUTPARAM)
{
*_retval = a + b;
return NS_OK;
}3)IHelloWorld.idl
#include "nsISupports.idl"
[scriptable, uuid(2f52e0f0-0eac-11e1-be50-0800200c9a66)]
interface IHelloWorld : nsISupports
{
attribute AString name;
long add(in long a, in long b);
}4)HelloWorldModule.cpp
#include "mozilla/ModuleUtils.h"
#include "nsIClassInfoImpl.h"
#include "HelloWorld.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(HelloWorld)
// The following line defines a kHELLOWORLD_CID CID variable.
NS_DEFINE_NAMED_CID(HELLOWORLD_CID);
static const mozilla::Module::CIDEntry kSampleCIDs[] = {
{ &kHELLOWORLD_CID, false, NULL, HelloWorldConstructor },
{ NULL }
};
static const mozilla::Module::ContractIDEntry kSampleContracts[] = {
{ HELLOWORLD_CONTRACTID, &kHELLOWORLD_CID },
{ NULL }
};
static const mozilla::Module kSampleModule = {
mozilla::Module::kVersion,
kSampleCIDs,
kSampleContracts,
NULL /* or a category definition if you need it */
};
NSMODULE_DEFN(nsSampleModule) = &kSampleModule;5)xpidl-build.bat (用作命令行调用预构建事件)
..\..\xulrunner-sdk\sdk\bin\xpidl.exe -m header -I..\..\xulrunner-sdk\idl %1
..\..\xulrunner-sdk\sdk\bin\xpidl.exe -m typelib -I..\..\xulrunner-sdk\idl %1发布于 2013-07-09 14:44:04
我发现我的mistake.Reason是错误的:“我把gecko-sdk放到了错误的目录中”,.Now是我的项目能够构建的。感谢所有回复这条线索的人。
https://stackoverflow.com/questions/17472895
复制相似问题