16

I have a program that uses libav. It works well when compiled in Debug mode (Windows, VisualStudio 2010). However, when the program is compiled in Release mode, it crashes in av_register_all. The exception I get is Privileged Instruction.

Anyone has an idea if there is anything special that needs to be done in Release mode to get libav to work?

Best regards Ran

ranyakir
  • 161
  • 1
  • 3
  • Do you dynamically like `libav*` libraries (e.g. `libavcodec-54.dll`)? – Roman R. Aug 07 '12 at 08:55
  • Thanks for answering.Yes. I link with the dynamic libraries. – ranyakir Aug 08 '12 at 07:28
  • So you possibly are just missing those dependencies, and hence the crash. – Roman R. Aug 08 '12 at 08:30
  • In that case what is the difference between debug and release modes? It does run well when compiled in debug mode. I am using the same paths and same libraries in both modes. – ranyakir Aug 08 '12 at 11:34
  • Not so much of a difference, but you need to gather more details: (1) if this is a crash, you need a callstack at crash time, to see your `av_register_all` on the call stack, and where exactly the crash is inside that, (2) list of process loaded modules, to make sure that dependency DLLs are loaded, and from exactly the path you expect. Because there are no such details available yet, I supposed the missing DLL to be the most likely reason. – Roman R. Aug 08 '12 at 11:38
  • 31
    Although the question was brutally closed by casperOne, I would like to update whoever is reading on the conclusion of the problem. Apparently it was a case of RTFM. I found a small note in the download page of libav (http://win32.libav.org/win32/) that says: The .lib are generated by dlltool 2.21 Note that using import libraries created by dlltool requires the linker optimization option to be set to "References: Keep Unreferenced Data (/OPT:NOREF)", otherwise the resulting binaries will fail during runtime. This isn't required when using import libraries generated by lib.exe. – ranyakir Aug 08 '12 at 18:41
  • I've just run into the same problem so muchos thanks for coming back with the solution to my problem (I'd read the same thing originally but forgotten about it by the time I came round to release mode) – PeterI Feb 06 '13 at 14:11
  • 3
    The setting is under "Linker | Optimization | References" set to "Keep Unreferenced Data (/OPT:NOREF)" – Adi Shavit Jun 24 '13 at 19:10
  • I've just run into the same problem, @ranyakir thanks for coming back with the solution to my problem !!! – Joseph Dec 06 '15 at 15:27
  • For those of you using cmake: `if (MSVC)\n set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /OPT:NOREF")\n endif()` – Chris Dec 15 '15 at 16:46

0 Answers0