我正在遵循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();
本教程指出,一切都应该正常进行。我想念什么?
hello
的已编译定义。