2009-09-17 8 views
3

어떤 이유로 든 포함 경로에 FLTK 디렉토리를 추가 할 때마다 cmath에서 많은 오류가 발생합니다. 나는 GCC 버전 4.2를 사용하고있다.cmath FLTK를 사용할 때의 오류

MAIN.CPP

#include <cmath> 

int main() 
{ 
    return 0; 
} 

**** Build of configuration Debug for project CMath Test **** 

make -k all 
Building file: ../main.cpp 
Invoking: GCC C++ Compiler 
g++ -I/usr/include/FL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp" 
In file included from ../main.cpp:1: 
/usr/include/c++/4.2/cmath:100: error: ‘::acos’ has not been declared 
/usr/include/c++/4.2/cmath:116: error: ‘::asin’ has not been declared 
/usr/include/c++/4.2/cmath:132: error: ‘::atan’ has not been declared 
/usr/include/c++/4.2/cmath:148: error: ‘::atan2’ has not been declared 
/usr/include/c++/4.2/cmath:165: error: ‘::ceil’ has not been declared 
/usr/include/c++/4.2/cmath:181: error: ‘::cos’ has not been declared 
/usr/include/c++/4.2/cmath:197: error: ‘::cosh’ has not been declared 
/usr/include/c++/4.2/cmath:213: error: ‘::exp’ has not been declared 
/usr/include/c++/4.2/cmath:229: error: ‘::fabs’ has not been declared 
/usr/include/c++/4.2/cmath:245: error: ‘::floor’ has not been declared 
/usr/include/c++/4.2/cmath:261: error: ‘::fmod’ has not been declared 
/usr/include/c++/4.2/cmath:271: error: ‘::frexp’ has not been declared 
/usr/include/c++/4.2/cmath:287: error: ‘::ldexp’ has not been declared 
/usr/include/c++/4.2/cmath:303: error: ‘::log’ has not been declared 
/usr/include/c++/4.2/cmath:319: error: ‘::log10’ has not been declared 
/usr/include/c++/4.2/cmath:335: error: ‘::modf’ has not been declared 
/usr/include/c++/4.2/cmath:354: error: ‘::pow’ has not been declared 
/usr/include/c++/4.2/cmath:376: error: ‘::sin’ has not been declared 
/usr/include/c++/4.2/cmath:392: error: ‘::sinh’ has not been declared 
/usr/include/c++/4.2/cmath:408: error: ‘::sqrt’ has not been declared 
/usr/include/c++/4.2/cmath:424: error: ‘::tan’ has not been declared 
/usr/include/c++/4.2/cmath:440: error: ‘::tanh’ has not been declared 
make: *** [main.o] Error 1 
make: Target `all' not remade because of errors. 
Build complete for project CMath Test 

g++ -v 
Using built-in specs. 
Target: x86_64-linux-gnu 
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu 
Thread model: posix 
gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7) 

사람이 뭐가 잘못 됐는지 말해 줄 수 : 다음은 샘플 프로그램과 빌드 출력은? 감사!

+0

"g ++ -v"의 출력을 시스템에 게시하십시오. –

+1

math.h가 누락 된 것 같습니다. – GManNickG

답변

3

순수한 추측이지만 어떤 경우에도 /usr/include/FL에 'math.h'헤더가 있습니까? 또는 거기에 cmath에 포함 된 다른 헤더가 있습니까?

... 약간의 시간이 경과 ...]

여전히 추측하지만, 코멘트 "그래, 거기? - 무슨 일이 일어나고 있는지"주어진, 난 더 '수학이 없다는 것을 추측합니다 .h '헤더가있는/usr/include - GCC (G ++)가있는 경우 일반적으로' '와 같은 위치에서 픽업하기 때문입니다. 그래서, 나는/usr/include 아래에 설치된 소프트웨어 헤더를 점검 할 것이다.

[... 조금 더 시간이지나 ...]

아, 음 ... 문제가 두 math.h 헤더 있으며, 컴파일러가 잘못된 따기되는 것 같다 .

시도해 볼만한 몇 가지 트릭이 있습니다. 먼저, 아마도 FLTK의 문서를 확인하는 것입니다 : <FL/header.h> 또는 <header.h>을 사용하여 헤더에 액세스해야합니까? 하위 디렉토리와 함께 버전을 사용하려면 컴파일 명령 행에 -I/usr/include/FL을 추가 할 필요가 없습니다. <FL/header.h>에 대한 참조는 /usr/include에서 과 같은 것으로 /usr/include을 검색 할 때 /usr/include/FL/header.h을 찾고 자동으로 처리됩니다. 그 해답의 일부가 아닌 경우

, 당신은 플래그를 사용하여 시도 할 수 있습니다 :

이 말한다
-I/usr/include -I/usr/include/FL 

"(다음 다시 /usr/include/FL을 검색 한 후 /usr/include 검색) /usr/include/FL를 검색하기 전에 /usr/include 검색". 즉각적인 문제를 해결해야하지만, /usr/include/FL/math.h을 포함해야하는 문제가 발생할 수 있습니다. 이것은 확실히 첫 번째 옵션만큼 신뢰할 수 없습니다.

+0

예, 있습니다! 무슨 일이야? –

+0

좋아, 너 덕분에, 알아 냈어. 내/usr/include 디렉토리에는 math.h가 있지만/usr/include/FL에있는 math.h가 우선합니다. 문제를 해결하는/usr/include/FL의 math.h를 제거 할 수는 있지만 math.h를 명시 적으로 컴파일러에게 알리는 방법이 있습니까? –

+0

아! 예, 그것은 내 잘못이었습니다. 나는 '#include '등을 수행해야한다. 따라서, 필자의 include 경로에는/usr/include (Ha-ha) 만 포함되어야합니다. 도와 주셔서 감사합니다. 그것은 나에게 매우 미묘했다. 앞으로 이런 종류의 문제를 진단 할 수 있기를 바랍니다. –

0

스콧,이 링커 플래그 목록에 -lm를 추가, 당신은 괜찮을거야.

4

비슷한 문제가있었습니다. Qt Creator의 포함 경로에 실수로 math.h이 생성되어서 math.h 파일을 숨긴 프로젝트에 대한 수학 하위 패키지를 만들었 기 때문입니다. 간단히 말해서 find/-name math.h을 찾은 것입니다. 물론 그것은 시간이 좀 걸릴 수 있지만, 그것들 모두를 가져옵니다.

0

Qt Creator 3.3을 사용합니다.0과 같은 문제를 가지고

그것은 내가 다른 #include를

그것은 해결하기 전에 상단 라인에 선

사용법 #include < cmath>

를 이동하여 그것을 해결 한 것이 재미있다 내 문제!