Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从windows使用Cygwin编译的dll_C++_C_Dll_Cygwin - Fatal编程技术网

C++ 从windows使用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>

我需要使用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>
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;
}