I followed the instructions on this site http://wiki.videolan.org/GenerateLibFromDll for generating a lib file from a dll. The def file is created fine and I have editted it as suggested but when I try to 开发者_StackOverflow社区generate the lib file I get the LNK1107 error for an invalid or corrupt file. Any help would be most welcome.
Regards
Try another way: call function from dll by getting pointer with GetProcAddress;
Example: C++ calling a dll
Update:
VLC media player downloaded as 7zip version;
I choose the way with GetProcAddress:
#include <windows.h>
#include <iostream>
int main()
{
//VLC_PUBLIC_API const char * libvlc_get_version(void);
//Set directory path with libvlccore.dll and libvlc.dll
SetCurrentDirectory("C:/Program Files/VideoLAN/VLC");
HINSTANCE hGetProcIDDLL = LoadLibrary("libvlc.dll");
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE(hGetProcIDDLL),"libvlc_get_version");
if(lpfnGetProcessID == 0)
{
std::cout << "GetProcAddress failed";
return 1;
}
typedef const char * (__stdcall * pICFUNC)(void);
pICFUNC MyFunction = pICFUNC(lpfnGetProcessID);
std::cout << MyFunction() << std::endl;
//output: 1.1.4 The Luggage
return 0;
}
It works fine for me, but you must change Character Set from default Unicode to Multi-Byte: Project -> Properties -> General -> Character Set;
Try it! and good luck!;)
Update 2:
I got lib, here the trace from cmd:
Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp.
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin>vcvars32.bat
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin>"C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat" Setting environment for using Microsoft Visual Studio 2008 x86 tools.
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin>dumpbin.exe /exports "D:\My Downloads\VLC\vlc-1.1.4-win32\vlc-1.1.4\libvlc.dll"
"C:\Documents and Settings \Eugene\My Documents\Visual Studio 2008\Projects\VLCApp\VLCApp\libvlc.def"
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin>lib /def:"C:\Documents and S ettings\Eugene\My Documents\Visual Studio 2008\Projects\VLCApp\VLCApp\libvlc.def " /out:"C:\Documents and Settings\Eugene\My Documents\Visual Studio 2008\Project s\VLCApp\VLCApp\libvlc.lib" /machine:x86 Microsoft (R) Library Manager Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved.
Creating library C:\Documents and Settings\Eugene\My Documents\Visual Studio 2008\Projects\VLCApp\VLCApp\libvlc.lib and object C:\Documents and Settings\Euge ne\My Documents\Visual Studio 2008\Projects\VLCApp\VLCApp\libvlc.exp
C:\Program Files\Microsoft Visual Studio 9.0\VC\bin>
精彩评论