Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm doing a project which requires manipulating an avi file. I want to do it in C language. I have included the vfw.h header file and the required libraries are there but the avi functions are not working. During compilation no error is shown but I cant run the program, it halts abruptly. I tried to debug. I found that as soon as AVIFileInit() function is encountered, a SIGSEGV segmentation fault occurs.

Even this code is not working:
C++
#include<windows.h>
#include <vfw.h>
#include <stdio.h>
#include <stdlib.h>

void main()
{
printf("Hello\n");
AVIFileInit();
printf("World\n")
}

This compiles without any error but when i run it, it'll only output Hello but after that it'll say "project1.exe has encountered a problem and needs to close". When I tried to debug, found that SIGSEGV segmentation fault is occuring at AVIFileInit(). Could anyone please help me resolve this situation. Why is a simple function like AVIFileInit() not working in a simple program. Where am i going wrong?
Posted
Updated 29-Jan-11 19:48pm
v2

This works like a charm:
C++
#include<windows.h>
#include <vfw.h>
#include <stdio.h>
#include <stdlib.h>

#pragma comment(lib,"Vfw32")

void main()
{
    printf("Hello\n");
    AVIFileInit();
    printf("World\n");
    AVIFileExit();
}


Update
If you are using MinGW, use dlltool[^] ,note the details about STDCALL, to generate a new import library from the dll.

Regards
Espen Harlinn
 
Share this answer
 
v3
Comments
Richard MacCutchan 30-Jan-11 8:49am    
Just what I did, and no errors. I can only assume that something else is happening on the OP's system.
Espen Harlinn 30-Jan-11 9:00am    
Checking the dll was a good thought though, it might even be corrupted ...
Chaithan 30-Jan-11 9:21am    
Thanks for the replies. I tried including the pragma. Its still not working. Its infact ignoring the #pragma comment line during compilation.
Espen Harlinn 30-Jan-11 9:28am    
try running dumpbin,http://msdn.microsoft.com/en-us/library/c1h23y6c(v=vs.71).aspx, on the dll
I have just copied your code (corrected) into a simple console app and it compiles, links and runs without error. Are you sure that the Avifil32.dll is present in the correct folder on your system?
 
Share this answer
 
Comments
Espen Harlinn 30-Jan-11 8:35am    
Good question - odd if it isn't though, when did MS last ship a version of windows that didn't include this by default?
Chaithan 30-Jan-11 9:18am    
Its present in C:\WINDOWS\SYSTEM32
Chaithan 30-Jan-11 9:25am    
Did you do it in Visual Studio?? I wonder if that has anything to do with this. I'm using CodeBlocks so its MinGW compiler.
Richard MacCutchan 30-Jan-11 11:50am    
Ah, sorry all bets are off if you are not using Visual Studio or Visual C++ Express. You may need to add some environment variable for MinGW/CodeBlocks to tell it where the libraries are.
I got Visual studio like Richard said and its working fine. A good suggestion it was to include the #pragma comment by Espen Harlinn, it saves going to the properties and including additional dependancies and all that procedure. Thank you all. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900