【发布时间】:2019-11-20 22:25:17
【问题描述】:
我正在关注https://cygwin.com/cygwin-ug-net/dll.html 的“构建和使用 DLL”教程。 我已经制作了 mydll.cpp 文件:
#include <iostream>
void hello()
{
std::cout << "Hello World of DLL" << std::endl;
}
编译并链接它:
g++ -c mydll.cpp
g++ -shared -o mydll.dll mydll.o
然后尝试在 main.cpp 中使用 hello() 函数:
int main ()
{
hello ();
}
与g++ -o main main.cpp -L./ -l mydll链接后得到:
error: 'hello' was not declared in this scope
hello();
本教程指出一切都应该正常工作。我错过了什么?
【问题讨论】:
标签: c++ gcc dll mingw dllimport