我正在构建一个包含以下内容的 DLL:
extern "C" __declspec(dllexport) void __stdcall DrawMouse(int X, int Y, int R, int G, int B)
{
Buffer.SetMouse(X, Y, R, G, B);
}
然后在 .def 文件中我添加了:
LIBRARY Test
;DESCRIPTION "Test Definition File"
EXPORTS
DrawMouse;
然后当我编译时,我添加链接器选项:
-static
-static-libstdc++
-static-libgcc
-Wl,--kill-at -d --input-def src\Test.def
-m32
输出是:
Warning: Resolving _DrawMouse by linking to _DrawMouse@24
为什么?为什么它警告我要解决,我怎样才能摆脱它?对于大量导出,我收到大量警告..
小例子:
主要.cpp:
#include <windows.h>
class Input
{
public:
void SetMouse(int X, int Y, int R, int G, int B)
{
/**Dummy Example**/
}
};
Input Buffer;
extern "C" void __stdcall SetMouse2(int X, int Y, int R, int G, int B)
{
/**Dummy Non-Class Example**/
}
extern "C" __declspec(dllexport) void __stdcall DrawMouse(int X, int Y, int R, int G, int B)
{
Buffer.SetMouse(X, Y, R, G, B);
}
extern "C" __declspec(dllexport) void __stdcall DrawMouse2(int X, int Y, int R, int G, int B)
{
SetMouse2(X, Y, R, G, B);
}
extern "C" __declspec(dllexport) bool __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DrawMouse(100, 100, 1, 1, 1);
DrawMouse2(100, 100, 1, 1, 1);
break;
case DLL_PROCESS_DETACH:
break;
}
return true;
}
测试.def:
LIBRARY Test
;DESCRIPTION "Test Definition File"
EXPORTS
DrawMouse;
DrawMouse2;
编译器日志:
-------------- Clean: Release in Test (compiler: GNU GCC Compiler)---------------
Cleaned "Test - Release"
-------------- Build: Release in Test (compiler: GNU GCC Compiler)---------------
x86_64-w64-mingw32-g++.exe -O2 -Wall -m32 -DBUILD_DLL -std=c++11 -c C:\Users\Brandon\Desktop\Test\main.cpp -o obj\Release\main.o
x86_64-w64-mingw32-g++.exe -shared -Wl,--output-def=bin\Release\libTest.def -Wl,--out-implib=bin\Release\libTest.a -Wl,--dll obj\Release\main.o -o bin\Release\Test.dll -s -static -static-libstdc++ -static-libgcc -Wl,--kill-at -d --input-def Test.def -m32 -luser32
Warning: resolving _DrawMouse by linking to _DrawMouse@20
Warning: resolving _DrawMouse2 by linking to _DrawMouse2@20
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Output size is 32.50 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 2 warnings (0 minutes, 0 seconds)
注意:--disable-stdcall-fixup 不起作用。这就是为什么我要问如何解决这个问题并消除这些警告以及导致它们的原因。
编辑:
按要求修复的命令行:
x86_64-w64-mingw32-g++.exe -O2 -Wall -m32 -DBUILD_DLL -std=c++11 -c C:\Users\Brandon\Desktop\Test\main.cpp -o obj\Release\main.o
x86_64-w64-mingw32-g++.exe -shared -Wl,--output-def=bin\Release\libTest.def -Wl,--out-implib=bin\Release\libTest.a -Wl,--dll obj\Release\main.o -o bin\Release\Test.dll -s -static -static-libstdc++ -static-libgcc -Wl,--kill-at -d --input-def Test.def -m32 --disable-stdcall-fixup -luser32
还试过:
x86_64-w64-mingw32-g++.exe -O2 -Wall -m32 -DBUILD_DLL -std=c++11 -c C:\Users\Brandon\Desktop\Test\main.cpp -o obj\Release\main.o
x86_64-w64-mingw32-g++.exe -shared -Wl,--output-def=bin\Release\libTest.def -Wl,--out-implib=bin\Release\libTest.a -Wl,--dll obj\Release\main.o -o bin\Release\Test.dll -s -static -static-libstdc++ -static-libgcc -Wl,--kill-at -d --input-def Test.def -m32 --enable-stdcall-fixup -luser32
都不行。
最佳答案
您需要向链接器提供 --enable-stdcall-fixup(它会自动修复问题)。当与 gcc 或 g++ 一起使用时,这意味着 -Wl,--enable-stdcall-fixup。
有关这些选项的详细信息,请查看 Gnu Linker options 的第 2.1.1 节.
关于c++ - 警告 : resolving Func by linking to Func@##,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16911866/
我试图使用yard记录一些Ruby代码,尽管我所做的正是所描述的here或here#@param[Integer]thenumberoftrials(>=0)#@param[Float]successprobabilityineachtrialdefinitialize(n,p)#initialize...end虽然我仍然得到这个奇怪的错误@paramtaghasunknownparametername:the@paramtaghasunknownparametername:success然后生成的html看起来很奇怪。我称yard为:$yarddoc-mmarkdown我做错了什么?
我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server
我正在使用active_admin,我在Rails3应用程序的应用程序中有一个目录管理,其中包含模型和页面的声明。时不时地我也有一个类,当那个类有一个常量时,就像这样:classFooBAR="bar"end然后,我在每个必须在我的Rails应用程序中重新加载一些代码的请求中收到此警告:/Users/pupeno/helloworld/app/admin/billing.rb:12:warning:alreadyinitializedconstantBAR知道发生了什么以及如何避免这些警告吗? 最佳答案 在纯Ruby中:classA
最近,当我启动我的Rails服务器时,我收到了一长串警告。虽然它不影响我的应用程序,但我想知道如何解决这些警告。我的估计是imagemagick以某种方式被调用了两次?当我在警告前后检查我的git日志时。我想知道如何解决这个问题。-bcrypt-ruby(3.1.2)-better_errors(1.0.1)+bcrypt(3.1.7)+bcrypt-ruby(3.1.5)-bcrypt(>=3.1.3)+better_errors(1.1.0)bcrypt和imagemagick有关系吗?/Users/rbchris/.rbenv/versions/2.0.0-p247/lib/ru
简而言之错误:NOTE:Gem::SourceIndex#add_specisdeprecated,useSpecification.add_spec.Itwillberemovedonorafter2011-11-01.Gem::SourceIndex#add_speccalledfrom/opt/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:91./opt/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/gem_dependency.rb:275:in`==':und
如何将send与+=一起使用?a=20;a.send"+=",10undefinedmethod`+='for20:Fixnuma=20;a+=10=>30 最佳答案 恐怕你不能。+=不是方法,而是语法糖。参见http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html它说Incommonwithmanyotherlanguages,Rubyhasasyntacticshortcut:a=a+2maybewrittenasa+=2.你能做的最好的事情是:
我对如何计算通过{%assignvar=0%}赋值的变量加一完全感到困惑。这应该是最简单的任务。到目前为止,这是我尝试过的:{%assignamount=0%}{%forvariantinproduct.variants%}{%assignamount=amount+1%}{%endfor%}Amount:{{amount}}结果总是0。也许我忽略了一些明显的东西。也许有更好的方法。我想要存档的只是获取运行的迭代次数。 最佳答案 因为{{incrementamount}}将输出您的变量值并且不会影响{%assign%}定义的变量,我
我有一个数组数组,想将元素附加到子数组。+=做我想做的,但我想了解为什么push不做。我期望的行为(并与+=一起工作):b=Array.new(3,[])b[0]+=["apple"]b[1]+=["orange"]b[2]+=["frog"]b=>[["苹果"],["橙子"],["Frog"]]通过推送,我将推送的元素附加到每个子数组(为什么?):a=Array.new(3,[])a[0].push("apple")a[1].push("orange")a[2].push("frog")a=>[[“苹果”、“橙子”、“Frog”]、[“苹果”、“橙子”、“Frog”]、[“苹果”、“
有没有办法让Ruby能够做这样的事情?classPlane@moved=0@x=0defx+=(v)#thisiserror@x+=v@moved+=1enddefto_s"moved#{@moved}times,currentxis#{@x}"endendplane=Plane.newplane.x+=5plane.x+=10putsplane.to_s#moved2times,currentxis15 最佳答案 您不能在Ruby中覆盖复合赋值运算符。任务在内部处理。您应该覆盖+,而不是+=。plane.a+=b与plane.a=
出于某种原因,heroku尝试要求dm-sqlite-adapter,即使它应该在这里使用Postgres。请注意,这发生在我打开任何URL时-而不是在gitpush本身期间。我构建了一个默认的Facebook应用程序。gem文件:source:gemcuttergem"foreman"gem"sinatra"gem"mogli"gem"json"gem"httparty"gem"thin"gem"data_mapper"gem"heroku"group:productiondogem"pg"gem"dm-postgres-adapter"endgroup:development,:t