intelliproject logo

Location: Desktop development - C/C++    License: The Intelliproject Open License (IPOL)

How to compile Xvid with Microsoft Visual C++

Posted by Silviu Caragea

Describes how to compile Xvid with Microsoft Visual C++

Skill: Advanced

Posted: 22/11/2008

Views: 3649

Rating: 5.00 /5

Popularity: 0.00

Sign Up to vote for this article

Introduction

With some time ago I had to use Xvid in an intelligent mobile video real-time surveillance system, to compress frames before sending them over the sockets.

I spend over two hours to compile the sources because Xvid depends on a number of libraries and programs that do not come with Microsoft Visual Studio.

In this tutorial I will use Microsoft Visual Studio 2003 but in large part the instructions are the same.

Downloading necessary files

1.NASM

The Netwide Assembler, NASM, is an 80x86 and x86-64 assembler designed for portability and modularity. It supports a range of object file formats, including Linux and *BSD a.out, ELF, COFF, Mach-O, Microsoft 16-bit OBJ, Win32 and Win64. It will also output plain binary files. Its syntax is designed to be simple and easy to understand, similar to Intel's but less complex. It supports all currently known x86 architectural extensions, and has strong support for macros.

Xvid use NASM to compile the code written in assembly language (*.asm files).

You can download Win32 NASM binary files from http://sourceforge.net/projects/nasm/

2.DirectX 9.0 SDK

Microsoft DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with Direct, such as Direct3D, DirectDraw, DirectMusic, DirectPlay, DirectSound, and so forth. DirectX, then, was the generic term for all of these APIs and became the name of the collection.

You need DirectX to build the DirectShow filters used in Xvid.

Download Microsoft Directx from: here

3. Pthreads for Win32 (optional)

You will need the pthreads library if you want to build the SMP version of the Xvid. SMP version of the XVid is used when you have dual processing systems.

Installing and Configuring downloaded files

1. Installing and configuring NASM

  • Unzip file to c:\nasm
  • Xvid expects the filename to be "nasm.exe" .If your file have another name (nasmw.exe for example) rename it to "nasm.exe"
  • Start your Visual C++ and perform the next steps:
  1. Click "Tools" item from menu and select "Options" .
  2. Click on "Projects" and select "Visual C++ directories"
  3. Select in "Show directories for" combo box the "Executable files" item.
  4. Add your NASM path here (in my case "c:\nasm")

nasm_dir.JPG

2) Installing and Configuring the DirectX SDK

The DirectX SDK comes with an installer very easy to use. Next... Next... finish and you are ready to use it .

To configure the DirectX SDK:

  1. Start your Visual C++
  2. Click "Tools" item from menu and select "Options".
  3. Click on "Projects" and select "Visual C++ directories"
  4. Select in "Show directories for" combo box the "Include files" item.
  5. Add the following entry to the top of the list: "<path to DirectX SDK>\SAMPLES\C++\DIRECTSHOW\BASECLASSES" where you replace <path to DirectX SDK> with the actual path to the DirectX SDK (in my example, "C:\DXSDK").

Compiling the Xvid sources

Click on the workspace file, and make sure you build the xvidcore first.

You might be surprise that you have some fatal errors like those:

libxvidcore_static error: more than one input
file specified

libxvidcore_static error PRJ0019: A tool
returned an error code from "Assembling c:\Documents and Settings\...\mem_transfer_mmx.asm"

libxvidcore error: more than one input file
specified

libxvidcore error PRJ0019: A tool returned an
error code from "Assembling c:\Documents and Settings\...\mem_transfer_mmx.asm"

xvid_decraw fatal error LNK1181: cannot open
input file 'xvidcore.dll.a'

xvid_bench fatal error LNK1181: cannot open
input file 'libxvidcore.lib'

xvid_decraw_static fatal error LNK1181: cannot
open input file 'libxvidcore.lib'

xvid_encraw fatal error LNK1181: cannot open
input file 'xvidcore.dll.a'

xvid_encraw_static fatal error LNK1181: cannot
open input file 'libxvidcore.lib'

Now let's solve these issues.

The command lines that XVID uses for invoking NASM aren't quoted, making it fail on any path that has spaces. Thus you must compile the project from a path that doesn't have spaces.

For example remove the Xvid sources to c:\ xvid and open again the workspace.

For each asm file in workspace follow the next steps:

  1. Right click on the file:
  2. Choose Properties -> Custom Build Step -> General
  3. For the command line click on the ... button.
  4. Change the command line from what it is presently to:
    nasm -f win32 -DPREFIX -I$(InputDir) -o "$(IntDir)\$(InputName).obj" "$(InputPath)"

Thant's it!

We have compiled Xvid in Visual Studio 2003.

License

This article, along with any associated source code and files, is licensed under The Intelliproject Open License (IPOL)

About the author

Silviu Caragea

Silviu Caragea is the Founder, Administrator and Chief Editor who wrote and runs The IntelliProject.

He's been programming since 2000 and now he's student at The Faculty of Economic Cybernetics, Statistics and Informatics from Bucharest. In the same time he's working as software developer at Cratima Software, a Romanian software and web design company that activates both on the local and foreign market, providing its customers with software development services, internet and intranet solutions, web design, graphic design and IT consultancy.

His programming experience includes:
- C,C++, Visual C++(Win32 API, MFC, ADO, STL, DAO, ODBC, ATL, COM, DirectShow, DirectDraw, WTL)
- Open Source libraries :CURL & Boost
- HTML, CSS
- Java (SE,ME)
- JavaScript, Ajax, Google Web Toolkit (GWT)
- Php, MySQL
-Oracle, PL SQL
- C# .NET
-Objective C, IPhone SDK, Cocoa

Location: Romania
Ocupation: Software Engineer
Home page: http://www.intelliproject.net

Sign up to post message on the article message board!