2014-11-26 2 views
0

C 및 C++ 프로그램은 옹스트롬 OS컴파일 C/C++ 프로그램



C Progam (board.c)에 컴파일되지

[email protected]:~/Comparison# gcc board.c -o board 
/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.7.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: this linker was not configured to use sysroots 
collect2: error: ld returned 1 exit status 


[email protected]:~/Comparison# gcc --sysroot=/usr/local board.c -o board 
board.c:1:18: fatal error: stdio.h: No such file or directory 
compilation terminated. 

[email protected]:~/Comparison# whereis stdio 
stdio: /usr/include/stdio.h 

[email protected]:~/Comparison# echo $PATH 
/mnt/data/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/include/c++/:/usr/include/:/usr/include/c++/:/usr/include/c++:/usr/include/c++/:/usr/include/c++/:/usr/include/c++/:/usr/include/:/usr/include 

위에서 볼 수 있듯이 stdio. h path는 $ PATH에서 사용할 수 있지만 gcc는 찾을 수 없습니다.


C++ Progam (beagle.cpp는) 위에서 볼 수 있듯이

using namespace std; 
#include<iostream> 
void main(){ 
    cout<<"hello world"; 
} 


는 옹스트롬 터미널

[email protected]:~/Comparison# g++ beagle.cpp -o beagle 
/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.7.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: this linker was not configured to use sysroots 
collect2: error: ld returned 1 exit status 

[email protected]:~/Comparison# g++ --sysroot=/usr/local beagle.cpp -o beagle 
beagle.cpp:2:19: fatal error: iostream: No such file or directory 
compilation terminated. 

[email protected]:~/Comparison# whereis iostream 
iostream: /usr/include/c++/iostream 

echo $PATH 
/mnt/data/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/include/c++/:/usr/include/:/usr/include/c++/:/usr/include/c++:/usr/include/c++/:/usr/include/c++/:/usr/include/c++/:/usr/include/:/usr/include 

에 C++ 프로그램을 컴파일, iostream 경로는 $의 PATH도 가능합니다 g ++은 그것을 찾을 수 없다.

+0

어디에서 크로스 컴파일러를 배치합니까? 오류 메시지에서, 그것은'/ usr/lib/...'에 보이지만'PATH'에 존재하지 않습니다. 크로스 컴파일러 위치를 다시 확인할 수 있습니까? – SSC

+0

내가 아는 한, gcc는 $ PATH에서 헤더 나 라이브러리를 찾지 않습니다. ($ PATH는 실행 파일을위한 것입니다.) 관련 환경 변수는 [here] (https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html)입니다. – molbdnilo

+0

가능한 [Linker Error : gcc] (http://stackoverflow.com/questions/16437383/linker-error-gcc) 중복 가능 –

답변

1

임의의 stdio.h 파일을 가져올 수는 없습니다. 이것은 구현의 일부이며 크로스 컴파일러의 경우 일반적으로 크로스 컴파일러 구현이 필요합니다. <iostream>과 동일합니다.

+0

나는 angstrom에 gcc와 g ++라는 기본 컴파일러를 사용하고 있습니다. 크로스 컴파일러가 아닌 것 같습니다. –

+0

SSC의 코멘트에 대한 답변으로 "크로스 컴파일러 위치가 $ PATH에 추가되었습니다"라고하셨습니다. 당신은 우리가 당신의 시스템에 관해 우리에게 말하고있는 것을 기반으로 대응하려고 노력하고 있다는 것을 이해해야합니다. 명확한 사실이 없으면 분명한 대답을 기대하지 마십시오. – MSalters

+0

위의 스크린 샷에서 알 수 있듯이 기본 컴파일러를 사용하려고합니다. 그러나 크로스 컴파일러 (SSC가 제안한대로)를 시도한 후에도 동일한 오류가 발생합니다. 하지만 기본 컴파일러에 대한 솔루션이 필요합니다. –