|
-
November 27th, 2010, 08:15 PM
#1
Capturing stderr output from lib/dll?
I have an MFC/C++ program which is linking to the ffmpeg project. I can build the ffmpeg libs/dlls using mingw, but I can't actually debug it or step into it in any way. I'm having trouble with a specific function in the program and I can't figure out where it's erroring out. I looked at the source code and the error code returned by the function is used in several places. However the error is accompanied by a text error, which according to the project, are sent to stderr. Is there any way for me to access the stderr output of a lib/dll and print it to a file or even just the VS output window so I can figure out where it's failing and try to fix the problem?
Any help would be greatly appreciated.
Dan
-
November 29th, 2010, 04:58 AM
#2
Re: Capturing stderr output from lib/dll?
Is it a console application or a Windows application? Does it starts with main() or WinMain()?
See http://comsci.liu.edu/~murali/win32gui/Win32Apps.htm where it is said:
This type of windows application [using WinMain()] cannot use the stdio library functions that need access to stdin, stdout, and stderr. For these functions(ie printf, scanf) to work properly, you will need to create a console window(See Several Programs Below).
If this is a console application, you can redirect standard streams with freopen(). See http://blogs.msdn.com/b/ronpih/archi...29/235903.aspx
-
November 29th, 2010, 05:14 AM
#3
Re: Capturing stderr output from lib/dll?
stderr should normally go to the debug outputwindow, because (on VC at least), stderr is outputting data using OutputDebugString().
HOWEVER.
You're saying the code here is compiled with mingw, and that compiler may redirect stderr to somethign else entirely. It may require that you create a console window to actually see the output, I don't know the mingw compiler so I can't offer any actual help.
I have some experience with other compilers though and at least one of them redirects stderr by default to COM1 (which is the 'accepted' debugging output on that particular device).
Check the mingw docs to see what stderr is redirected to and how you can change it.
-
November 29th, 2010, 10:07 AM
#4
Re: Capturing stderr output from lib/dll?
Mingw uses the MS-CRT. You can use depends.exe to see which MS-CRT the ffmpeg DLL's are using. If you built it yourself using a standard Mingw install, then it's using MSVCRT.dll
gg
-
November 29th, 2010, 02:37 PM
#5
Re: Capturing stderr output from lib/dll?
OK so the app I'm running here is an MFC dialog based app, not a console app.
I honestly don't know anything about MinGW, I found some step by step instructions online for building FFmpeg in Windows and followed them.
I ran the DLLs through depends as suggested and Codeplug is right they link to MSVCRT.dll. So if that's the case how do I see the output to go somewhere? Like I said I don't care where the output goes I just need to see it so I can see why it's failing. I've looked at the output window in the VS debugger and it's not going there, so there must be something I need to do to redirect it.
Dan
-
November 29th, 2010, 10:32 PM
#6
Re: Capturing stderr output from lib/dll?
Two easiest things you could do:
1) Change ffmpeg to log to a file - just for debug'n
2) Call SetStdHandle(STD_OUTPUT_HANDLE/STD_ERROR_HANDLE) to a file handle that you create/open yourself. This will have to be done before the ffmpeg DLL is loaded. If you're using an import lib, you can achieve this using /DELAYLOAD.
gg
-
November 30th, 2010, 02:22 AM
#7
Re: Capturing stderr output from lib/dll?
Thanks everyone for your help. I searched through the ffmpeg source code and stumbled across a function which allows you to redirect it's logging functions to a callback function. With that I was able to see the error text and resolve the issue I was having. Thanks again for everything. Even though I didn't use your specific advice it did lead me down the right path.
Dan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|