This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re[2]: I want to use DLL compiled with Cygwin with VC(VS2008).


Thank you. 

However, it did not move well. 

If test.dll is done in LoadLibrary, Access Violation is generated. 

Are you still amused something?


[main source code]

#include "stdafx.h"
#include "windows.h"

#ifdef __cplusplus
extern "C"{
#endif

typedef int (*TFUNC)(void);

typedef void (*Tinit)(void);

int _tmain(int argc, _TCHAR* argv[])
{
	int i;

	HINSTANCE	h;
    	HINSTANCE	hInstDLL;

	Tinit		init;
	TFUNC		DllFunction;
	DWORD		ErrNo;

	h = LoadLibrary( TEXT( "cygwin1.dll" ) );
	init = (Tinit)GetProcAddress( h, "cygwin_dll_init" );

	init();

	hInstDLL = LoadLibrary( TEXT( "test.dll" ) );		/* !Access Violation! */
	if( hInstDLL == NULL )
	{
		ErrNo = GetLastError();
		return 0;
	}
	DllFunction = (TFUNC)GetProcAddress( hInstDLL, "hello" );
	i = DllFunction();

	FreeLibrary( hInstDLL );
	FreeLibrary( h );

	return 0;
}

#ifdef __cplusplus
}
#endif

-- 
 Y.Hosoi <mlist@mail.cuvie.net>


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]