본문 바로가기

How to Build

VLS 컴파일

이번에는 vls-0.5.6을 컴파일 하였습니다.

[작업환경]
* RHEL5-2.6.21.5
* 컴파일러 버젼: gcc-4.1.1
* 참조페이지
http://forum.videolan.org/viewtopic.php?t=16753 (vls 0.5.6 linux-gcc 3.4 patch 관련)
http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2004-October/042903.html (vls 0.5.6 freebsd-gcc 3.4 fix patch 관련)

---------------------------------------------------------
1. 우선 vls-0.5.6을 다운받아서 설치합니다.

http://download.videolan.org/pub/videolan/vls/0.5.6/contrib/ (모듈)
http://download.videolan.org/pub/videolan/vls/0.5.6/ (vls-프로그램)

* 모듈을 다운받아서 설치합니다.
libdvb-0.2.2 : make & make install
libdvbpsi3-0.1.4 / libdvdcss-1.2.8 / libdvdread-0.9.4 : ./configure && make && make install

* vls를 컴파일 하여 설치합니다.
./configure && make && make install

주의!!
make 할 경우 make 규칙이 없다면서 make 되지 않을 때도 있습니다. 이럴경우 Makefile.dep 와 Makefile.module.dep 파일을 수정해 줍니다.

(수정전)
Makefile.dep
$(DEP): dep/%.dpp: src/%.cpp
        @test -d dep/$(dir $*) || mkdir -p dep/$(dir $*)
        @echo "Generating dependancies for $<..."
        @$(SHELL) -ec '$(CXX) $(DCFLAGS) $(INCLUDE) $< \
        | sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/src\/$(subst /,\/,$*).o \
        dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
        [ -s $@ ] || rm -f $@'

$(C_DEP): dep/%.d: src/%.c
        @test -d dep/$(dir $*) || mkdir -p dep/$(dir $*)
        @echo "Generating dependancies for $<..."
        @$(SHELL) -ec '$(CC) $(DCFLAGS) $(INCLUDE) $< \
        | sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/src\/$(subst /,\/,$*).o \
        dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
        [ -s $@ ] || rm -f $@'

Makefile.module.dep
$(MODULE_DEP): dep/%.d: %.cpp
        @test -d dep/$(dir $*) || mkdir -p dep/$(dir $*)
        @echo "Generating dependancies for $<..."
        @$(SHELL) -ec '$(CXX) $(DCFLAGS) $(MODULE_DCFLAGS) $(INCLUDE) $< \
        | sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/$(subst /,\/,$*).o \
        dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
        [ -s $@ ] || rm -f $@'

(수정후)
Makefile.dep
$(DEP): dep/%.dpp: src/%.cpp
        @test -d dep/$(dir $*) || mkdir -p dep/$(dir $*)
        @echo "Generating dependancies for $<..."
        @$(SHELL) -ec '$(CXX) $(DCFLAGS) $(INCLUDE) $< \
        | sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/src\/$(subst /,\/,$*).o \ dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
        [ -s $@ ] || rm -f $@'

$(C_DEP): dep/%.d: src/%.c
        @test -d dep/$(dir $*) || mkdir -p dep/$(dir $*)
        @echo "Generating dependancies for $<..."
        @$(SHELL) -ec '$(CC) $(DCFLAGS) $(INCLUDE) $< \
        | sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/src\/$(subst /,\/,$*).o \ dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
        [ -s $@ ] || rm -f $@'

Makefile.module.dep
$(MODULE_DEP): dep/%.d: %.cpp
        @test -d dep/$(dir $*) || mkdir -p dep/$(dir $*)
        @echo "Generating dependancies for $<..."
        @$(SHELL) -ec '$(CXX) $(DCFLAGS) $(MODULE_DCFLAGS) $(INCLUDE) $< \
        | sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/$(subst /,\/,$*).o \ dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
        [ -s $@ ] || rm -f $@'

하지만 이렇게 수정하고 나서도 다음과 같이 오류가 나면서 컴파일이 되지 않는 경우도 있습니다.
그럴경우에는 Makefile, src/core/hashtable.h, src/core/library.cpp, src/core/stream.cpp 를 다음과 같이 수정해 줍니다.

# make
Generating dependancies for src/core/application.cpp...
Compiling src/core/application.cpp...
g++ -Wall -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DCONFIG_PATH='"/usr/local/etc/videolan/vls"' -DBUGGY_VLC -DYY_NO_UNPUT -DSYSLOG -o obj/core/application.o -c src/core/application.cpp
In file included from src/core/application.cpp:97:
src/core/hashtable.h:67: error: an explicit specialization must be preceded by 'template <>'
src/core/hashtable.h:80: error: an explicit specialization must be preceded by 'template <>'
src/core/hashtable.h:93: error: an explicit specialization must be preceded by 'template <>'
In file included from src/core/application.cpp:113:
src/core/library.cpp: In member function `void C_Library<Type, Arg>::Load()':
src/core/library.cpp:82: error: `DL_LAZY' undeclared (first use this function)
src/core/library.cpp:82: error: (Each undeclared identifier is reported only once for each function it appears in.)
src/core/library.cpp:93: error: there are no arguments to `dlsym' that depend on a template parameter, so a declaration of `dlsym' must be available
src/core/library.cpp:93: error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
src/core/library.cpp:110: error: there are no arguments to `dlsym' that depend on a template parameter, so a declaration of `dlsym' must be available
src/core/library.cpp: In member function `void C_Library<Type, Arg>::Unload()':
src/core/library.cpp:133: error: there are no arguments to `dlclose' that depend on a template parameter, so a declaration of `dlclose' must be available
src/core/library.cpp: In member function `C_String C_Library<Type, Arg>::GetLoaderError()':
src/core/library.cpp:177: error: there are no arguments to `dlerror' that depend on a template parameter, so a declaration of `dlerror' must be available
make: *** [obj/core/application.o] Error 1


* Makefile
################################################################################
# Common options
################################################################################

LCFLAGS += $(VLS_LCFLAGS)
다음줄을 추가합니다.
CFLAGS += -fpermissive

* src/core/hashtable.h
class C_HashMethod<u32> 을 다음과 같이 수정합니다. (66번째 줄)
template <> class C_HashMethod<u32>

class C_HashMethod<u16> 을 다음과 같이 수정합니다. (79번째 줄)
template <> class C_HashMethod<u16>

class C_HashMethod<handle> 을 다음과 같이 수정합니다. (92번째 줄)
template <> class C_HashMethod<handle>

* src/core/library.cpp
(30번째 줄)
//------------------------------------------------------------------------------
// Preamble
//------------------------------------------------------------------------------
// There is no preamble since this file is to be included in the files which
// use the template: look at vector.h for further explanation
다음 줄을 추가합니다.
 #include <dlfcn.h>

(79번째 줄)
# ifdef RTLD_NOW
  m_hHandle = dlopen(m_strName.GetString(), RTLD_NOW);
# else
  m_hHandle = dlopen(m_strName.GetString(), DL_LAZY); 을 다음과 같이 수정합니다.
  m_hHandle = dlopen(m_strName.GetString(), RTLD_LAZY);
# endif

* src/core/stream.cpp
(317번째 줄부터)
template <class IOStream>
 C_Stream<IOStream>& C_Stream<IOStream>::operator >> (C_Serializable& cObject)
{
다음 두 줄을 추가합니다.
C_ClassDescription cObjectDescription = cObject.Reflect();
C_Serializer cSerializer(&cObject, cObjectDescription);
  try
  {
    u32 iByteCount = cSerializer.NextBytesCount();
    while(iByteCount > 0)
    {
      const byte aBytes[iByteCount];
      u32 iOffset = 0;
다음 줄을 추가합니다.
      int iRc;

      // Read the data to deserialize on the stream
      do
      {
        int iRc = m_pIOStream->Read(aBytes+iOffset, iByteCount-iOffset); 를 다음과 같이 수정합니다.
        iRc = m_pIOStream->Read(aBytes+iOffset, iByteCount-iOffset);
        ASSERT(iRc >= 0 || iRc == FILE_EOF);
        iOffset += iRc;
      }

이제 make를 합니다.

# make && make install
정상적으로 vls가 설치되는 것을 확인할 수 있습니다.

[출처] VLS 컴파일|작성자 아스라다