【发布时间】:2015-01-28 15:23:54
【问题描述】:
dllwrap 是 mingw 中 GNU GCC 的工具。它可以用来构建 gcc 或 g++ 之类的 .dll 文件。但我发现它不能很好地使用如下:
hello3.cpp
#include<iostream>
extern "C" void MyDllSay( void )
{
}
hello3.def
LIBRARY hello3.dll
EXPORTS
MyDllSay @1
hello = MyDllSay @2
编译代码是
g++.exe -c -O3 hello3.cpp
dllwrap.exe -o hello3.dll hello3.o --def hello3.def --output-lib libhello3.a
错误报告是
hello3.o:hello3.cpp:(.text+0x8): 未定义的引用
std::ios_base::Init::~I nit()' hello3.o:hello3.cpp:(.text.startup+0xc): undefined reference tostd::ios_base::Init::Init()' collect2.exe: 错误: ld 返回 1 退出 状态
如果我这样设置 hello3.cpp
//#include<iostream>
#include<fstream>
extern "C" void MyDllSay( void )
{
}
或者像这样
//#include<iostream>
extern "C" void MyDllSay( void )
{
}
一切都很好。 如何让 dllwrap 与 iostream 一起工作?
非常感谢您的任何帮助!
【问题讨论】:
-
使用
g++ -shared有什么问题?