以下是带有mingw的简单c ++ DLL教程的错误

问题描述 投票:0回答:1

我正在遵循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
1个回答
0
投票
链接过程与编译过程是分开的。您提供的库包含链接过程中使用的hello的已编译定义。
© www.soinside.com 2019 - 2024. All rights reserved.