흐르는 시간의 블로그...

바로 직전의 poco library의 링크 문제와 GCC5.x.x와 연관된 부분이다.

poco library를 겨우겨우 컴파일해서 넘어갔는데 이번에는 OCCI에서 문제가 다시 발생했다.


POCO Library link 이슈 - GCC 5.4.0 업버전 후 생긴 문제



이번 개발에서는 오라클과 redis를 사용한다. poco library이후 occi를 위해 두개의 패키지를 인수톨 했다.

기존에 올렸던 글을 참고해도 된다.


instant client 설치하기



설치가 완료되었고 소스에 occi 클래스를 컴파일 했다.

ubiocci.cpp:(.text+0x197e): undefined reference to `oracle::occi::Number::fromText(oracle::occi::Environment const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
ubiocci.o: In function `CUbiOcci::AddParam(unsigned long long)':


뚜둥... 어제와 같은일이 또 발생했다.

대충봐도. std::__cxx11::bast_string<...> 부분이 보인다.

문제를 해결하다가 멈췄던 그 지점으로 다시 돌아가본다.

오늘은 그래도 좀 사용자가 있는 오라클 이슈... 나름 답이 쉽게 나온다.

OCCI linkage error with gcc 5

poco library 문제를 검색했을때도 나왔던 그 문구가 다시 나온다.
-D_GLIBCXX_USE_CXX11_ABI=0


define과 관련된 내용은.. 이리로 넘어간다.

Dual ABI

Application binary interface


다 찾아서 읽어보고 이해하라고 하면 나도 안하기 때문에...

나름 이해한바를 적어보면 아래와 같다.

SW분야에서 Application binary interface는 OS나 library간의 기계어 코드레벨의 인터페이스이다. ABI는 함수가 어떻게 호출되는지 하나의 프로그램 컴포넌트에서 다른 쪽으로 binary format information이 넘어가는지를 혹은 시스템 콜에 어떻게 반응하는지를 걸정한다. ABI는 보통 컴파일러, OS나 라이브러리 제작자 혹은 여러 프로그래밍 언어를 섞어서 다른 언어의 함수를 호출하는 것을 개발하는 개발자의 몫이다. API와 유사하지만 API는 소스 코드 레벨에서 이루어지고 ABI는 프로그램 컴포넌트간의 인터페이스이다.


ABI는 아래와 같은 상세한 것들을 포함한다.(해석하기 뭣해서 걍 위키피디아 붙임)

  • the sizes, layout, and alignment of data types
  • the calling convention, which controls how functions' arguments are passed and return values retrieved; for example, whether all parameters are passed on the stack or some are passed in registers, which registers are used for which function parameters, and whether the first function parameter passed on the stack is pushed first or last onto the stack
  • how an application should make system calls to the operating system and, if the ABI specifies direct system calls rather than procedure calls to system call stubs, the system call numbers
  • and in the case of a complete operating system ABI, the binary format of object files, program libraries and so on


GCC 5.1릴리즈는 std::string과 std::list의 새로운 구현을 포함한 새로운 라이브러리 ABI를 소개했다. C++11의 표준에 따른 작업이었다. 이미 존재하는 라이브러리에 대한 역호환성을 위해 ABI를 선택할 수 있도록 했다. 이것은 링크에서 다른 이름을 가지도록 인라인으로 define함으로써 가능하다. 예를 들어 새버전의 std::lst<int>는 실제로 std::__cxx11:list<int>로 정의한다.


_GLIBCXX_USE_CXX11_ABI 매크로는 라이브러리 헤더의 어떤 ABI를 선택할지 조정할 수 있다. GCC의 기본값은 1로 새로운 ABI를 사용하는 것이다. 기존의 라이브러리를 사용할 것이라면 어떤 라이브러리 헤더를 include 하기전에 매크로를 0으로 해야 한다. -std옵션은 ABI를 선택하지 않는다. 그래서 C++03과 C++11 코드를 함께 링크 할 수 있다.


컴파일시 -Wabi-tag 옵션을 통해 알 수 있다.


위의   OCCI linkage error with gcc 5  에서 나오듯이 일부 라이브러리만 이 옵션을 적용하게 할 방법은 없어 보인다. 모든 라이브러리는 동일한 ABI로 컴파일되어야 함께 동작이 가능하다. 

따라서 occi의 소스가 나에게 없으므로 결국 poco 라이브러리를 4.x.x gcc로 컴파일한 이후 -D_GLIBCXX_USE_CXX11_ABI=0를 통해 개발을 진행할 것이다.