Asterisk-12.2.0 compile error in FreeBSD-10

아래 내용들은 GCC49 버전으로 컴파일 했을 때 발생한 에러들이다.

GCC46 버전으로 컴파일 시, 다른 에러들이 발생할 수 있다. 가급적 최신의 컴파일러를 사용하자.

Asterisk 컴파일 에러.
컴파일 중 발생한 에러로서, 참조 에러이다. 파일 수정이 필요하다.

creating config.h
[LD] abstract_jb.o acl.o adsi.o alaw.o aoc.o app.o ast_expr2.o ast_expr2f.o asterisk.o astfd.o astmm.o astobj2.o audiohook.o autochan.o autoservice.o backtrace.o bridge.o bridge_after.o bridge_basic.o bridge_channel.o bridge_roles.o bucket.o callerid.o ccss.o cdr.o cel.o channel.o channel_internal_api.o chanvars.o cli.o config.o config_options.o core_local.o core_unreal.o crypt.o data.o datastore.o db.o devicestate.o dial.o dns.o dnsmgr.o dsp.o endpoints.o enum.o event.o features.o features_config.o file.o fixedjitterbuf.o format.o format_cap.o format_pref.o frame.o framehook.o fskmodem.o global_datastores.o hashtab.o heap.o http.o image.o indications.o io.o jitterbuf.o json.o loader.o lock.o logger.o manager.o manager_bridges.o manager_channels.o manager_endpoints.o manager_mwi.o manager_system.o md5.o media_index.o message.o mixmonitor.o named_acl.o netsock.o netsock2.o optional_api.o parking.o pbx.o pickup.o plc.o poll.o presencestate.o privacy.o rtp_engine.o say.o sched.o sdp_srtp.o security_events.o sem.o sha1.o sip_api.o slinfactory.o sorcery.o sounds_index.o srv.o stasis.o stasis_bridges.o stasis_cache.o stasis_cache_pattern.o stasis_channels.o stasis_endpoints.o stasis_message.o stasis_message_router.o stasis_system.o stdtime/localtime.o strcompat.o strings.o stun.o syslog.o taskprocessor.o tcptls.o tdd.o term.o test.o threadpool.o threadstorage.o timing.o translate.o udptl.o ulaw.o utils.o uuid.o version.o xml.o xmldoc.o editline/libedit.a  -> asterisk
ast_expr2.o: In function `op_func’:
/usr/local/src/asterisk-12.2.0/main/ast_expr2.y:884: warning: powl has lower than advertised precision
/usr/local/bin/ld: asterisk: local symbol `__progname’ in /usr/lib/crt1.o is referenced by DSO
/usr/local/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
gmake[2]: *** [asterisk] Error 1
gmake[1]: *** [main] Error 2
gmake[1]: Leaving directory `/usr/local/src/asterisk-12.2.0′
*** Error code 2

Stop.
make: stopped in /usr/local/src/asterisk-12.2.0

해결책은 해당 에러가 난 후에, main/asterisk.exports 파일에 다음의 패치 내용을 적용해주면 된다.

--- /usr/ports/net/asterisk/work/asterisk-1.8.11.0/main/asterisk.exports        2012-04-01 11:19:50.532808549 -0700
+++ /root/asterisk.exports      2012-04-01 10:43:28.258979089 -0700
@@ -44,6 +44,8 @@
res_srtp;
res_srtp_policy;
secure_call_info;
+               __progname;
+               environ;
local:
*;
};

 

 

spandsp 모듈 에러.
spandsp 모듈은 FAX 관련 모듈로 설치시 다음과 같은 오류가 발생했다.

   [CC] res_speech.c -> res_speech.o
[LD] res_speech.o -> res_speech.so
[CC] res_fax_spandsp.c -> res_fax_spandsp.o
res_fax_spandsp.c: In function ‘spandsp_v21_new’:
res_fax_spandsp.c:470:52: error: ‘MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE’ undeclared (first use in this function)
p->tone_state = modem_connect_tones_rx_init(NULL, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, spandsp_v21_tone, p);
^

문제의 원인은 낮은 버전의 라이브러리를 설치했기 때문이었다. 내가 설치했던 spandsp 패키지에서 제공하는 헤더파일에는 “MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE” 선언이 없었던 것.
이미 Asterisk 를 설치한 다른 시스템에서 해당 헤더파일을 비교한 후에야 문제를 해결할 수 있었다.
해당 선언이 들어있는 패키지는 spandsp-devel 패키지이다.
그냥 설치하려고 하면 의존성 문제가 발생하므로 이전에 설치한 패키지를 지우고 새로 설치하도록 하자.

pkg delete spandsp
pkg install spandsp-devel

 

참조 : http://forums.asterisk.org/viewtopic.php?f=1&t=81017

————————————————————————–

 

하지만 make install 과정에서 asterisk.h 파일을 찾을 수 없다는 에러만 계속 나왔다.

결국 적당한 시점에서 타협을 해야 했는데.. 그냥 pkg 에 올려져 있는 asterisk 를 사용하기로 했다.

설치한 asterisk 버전은 11.8.1 이다.

Upgrade openssl-1.0.1 on Debian 6

Freeswitch 를 설치하는데 openssl-1.0 이상 버전을 요구했다.

현재 운용중인 서버 버전은 Debian-6.0
apt-get 으로 설치 가능한 openssl 버전은 0.9.x 버전이었다.

 

즉, openssl 버전 문제로 정상적인 설치가 안되는 상황.
openssl 최신버전이야 소스 설치를 하면 되겠는데.. 문제는 이미 사용중인 openssl-0.9.x 버전은 어떻게 하느냐였다.
이미 많은 수의 패키지들이 라이브러리를 참조하고 있었다.
실제로 apt-get remove 명령어로 해당 패키지를 지워볼까 생각도 했는데, 의존성 문제로 상당히 많은 수의 패키지들을 같이 지워야 해서 관두었다.

어쩔까…
Linux HanIRC 채널에 문의를 해보니 다행히 답변이 나왔다.

그냥 덮어쓰면 된다는 것.

 wget http://openssl.org/source/openssl-1.0.1.tar.gz 
 tar xfz openssl-1.0.1.tar.gz 
 cd openssl-* 
 ./config --prefix=/usr zlib-dynamic --openssldir=/etc/ssl shared 
 make 
 sudo make install

 

출처 : http://mariobrandt.de/archives/linux/upgrading-openssl-on-debian-6-squeeze-or-ubuntu-8-04-hardy-456

Could not get python modules list…

사용가능한 Python 모듈들을 알아보기 위해 python 인터프리터에서 전체 모듈보기 명령어를 입력했는데, 다음과 같은 오류 메시지를 확인했다.

pchero@MyDebian:/usr/lib/pymodules/python2.7$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help('modules')

Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
/usr/lib/python2.7/dist-packages/gi/module.py:142: Warning: cannot register existing type `GtkWidget'
  g_type = info.get_g_type()
/usr/lib/python2.7/dist-packages/gi/module.py:142: Warning: cannot add class private field to invalid type '<invalid>'
  g_type = info.get_g_type()
/usr/lib/python2.7/dist-packages/gi/module.py:142: Warning: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
  g_type = info.get_g_type()
/usr/lib/python2.7/dist-packages/gi/module.py:142: Warning: cannot register existing type `GtkBuildable'
  g_type = info.get_g_type()
/usr/lib/python2.7/dist-packages/gi/module.py:142: Warning: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed
  g_type = info.get_g_type()
/usr/lib/python2.7/dist-packages/gi/module.py:142: Warning: g_once_init_leave: assertion `result != 0' failed
  g_type = info.get_g_type()
/usr/lib/python2.7/dist-packages/gi/module.py:146: Warning: g_type_get_qdata: assertion `node != NULL' failed
  type_ = g_type.pytype

그리고 Hang 이 걸린듯 더이상 진행되지 않았다.

해결법을 찾던 도중, http://blog.rabbitvcs.org/archives/312 에서 비슷한 현상에 대한 해결법을 찾았는데 뭔가 완벽하진 않았다.
http://stackoverflow.com/questions/13301100/python-fail-to-display-list-of-modules 여기도 역시…
내용인 즉, help(‘modules’) 를 입력하기 전에 gtk 모듈을 먼저 load 하라는 것인데.. 깔끔하지 않았다.

pchero@MyDebian:/etc$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
>>> 
>>> 
>>> help('modules')

Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.7/dist-packages/keybinder/__init__.py:26: GtkWarning: IA__gdk_keymap_get_for_display: assertion `GDK_IS_DISPLAY (display)' failed
  from _keybinder import *
/usr/lib/python2.7/dist-packages/keybinder/__init__.py:26: GtkWarning: IA__gdk_screen_get_root_window: assertion `GDK_IS_SCREEN (screen)' failed
  from _keybinder import *

** (.:7702): WARNING **: keybinder_init: Unable to open display
ANSI                _codecs_iso2022     fdpexpect           pyatspi
ArgImagePlugin      _codecs_jp          feedparser          pyclbr
BaseHTTPServer      _codecs_kr          filecmp             pycurl
Bastion             _codecs_tw          fileinput           pydoc
BdfFontFile         _collections        fnmatch             pydoc_data
BeautifulSoup       _csv                formatter           pyexpat
BeautifulSoupTests  _ctypes             fpconst             pygtk
BmpImagePlugin      _ctypes_test        fpectl              pynotify
BufrStubImagePlugin _curses             fpformat            quopri
CDROM               _curses_panel       fractions           random
CGIHTTPServer       _dbus_bindings      freeswitch          re
Canvas              _dbus_glib_bindings ftplib              readline
ConfigParser        _elementtree        functools           reportbug
ContainerIO         _functools          future_builtins     reportlab
Cookie              _hashlib            gc                  repr
CurImagePlugin      _heapq              gconf               resource
DLFCN               _hotshot            genericpath         rexec
DcxImagePlugin      _imaging            getopt              rfc822
Dialog              _imagingcms         getpass             rlcompleter
DocXMLRPCServer     _imagingft          gettext             robotparser
EpsImagePlugin      _imagingmath        gi                  runpy
ExifTags            _io                 gio                 scanext
FSM                 _json               glib                sched
FileDialog          _locale             glob                screen
FitsStubImagePlugin _lsprof             gnome               select
FixTk               _multibytecodec     gnome_sudoku        serial
FliImagePlugin      _multiprocessing    gnomecanvas         sets
FontFile            _pyio               gnomevfs            setuptools
FpxImagePlugin      _random             gobject             sgmllib
GbrImagePlugin      _renderPM           grp                 sgmlop
GdImageFile         _rl_accel           gtk                 sha
GifImagePlugin      _socket             gtkunixprint        shelve
GimpGradientFile    _sqlite3            gtweak              shlex
GimpPaletteFile     _sre                gzip                shutil
GnuPGInterface      _ssl                hamster             signal
GribStubImagePlugin _strptime           hashlib             site
HTMLParser          _struct             heapq               sitecustomize
Hdf5StubImagePlugin _symtable           hmac                smtpd
HelloModule         _sysconfigdata      hotshot             smtplib
IN                  _sysconfigdata_nd   hpmudext            sndhdr
IcnsImagePlugin     _testcapi           htmlentitydefs      socket
IcoImagePlugin      _threading_local    htmllib             softwareproperties
ImImagePlugin       _warnings           httplib             speechd
Image               _weakref            httplib2            speechd_config
ImageChops          _weakrefset         ihooks              spwd
ImageCms            abc                 imaplib             sqlite3
ImageColor          aifc                imghdr              sre
ImageDraw           antigravity         imp                 sre_compile
ImageDraw2          anydbm              importlib           sre_constants
ImageEnhance        apt                 imputil             sre_parse
ImageFile           apt_inst            inspect             ssl
ImageFileIO         apt_pkg             invest              starpy
ImageFilter         aptdaemon           io                  stat
ImageFont           aptsources          itertools           statvfs
ImageGL             argparse            json                string
ImageGrab           array               keybinder           stringold
ImageMath           ast                 keyword             stringprep
ImageMode           asynchat            lib2to3             strop
ImageOps            asyncore            libxml2             struct
ImagePalette        atexit              libxml2mod          subprocess
ImagePath           atk                 linecache           sunau
ImageQt             audiodev            linuxaudiodev       sunaudio
ImageSequence       audioop             locale              symbol
ImageShow           axi                 logging             symtable
ImageStat           base64              louis               sys
ImageTransform      bdb                 lsb_release         sysconfig
ImageWin            binascii            macpath             syslog
ImtImagePlugin      binhex              macurl2path         tabnanny
IptcImagePlugin     bisect              mailbox             tarfile
JpegImagePlugin     bonobo              mailcap             telnetlib
McIdasImagePlugin   brlapi              mako                tempfile
MicImagePlugin      bsddb               markupbase          termios
MimeWriter          bz2                 markupsafe          test
MpegImagePlugin     cPickle             marshal             test1
MspImagePlugin      cProfile            math                textwrap
ORBit               cStringIO           md5                 this
OleFileIO           cairo               mhlib               thread
OpenSSL             calendar            mimetools           threading
PAM                 caribou             mimetypes           tidy
PIL                 cgi                 mimify              time
PSDraw              cgitb               mmap                timeit
PaletteFile         chardet             mod_fstest          tkColorChooser
PalmImagePlugin     chunk               mod_test            tkCommonDialog
PcdImagePlugin      cmath               modulefinder        tkFileDialog
PcfFontFile         cmd                 multifile           tkFont
PcxImagePlugin      code                multiprocessing     tkMessageBox
PdfImagePlugin      codecs              mutex               tkSimpleDialog
PixarImagePlugin    codeop              netrc               toaiff
PngImagePlugin      collections         new                 token
PpmImagePlugin      colorsys            nis                 tokenize
PsdImagePlugin      commands            nntplib             trace
Queue               compileall          ntpath              traceback
SOAPpy              compiler            nturl2path          ttk
ScrolledText        contextlib          numbers             tty
SgiImagePlugin      cookielib           numpy               turtle
SimpleDialog        copy                opcode              twisted
SimpleHTTPServer    copy_reg            operator            types
SimpleXMLRPCServer  crypt               optparse            unicodedata
SocketServer        csv                 orca                unittest
SpiderImagePlugin   ctypes              os                  uno
StringIO            cupsext             os2emxpath          unohelper
SunImagePlugin      curl                ossaudiodev         urllib
TYPES               curses              packagekit          urllib2
TarIO               datetime            pango               urlparse
TgaImagePlugin      dbhash              pangocairo          user
TiffImagePlugin     dbm                 parser              uu
TiffTags            dbus                pcardext            uuid
Tix                 deb822              pdb                 vte
Tkconstants         debconf             pexpect             warnings
Tkdnd               debian              pickle              wave
Tkinter             debian_bundle       pickletools         weakref
UserDict            debianbts           pip                 webbrowser
UserList            decimal             pipes               whichdb
UserString          defer               pkg_resources       wnck
WalImageFile        difflib             pkgutil             wsgiref
WmfImagePlugin      dircache            platform            xapian
XVThumbImagePlugin  dis                 plistlib            xdg
XbmImagePlugin      distutils           popen2              xdrlib
XpmImagePlugin      doctest             poplib              xml
_LWPCookieJar       drv_libxml2         posix               xmllib
_MozillaCookieJar   dsextras            posixfile           xmlrpclib
__builtin__         dumbdbm             posixpath           xxsubtype
__future__          dummy_thread        pprint              zeitgeist
_abcoll             dummy_threading     profile             zipfile
_ast                easy_install        pstats              zipimport
_bisect             email               pty                 zlib
_bsddb              encodings           pwd                 zope
_codecs             errno               pxssh               
_codecs_cn          exceptions          pyHnj               
_codecs_hk          fcntl               py_compile          

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose descriptions contain the word "spam".

[FreeBSD] Network configure

시스템 부팅시 자동으로 NIC 에 IP 를 할당하고 싶다면 /etc/rc.conf 파일을 이용한다.

rc.conf 설정 예제.

root@FBSD10:/etc # vi rc.conf 

hostname="FBSD10"
#ifconfig_em0="DHCP"
ifconfig_em0="10.0.2.16/24"
ifconfig_em0_ipv6="inet6 accept_rtadv"
sshd_enable="YES"
ntpd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"

# Set for em1
ifconfig_em1="192.168.200.12/24"

# Set for em2
ifconfig_em2="192.168.201.12/24"

# Default route gateway
defaultrouter="10.0.2.2"

 

rc.conf 파일은 NIC 설정외에도 다양한 기능들을 지원한다. 리눅스의 /etc/rc.local 파일을 생각하면 되겠다.
이보다 더 자세한 옵션들을 보고 싶다면..

$ man rc.conf

 

/etc/rc.conf 파일 설정 이후, 재부팅없이 네트워크를 Up/Down/Restart 를 해야 한다면 다음을 활용하자.

Netowrk Restart

$ /etc/rc.d/netif restart

Network Down

$ /etc/rc.d/netif stop

Network Up

$ /etc/rc.d/netif start

 

Routing Table 도 마찬가지로 조작이 가능하다.

Network routing table Restart

$ /etc/rc.d/routing restart

 

출처 : http://www.cyberciti.biz/tips/freebsd-how-to-start-restart-stop-network-service.html

lsof anon_inode

사내에서 개발한 리눅스 플랫폼 프로그램을 테스팅하면서 File descriptor 를 감시해야 하는 경우가 생겼다.

Socket 을 열고 정상적으로 종료를 하는지 확인하는 내용이었는데.. 이를 위해서 lsof 유틸리티를 사용했다.

$ lsof -p [PID] | wc -l

의 명령어로 갯수를 확인하면서 open file descriptor 수를 감시했다.

그러던 중, lsof 의 결과 출력을 분석했는데 이상한 것이 있었다.

cbapid  5560 root    3u  0000                0,7        0       521 anon_inode
cbapid  5560 root    4u  0000                0,7        0       521 anon_inode
cbapid  5560 root    5r  0000               0,11        0 271110595 eventpoll
cbapid  5560 root    6u  0000                0,7        0       521 anon_inode
cbapid  5560 root    7r  0000               0,11        0 271110596 eventpoll
cbapid  5560 root    8u  0000                0,7        0       521 anon_inode
cbapid  5560 root    9u  0000                0,7        0       521 anon_inode
cbapid  5560 root   10r   CHR                1,9      0t0  97762892 /dev/urandom
cbapid  5560 root   11r  0000               0,11        0 271110599 eventpoll

anon_inode 와 같이 나타난 file descriptor 들이 많이 있는 것을 확인한 것이다.

anon_inode 가 무엇이고 왜 나타나는 것일까?

해답은 다음과 같다.

anon_inode 는 anonymouse_inode 의 약자이며, epoll 을 사용할 경우, 감시대상 file descriptor 들을 관리하기 위해서 생성하고 사용하는 file descriptor 인 것이다.
즉, 내부적으로 epoll 을 사용하는 library 가 있다면 나타나는 정상적인 현상인 것이다.

참조 :  http://stackoverflow.com/questions/8170902/why-is-the-jdk-nio-using-so-many-anon-inode-file-descriptors