지풍@blog

지풍@blog RSS

간혹 컴파일에 따라 아래와 같이 오류를 맽으면서 컴파일이 안 되는 경우가 발생합니다


undefined reference to `clock_getres'

collect2: ld returned 1 exit status


컴파일에 따라 RT library를 기본 포함하느냐 마느냐에 따라 위와 같이 오류가 발생합니다


-lrt를 추가해서 같이 컴파일 해주면 오류 없이 컴파일을 되는 것을 확인 할 수 있습니다


출처 : http://stackoverflow.com/questions/922492/use-of-clock-getres-newbie-linux-c

간혹 개발 서버를 재 설치 이후에 컴파일을 하면 아래와 같이 math 라이브러리를 못 찾는 다는 오류가 뜹니다

/usr/bin/ld: cannot find -lm

이럴 때는 glibc-static.x86_64 패키지를 설치 해주면 오류를 해결 할 수 있습니다

Redhat 계열은 아래와 같이 yum으로 간단히 설치 가능합니다

# yum install glibc-static.x86_64
Loaded plugins: fastestmirror, priorities, refresh-packagekit, security
Loading mirror speeds from cached hostfile
epel/metalink                                            | 5.2 kB     00:00
 * base: ftp.daum.net
 * epel: ftp.kddilabs.jp
 * extras: ftp.daum.net
 * updates: ftp.neowiz.com
PlexRepo                                                 |  951 B     00:00
base                                                     | 3.7 kB     00:00
epel                                                     | 3.9 kB     00:00
epel/primary_db                                          | 5.6 MB     00:01
extras                                                   | 3.4 kB     00:00
updates                                                  | 3.4 kB     00:00
updates/primary_db                                       | 4.5 MB     00:01
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package glibc-static.x86_64 0:2.12-1.107.el6_4.4 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch         Version                    Repository     Size
================================================================================
Installing:
 glibc-static       x86_64       2.12-1.107.el6_4.4         updates       1.4 M

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 1.4 M
Installed size: 6.5 M
Is this ok [y/N]: y
Downloading Packages:
glibc-static-2.12-1.107.el6_4.4.x86_64.rpm               | 1.4 MB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : glibc-static-2.12-1.107.el6_4.4.x86_64                       1/1
  Verifying  : glibc-static-2.12-1.107.el6_4.4.x86_64                       1/1

Installed:
  glibc-static.x86_64 0:2.12-1.107.el6_4.4

Complete!


출처 : 
http://software.intel.com/en-us/articles/error-ld-cannot-find-lm

gcc로 malloc이 들어 간 소스를 gcc로 컴파일 하면 아래와 같이 warning이 뜰 때가 있습니다

test.c:224: warning: implicit declaration of function ‘malloc’

test.c:224: warning: incompatible implicit declaration of built-in function ‘malloc’

이럴 때는 소스코드 내에 아래와 같이 헤더 파일 하나 추가시켜 주면 됩니다

#include <stdlib.h>

stdlib.h가 빠져서 이런 오류가 나올 수도 있는데, 추가하고도 warning이 나온 다면 다른 방법을 찾아 보셔야 할껍니다~

언제부터인가 몰라도 Fedora Core 나 Redhat el(CentOS 포함) 계열에서

기본설치를 하면 gcc가 설치 안 되는 어처구니 없는 현실이....

기본적으로 커널 컴파일을 하기 위해서 gcc를 설치 해야 하는데

Fedora Core 7 기본 설치 된 곳에서 gcc를 설치 방법입니다

일단 네트워크가 되는 환경이고 rpm 들은 모두 외부에서 받아 오는 것으로 했습니다

glib
rpm -Uvh ftp://ftp.sayclub.com/pub/Linux/fedora/releases/7/Fedora/x86_64/os/Fedora/glib-1.2.10-26.fc7.x86_64.rpm

kernel-header
rpm -Uvh ftp://ftp.sayclub.com/pub/Linux/fedora/releases/7/Fedora/x86_64/os/Fedora/kernel-headers-2.6.21-1.3194.fc7.x86_64.rpm

glibc-headers
rpm ftp://ftp.sayclub.com/pub/Linux/fedora/releases/7/Fedora/x86_64/os/Fedora/glibc-headers-2.6-3.x86_64.rpm

glibc-devel
rpm -Uvh ftp://ftp.sayclub.com/pub/Linux/fedora/releases/7/Fedora/x86_64/os/Fedora/glibc-devel-2.6-3.x86_64.rpm

gcc
rpm -Uvh ftp://ftp.sayclub.com/pub/Linux/fedora/releases/7/Fedora/x86_64/os/Fedora/gcc-4.1.2-12.x86_64.rpm

ncures-devel
rpm -Uvh ftp://ftp.sayclub.com/pub/Linux/fedora/releases/7/Fedora/x86_64/os/Fedora/ncurses-devel-5.6-6.20070303.fc7.x86_64.rpm

이 순서 대로 rpm을 설치 하면 기본 설치 된 곳에서도 커널 컴파일이 되도록 gcc가 설치가 됩니다

다른 배포판에서도 위 rpm 순서대로(버전은 좀 다르겠지만은요) 설치하면 gcc를 설치 할 수 있습니다

1 
분류 전체보기 (202)
내가 사는 이야기 (2)
백과사전 (89)
듣고 보는 것 (0)
세상 이야기 (1)
맛집 투어 & 여행 (0)
컴퓨터 이야기 (110)
게임 이야기 (0)
위시리스트 (0)
스포츠 이야기 (0)
영화 이야기 (0)
우하하하하 (0)

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백