C++ 从windows使用Cygwin编译的dll
我需要使用VisualStudioC++或Cys:MIW../P>代码的CygWin编译的DLL。 我试着用这个简单的例子C++ 从windows使用Cygwin编译的dll,c++,c,dll,cygwin,C++,C,Dll,Cygwin,我需要使用VisualStudioC++或Cys:MIW../P>代码的CygWin编译的DLL。 我试着用这个简单的例子 #include <stdio.h> int MyFunc() { printf("Printed from cygwin dll"); return 0; } 我试图在这里调用最终的dll #include <windows.h> #include <iostream> #include <string>
#include <stdio.h>
int MyFunc()
{
printf("Printed from cygwin dll");
return 0;
}
我试图在这里调用最终的dll
#include <windows.h>
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
typedef int(*FnP_MyFunc)();
typedef void(*FnP_CYGWIN_DLL_INIT)();
int main()
{
FnP_MyFunc fnMyFunc;
HMODULE hLib, hGetCygwinIDDLL = LoadLibrary(TEXT("C:\\cygwin64\\bin\\cygwin1.dll"));
if (hGetCygwinIDDLL)
{
FnP_CYGWIN_DLL_INIT init = (FnP_CYGWIN_DLL_INIT)GetProcAddress(hGetCygwinIDDLL, "cygwin_dll_init");
init();
std::cout << "init complete " << endl;
}
int a;
hLib = LoadLibrary(TEXT("C:\\cygwin64\\home\\azatyan\\TestDynamicLink\\cygTest.dll"));
if (hLib)
{
std::cout << "From wrapper dll " << std::endl;
fnMyFunc = (FnP_MyFunc)GetProcAddress(hLib, "MyFunc");
a = fnMyFunc();
cout << a;
}
FreeLibrary(hGetCygwinIDDLL);
FreeLibrary(hLib);
return 0;
}
#包括
#包括
#包括
#包括
使用名称空间std;
typedef int(*FnP_MyFunc)();
typedef void(*FnP_CYGWIN_DLL_INIT)();
int main()
{
FnP_MyFunc fnMyFunc;
HMODULE hLib,hGetCygwinidll=LoadLibrary(文本(“C:\\cygwin64\\bin\\cygwin1.dll”);
if(hGetCygwinidll)
{
FnP_CYGWIN_DLL_INIT INIT=(FnP_CYGWIN_DLL_INIT)GetProcAddress(hGetcygwinidll,“CYGWIN_DLL_INIT”);
init();
问题可能在这里?Q:我可以同时链接MSVCRT*.DLL和cygwin1.DLL吗?A:不,你必须使用其中一个,它们是互斥的。有人知道吗?问题可能在这里?Q:我可以同时链接MSVCRT*.DLL和cygwin1.DLL吗?A:不,你必须使用其中一个,它们是互斥的。有人知道吗s
#include <windows.h>
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
typedef int(*FnP_MyFunc)();
typedef void(*FnP_CYGWIN_DLL_INIT)();
int main()
{
FnP_MyFunc fnMyFunc;
HMODULE hLib, hGetCygwinIDDLL = LoadLibrary(TEXT("C:\\cygwin64\\bin\\cygwin1.dll"));
if (hGetCygwinIDDLL)
{
FnP_CYGWIN_DLL_INIT init = (FnP_CYGWIN_DLL_INIT)GetProcAddress(hGetCygwinIDDLL, "cygwin_dll_init");
init();
std::cout << "init complete " << endl;
}
int a;
hLib = LoadLibrary(TEXT("C:\\cygwin64\\home\\azatyan\\TestDynamicLink\\cygTest.dll"));
if (hLib)
{
std::cout << "From wrapper dll " << std::endl;
fnMyFunc = (FnP_MyFunc)GetProcAddress(hLib, "MyFunc");
a = fnMyFunc();
cout << a;
}
FreeLibrary(hGetCygwinIDDLL);
FreeLibrary(hLib);
return 0;
}