test.c warning LNK4070: /OUT:Test.dll directive in .EXP differs from output filename 'Debug/test.c.dll'; ignoring directive test.c error LNK2019: unresolved external symbol _Perl_sv_2mortal referenced in function "void __cdecl ExtensionAddNumbers(struct interpreter *,struct cv *)" (?ExtensionAddNumbers@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_newSViv referenced in function "void __cdecl ExtensionAddNumbers(struct interpreter *,struct cv *)" (?ExtensionAddNumbers@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_croak_nocontext referenced in function "void __cdecl ExtensionAddNumbers(struct interpreter *,struct cv *)" (?ExtensionAddNumbers@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_Tstack_base_ptr referenced in function "void __cdecl ExtensionAddNumbers(struct interpreter *,struct cv *)" (?ExtensionAddNumbers@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_Tmarkstack_ptr_ptr referenced in function "void __cdecl ExtensionAddNumbers(struct interpreter *,struct cv *)" (?ExtensionAddNumbers@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_Tstack_sp_ptr referenced in function "void __cdecl ExtensionAddNumbers(struct interpreter *,struct cv *)" (?ExtensionAddNumbers@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_get_context referenced in function "void __cdecl ExtensionAddNumbers(struct interpreter *,struct cv *)" (?ExtensionAddNumbers@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_sv_2iv referenced in function "long __cdecl ExtractLongFromSV(struct sv *)" (?ExtractLongFromSV@@YAJPAUsv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_sv_setsv_flags referenced in function "void __cdecl ExtensionGetFileSizes(struct interpreter *,struct cv *)" (?ExtensionGetFileSizes@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_Isv_undef_ptr referenced in function "void __cdecl ExtensionGetFileSizes(struct interpreter *,struct cv *)" (?ExtensionGetFileSizes@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_sv_catpvn_flags referenced in function "void __cdecl ExtensionGetFileSizes(struct interpreter *,struct cv *)" (?ExtensionGetFileSizes@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_sv_2pv_flags referenced in function "void __cdecl ExtensionGetFileSizes(struct interpreter *,struct cv *)" (?ExtensionGetFileSizes@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_newSVpv referenced in function "void __cdecl ExtensionGetFileSizes(struct interpreter *,struct cv *)" (?ExtensionGetFileSizes@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_Isv_yes_ptr referenced in function "void __cdecl boot_Win32__Test(struct interpreter *,struct cv *)" (?boot_Win32__Test@@YAXPAUinterpreter@@PAUcv@@@Z) test.c error LNK2019: unresolved external symbol _Perl_newXS referenced in function "void __cdecl boot_Win32__Test(struct interpreter *,struct cv *)" (?boot_Win32__Test@@YAXPAUinterpreter@@PAUcv@@@Z) test.c fatal error LNK1120: 15 unresolved externals #### // test.c.cpp : Defines the entry point for the dll application. // #ifdef __BORLANDC__ typedef wchar_t wctype_t; #endif #define EMBED #define WIN32 #define HAVE_DES_FCRYPT #define MULTIPLICITY #define PERL_IMPLICIT_CONTEXT #define PERL_IMPLICIT_SYS #define PERL_NO_GET_CONTEXT #define PERL_POLLUTE #define USE_ITHREADS #define WIN32_LEAN_AND_MEAN #include #include #include #include "stdafx.h" #if defined (__cplusplus) && !defined( PERL_OBJECT ) extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #if defined (__cplusplus) && !defined( PERL_OBJECT ) } #endif // Global Variables HINSTANCE ghInstance = NULL; DWORD gdwThreads = 0; #if PERL_VERSION == 6 && !defined( PERL_OBJECT ) #ifndef USE_THREADS #define PERL_ARG_PROTO PerlInterpreter* my_perl, #define PERL_ARG_ONLY_PROTO PerlInterpreter* my_perl #define PERL_ARG my_perl, #define PERL_ARG_ONLY my_perl #else #define PERL_ARG_PROTO pTHXo_ #define PERL_ARG_ONLY_PROTO perl_thread *thr #define PERL_ARG aTHXo_ #define PERL_ARG_ONLY aTHXo #endif #endif #ifdef PERL_OBJECT #define PERL_ARG_PROTO CPerl *pPerl, #define PERL_ONLY_ARG_PROTO CPerl *pPerl #define PERL_ARG pPerl, #define PERL_ARG_ONLY pPerl #else #define PERL_ARG_PROTO #define PERL_ONLY_ARG_PROTO #define PERL_ARG #define PERL_ONLY_ARG #endif long ExtractLongFromSV ( PERL_ARG_PROTO SV* pSV ); XS ( ExtensionAddNumbers ){ dXSARGS; long lNum1; long lNum2; long lSum; SV* pSV; if ( items != 2 ) { croak ( "Usage : $Sum = Win32::Test::AddNumbers ( $First, $Second ) "); } pSV = ST (0); lNum1 = ExtractLongFromSV (PERL_ARG pSV ); pSV = ST (1) ; lNum2 = ExtractLongFromSV (PERL_ARG pSV ); lSum = lNum1 + lNum2; pSV = newSViv (lSum); ST(0) = sv_2mortal (pSV); XSRETURN (1); } long ExtractLongFromSV ( PERL_ARG_PROTO SV* pSV ){ dXSARGS; long lValue = 0; if ( SvIOK (pSV) ) { lValue = SvIV ( pSV); } return (lValue); } typedef struct { char m_szPath[256]; DWORD m_dwSize; } FileStruct; XS ( ExtensionGetFileSizes ){ dXSARGS; FileStruct File; WIN32_FIND_DATA fileFind; HANDLE hSearch; SV *pSV = newSVpv("", 0); char *pszPath = NULL; int iTotal = 0; BOOL bContinue = TRUE; unsigned int uiLength = 0; if ( items != 2 ) { croak ( "Usage : $Sum = Win32::Test::GetFileSizes ( $Path, $Data ) "); } pszPath = SvPV ( ST ( 0 ), uiLength ); hSearch = FindFirstFile ( pszPath, &fileFind ); if ( INVALID_HANDLE_VALUE != hSearch ) { while ( bContinue) { if ( ! ( fileFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) { ZeroMemory ( File.m_szPath, sizeof ( File.m_szPath)); strncpy (File.m_szPath, fileFind.cFileName, sizeof ( File.m_szPath ) -1); File.m_dwSize = fileFind.nFileSizeLow; sv_catpvn ( pSV, (char*) &File, sizeof (File) ); iTotal++; } bContinue = FindNextFile ( hSearch, &fileFind ); } FindClose ( hSearch ); } else { pSV = &PL_sv_undef; } ST (0) = sv_2mortal ( newSViv ( iTotal) ); sv_setsv ( ST (1) , pSV ) ; XSRETURN (1); } XS (boot_Win32__Test ) { dXSARGS; char *pszFile= __FILE__; newXS ( "Win32::Test::GetFileSizes", ExtensionGetFileSizes, pszFile ); newXS ( "Win32::Test::AddNumbers", ExtensionAddNumbers, __FILE__ ); ST (0) = &PL_sv_yes; XSRETURN (1); } BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved ){ BOOL bResult = TRUE; switch ( dwReason ){ case DLL_PROCESS_ATTACH: ghInstance = hInstance; break; case DLL_THREAD_ATTACH: gdwThreads++; break; case DLL_THREAD_DETACH: gdwThreads--; break; case DLL_PROCESS_DETACH: break; } return ( bResult ); }