วันพฤหัสบดีที่ 28 เมษายน พ.ศ. 2554

Compile/build api-example of libavcodec on window with visual c++ 2008.

This post will show, how to compile and build api-exampl.c with visual c++ 2008.

api-example.c is contained in libavcodec folder, this file show you how to use api of libavcodec.
If you can compile it on window you will get idea to use it on your window application.

An example assume, you already have dll, lib and necessary include file on your machine.

1.Create VS C++ with console application project and add api-example.cpp (change file extension form .c to .cpp) to your project.

2.At this step if you compile you will get error message about cannot open include file. you need to set include files path of your visual studio.



- D:\TSL_Project\include; contain inttypes.h and stdint.h these files aren't in VS2008.
- C:\msys\1.0\local\include; contain libavcodec and other necessary include files.

3.Modify your api-example code by
- put extern "C" keywords between include header file of ffmpeg because it come form C coding style
- define "__STDC_CONSTANT_MACROS" this will remove error about "error C3861: 'INT64_C': identifier not found"



4.At this step if you compile code you will get 2 types of error first is cannot convert pointer and second is "snprintf': identifier not found". You need to fix it by.

- For pointer type you can convert it manually by yourself.
- For snprintf you need to use _snprintf instead.

5.At this step you can compile without error, BUT when you build project you will get a error like "unresolved external symbol" , because you still not set linker to your project.

- Add lib directory to VS2008



- Add lib to linker input



6.After add linker you can completely build your project BUT!!! it still not complete process to run your application,

You can build your project without error but you cannot launch your application because you don't have ".dll" in your directory so let's copy it all and paste to your directory and it will work :) .

ไม่มีความคิดเห็น: