tags:

views:

54

answers:

1

Hi,

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 generate the lib file I get the LNK1107 error for an invalid or corrupt file. Any help would be most welcome.

Regards

+1  A: 

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>

Edward83
Thanks for the reply, I tried that example but it didn't appear to work.
paj7777
@paj7777 Do you know parameters of exporting functions? Is this dll yours own library or third party?)))
Edward83
I have the parameters as I have the header files, the dll is part of vlc, if you follow the link I supplied that will take you to the wiki for vlc. Thanks for the help.
paj7777
Thanks for the recent post. A call to get version is fine but when I try to call libvlc_new I get a calling convention runtime error although I'm pretty sure I'm passing the parameters correctly. Is there anyway of checking the required convention against my own?
paj7777
Sorry, I tried, but I do not know how to help you, i did not work with VLC. Maybe exe-module makes some specific initializations before calling libvlc_new, like: init COM, fill some specific structs, set some variables or paths, etc; Maybe you need to check such options;)
Edward83
Check this link http://www.codeproject.com/KB/audio-video/nVLC.aspx they write wrapper for .net, maybe you'll find some ideas;)
Edward83
And one more thing. As I found, there are two versions of libvlc.h; If you download opensource you'll find second version of this header and definitions of some suspicious functions like system_Init; Also check libvlc.c;
Edward83
I finally managed to get the lib file. It appears that if you leave space between def: and the location of the def file you a lnk1107 error. Thanks for your help and I've learnt something about accessing external DLLs.
paj7777