Thread: Video for windows

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    4

    Smile Video for windows

    Dear friends :

    I am trying to port an aplication I did in masm to c.
    This app was to make a webcam-type imaging system.
    I am using the Dev-C++ compiler.

    My problem is that :

    One function I have to use is :

    capCreateCaptureWindow, as defined in video for windows.

    As I don't have the include file, but have the lib file (libvfw32.a),
    I tryed that :

    - in Resource.h (one file I created) :

    #define VFWAPI WINAPI

    HWND VFWAPI capCreateCaptureWindowW (
    LPCSTR lpszWindowName,
    DWORD dwStyle,
    int x, int y, int nWidth, int nHeight,
    HWND hwndParent, int nID);

    #define capCreateCaptureWindow capCreateCaptureWindowW


    in main.cpp :

    HWND hWndc;

    hWndc = capCreateCaptureWindow (
    0,
    WS_POPUP | WS_VISIBLE | WS_THICKFRAME,
    0,
    0,
    320,
    240,
    0,
    0
    );

    when I compile it I get an error :


    [Linker error] undefined reference to `_Z23capCreateCaptureWindowWPKwmiiiiP6HWND__i@32'


    Do somebody have an idea? Sorry if it's a stupid question, maybe
    but I am starting to learn C.

    Thanks a lot :

    Sergio Aguiar

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Code:
    HWND VFWAPI capCreateCaptureWindowW (
    LPCSTR lpszWindowName,
    DWORD dwStyle,
    int x, int y, int nWidth, int nHeight,
    HWND hwndParent, int nID);
    You have chosen the Unicode version, but you are using the params of the ASCII version....try

    Code:
    HWND VFWAPI capCreateCaptureWindowW (
    LPCWSTR lpszWindowName,
    DWORD dwStyle,
    int x, int y, int nWidth, int nHeight,
    HWND hwndParent, int nID);

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    4

    Unhappy Didn't work

    Dear friend :
    Thanks for your answer, but it didn't worked.


    My Resource.h :

    #define VFWAPI WINAPI

    #define ID_ICON1 200
    #define ID_ICON2 201
    #define ID_ICON3 202
    #define ID_TRAYICON 300

    HWND VFWAPI capCreateCaptureWindowW (
    LPCWSTR lpszWindowName,
    DWORD dwStyle,
    int x,int y,int nWidth,int nHeight,
    HWND hwndParent,int nID);

    #define capCreateCaptureWindow capCreateCaptureWindowW


    My Main.cpp :


    #include "Resource.h"

    ..
    ..
    ..

    hWndc = capCreateCaptureWindow (
    (LPCWSTR) "My Capture Window", // window name if pop-up
    WS_CHILD | WS_VISIBLE, // window style
    0, 0, 160, 120, // window position and dimensions
    (HWND) hwnd,
    (int) 32
    );

    ..
    ..
    ..

    When I try to compile, I get the same error :

    [Linker error] undefined reference to `_Z23capCreateCaptureWindowWPKwmiiiiP6HWND__i@32'

    Do I have to pass some other(s) option(s) to compiler or linker?

    Thanks anyway.

    Sergio Aguiar

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Hmmm weird...I see your problem.........

    I notice from the header (from which the info I gave was correct) that these functions are exported from "AVICAP.DLL"....

    I tried to link implicitely at runtime, but I got an error...so I dumped the dll into Dependancy walker and that choked too....thinking I had a duff dll, I tried it in a hex editor and noticed that there was no "PE" signature, but an "NE" one instead!!?

    I looked at Iczillions tuts on PE and noted that this made it an OS2 Image..........I'll keep trying.......but try have a look at the includes and includelibs for your MASM project.....that will probably have an answer......

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Doh!!.....found it

    The function can be loaded from "AVICAP32.DLL".....

    I dont know of any library to use (I couldnt get vfw32.a or its SDK counterpart to work either....) so you can link explicitely like so

    Code:
    #include <windows.h>
    
    #define VFWAPI WINAPI
    
    
    typedef HWND (VFWAPI *cCCW)(LPCWSTR,DWORD,int,int,int,int,HWND,int);
    
    int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
     LPSTR lpszArgument, int nFunsterStil)
    
    {
           HWND hWndc;
           HMODULE hMod;
           cCCW lpFunc;
    
               hMod = LoadLibrary("AVICAP32.DLL");
               if(!hMod){MessageBox(NULL,"Error - module",NULL,0);return 1;}
               lpFunc = (cCCW)GetProcAddress(hMod,"capCreateCaptureWindowW");
               if(!lpFunc){MessageBox(NULL,"Error - function",NULL,0);return 1;}
               hWndc = lpFunc((LPCWSTR) "Windows App",
                     WS_CHILD | WS_VISIBLE,0, 0, 160, 120,HWND_DESKTOP,
                     (int) 32);
    
               FreeLibrary(hMod);
    
    
    
        return 0;
    }
    Last edited by Fordy; 07-09-2002 at 05:51 AM.

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    4

    Thumbs up OK

    I'll give it a try. I think i t will work fine, because, in this case,
    you are calling the dll directly.

    I tryed also to compile my app in VC 6, at our University,
    and got the same result as in Dev-C++. The same error...

    Then, in the Project Settings -> Link, I added to the
    Object/Library modules : Vfw32.lib (The video for windows
    library of microsoft VC 6), and then I was able to compile and
    run the app.

    I think that I must supply the name of the lib file to the
    Dev-C++ linker, so it will compile fine.

    I'm going to try to find how to do it, as there is no docs about
    this IDE (Dev-C++), but it's a great compiler.

    Thank you very much for all help.

    I'll let you know if I get some result with Dev-C++.

    Sergio Aguiar

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Go to Compiler->options

    and then manually add this line to the box marked "add To Project" or something...



    "-lvfw32"

    But my Dev has the weird bug in that you have to create the project, then close it, then reopen it before doing that???!

    In dev, any library is added in this way: ie: cut off the "lib", replace with "-l", and omit the ".a" extension...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  8. #8
    Registered User
    Join Date
    Jul 2002
    Posts
    4

    Smile No way to work.

    Even making that, there's no way to make this Dev-C++
    compiler work with video for windows stuff.

    I already made the little program work with MS VC 6, but,
    the same code don't even compile with Dev-C++.

    I'll try to download an older version of Dev-C++ and maybe
    it will compile.

    This can be a very fine compiler, but, at this time, seems
    to need some more work. It's a fine piece of work, and I
    think it will be my choice in future.

    Thanks again.

    Sergio Aguiar - ssaguiar

  9. #9
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by Sebastiani
    Go to Compiler->options

    and then manually add this line to the box marked "add To Project" or something...



    "-lvfw32"

    But my Dev has the weird bug in that you have to create the project, then close it, then reopen it before doing that???!

    In dev, any library is added in this way: ie: cut off the "lib", replace with "-l", and omit the ".a" extension...
    I tried to link with 2 compilers, but I couldnt get either set of libs to work.....It seems that niether the SDK version (under VC++ - vfw.lib) or the (DevC++ convert - libvfw32.a) will allow this symbol to be linked.....

    That's why I went to the trouble of loading it at runtime....

    Maybe it can be done........but hell....using LoadLibrary is easy enough

    ssaguiar - I'm sorry you cant get it to work......I must admit that I am not used to these functions, and as soon as I got it to load I assumed that would do....

    I use Devc++ as a "tester" compiler to compare with my main toy - VC++..............

    Perhaps if you are a MASM programmer, you will feel more comfortable with VC++....IMHO its about the best you can get for windows..........and it has some similarities with MASM (Same Linker, Same Libraries)...........I'm learning MASM right now, but I started ASM coding with TASM.......the switch to MASM wasnt just because of the assembler's support on the web (which is huge), but I could easily find linker details as its the same as VC++ (for instance I needed a shared section in a DLL a while back........didnt have a clue with TLINK (TASM)....but with LINK it was pretty easy)......good luck

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem With My Box
    By HaVoX in forum Tech Board
    Replies: 9
    Last Post: 10-15-2005, 07:38 AM
  2. Codec Bitrates?
    By gvector1 in forum C# Programming
    Replies: 2
    Last Post: 06-16-2003, 08:39 AM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. Drawing a circle in a video captured frame
    By skyhigh in forum C Programming
    Replies: 2
    Last Post: 12-05-2001, 01:00 AM