2017-12-29 11 views
11

EDIT2 : 문제는 간단한 입력 오류가 아닙니다입니다. 아래의 로그에서 오타를 만들었지 만 문제는 여전히있었습니다.C++ 프로그램을 컴파일 할 수 없습니다. 오류 : 알 수없는 형식 이름 'uint8_t'

EDIT : g ++ 대신 gcc로 잘못 실행했습니다. 아래에서 시도한 후 한 번. 문제는 이전에 g ++와 함께 있었고 현재 있습니다.

현재 MacOS High Sierra 상자에 있습니다. 필자는 최근 MacBook Air에서이 컴퓨터로 많은 파일을 옮겼습니다. 여기에는 Xcode의 모든 정크가 포함됩니다. 지금 때 나는 아주 간단한 C++ 프로그램을 컴파일하려고 :

[email protected]: [config_file_script] $ g++ test.cpp -o test 
In file included from test.cpp:1: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream:38: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/ios:216: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:15: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/string:470: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/string_view:171: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/__string:56: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm:640: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/memory:629: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/typeinfo:61: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/exception:82: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdlib:86: 
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:94: 
In file included from /usr/include/stdlib.h:65: 
In file included from /usr/include/sys/wait.h:110: 
/usr/include/sys/resource.h:196:2: error: unknown type name 'uint8_t' 
     uint8_t ri_uuid[16]; 
     ^
/usr/include/sys/resource.h:197:2: error: unknown type name 'uint64_t' 
     uint64_t ri_user_time; 
     ^
/usr/include/sys/resource.h:198:2: error: unknown type name 'uint64_t' 
     uint64_t ri_system_time; 
     ^
/usr/include/sys/resource.h:199:2: error: unknown type name 'uint64_t' 
     uint64_t ri_pkg_idle_wkups; 
     ^
/usr/include/sys/resource.h:200:2: error: unknown type name 'uint64_t' 
     uint64_t ri_interrupt_wkups; 
     ^
/usr/include/sys/resource.h:201:2: error: unknown type name 'uint64_t' 
     uint64_t ri_pageins; 
     ^
/usr/include/sys/resource.h:202:2: error: unknown type name 'uint64_t' 
     uint64_t ri_wired_size; 
     ^
/usr/include/sys/resource.h:203:2: error: unknown type name 'uint64_t' 
     uint64_t ri_resident_size; 
     ^
/usr/include/sys/resource.h:204:2: error: unknown type name 'uint64_t' 
     uint64_t ri_phys_footprint; 
     ^
/usr/include/sys/resource.h:205:2: error: unknown type name 'uint64_t' 
     uint64_t ri_proc_start_abstime; 
     ^
/usr/include/sys/resource.h:206:2: error: unknown type name 'uint64_t' 
     uint64_t ri_proc_exit_abstime; 
     ^
/usr/include/sys/resource.h:210:2: error: unknown type name 'uint8_t' 
     uint8_t ri_uuid[16]; 
     ^
/usr/include/sys/resource.h:211:2: error: unknown type name 'uint64_t' 
     uint64_t ri_user_time; 
     ^
/usr/include/sys/resource.h:212:2: error: unknown type name 'uint64_t' 
     uint64_t ri_system_time; 
     ^
/usr/include/sys/resource.h:213:2: error: unknown type name 'uint64_t' 
     uint64_t ri_pkg_idle_wkups; 
     ^
/usr/include/sys/resource.h:214:2: error: unknown type name 'uint64_t' 
     uint64_t ri_interrupt_wkups; 
     ^
/usr/include/sys/resource.h:215:2: error: unknown type name 'uint64_t' 
     uint64_t ri_pageins; 
     ^
/usr/include/sys/resource.h:216:2: error: unknown type name 'uint64_t' 
     uint64_t ri_wired_size; 
     ^
/usr/include/sys/resource.h:217:2: error: unknown type name 'uint64_t' 
     uint64_t ri_resident_size; 
     ^
fatal error: too many errors emitted, stopping now [-ferror-limit=] 
20 errors generated. 

내가 설치하고 난 문제와 관련이 생각할 수있는 모든 것을 다시 설치 시도했다 :

#include <iostream> 

int main() 
{ 
    // VAR_DEC 
    int a = 4; 
    // VAR_MANIP 
    a = a*2; 
    // VAR_PRINT 
    std::cout << a << std::endl; 
    return 0; 
} 

을 나는 다음과 같은 말도 안되는 오류

  • unknown type name 'uint8_t', MinGW
  • Cythonizing fails because of unknown type name 'uint64_t'Unknown type name uint8_t?
  • Include search path on Mac OS X Yosemite 10.10.1
  • , 그러나 그 꽤 잘 요약한다. 해결책 중 어느 것도 효과가 없습니다.

    나는 the last one이 가장 가능성있는 해결책이라고 생각합니다. (당신은 페이지의 "알"을 검색하면 수정 프로그램을 볼 수 있습니다.) 개발자에 따르면

    Fix: Remove /opt/local/include/** and /opt/local/lib/** from the "Header Search Paths" build settings. Replace them with much more specific paths to the desired include directories. In my particular case, this meant replacing them with /opt/local/include/glib-2.0 /opt/local/lib/glib-2.0/include /opt/local/include/. It's up and running again!

    을하지만, 내가 엑스 코드를 설치하지 않은, 난 단지 명령 줄 개발자 도구를 설치했습니다. 따라서 "헤더 검색 경로"빌드 설정에 액세스 할 수있는 쉬운 방법이 없으므로 솔루션을 사용해 볼 수 없습니다.

    이 문제에 대한 해결책을 찾고 있는데, 전체 운영 체제를 설치하지 않아도되는 것이 좋습니다. 또는 빌드 설정 파일을 찾음으로써 누군가 나를 친절하게 안내 할 수 있다면 매우 감사하게 생각합니다.

  • +0

    설명은 확장 토론이 아닙니다. 이 대화는 [채팅으로 이동되었습니다] (http://chat.stackoverflow.com/rooms/162198/discussion-on-question-by-joseph-farah-cannot-compile-any-c-programs-error-u) . –

    답변

    3

    시스템 GCC 설치를 골랐다는 것이 명백합니다. GCC는 컴파일러의 모음이고 G ++은 C++ 프런트 엔드입니다. 패키지 관리자는 종종 gcc-g++이라는 별도의 패키지를 가지고 있지만, 소스에서 컴파일 할 때는 --enable-languages=c,c++을 사용하면됩니다. 이제 XCode를 다시 설치해도 문제가 해결되지 않으면 (이미 완료 했어야합니다. "너무 많은 공간이 필요하다"를 제거한 경우에만) 소스에서 GCC를 컴파일 해 볼 수 있습니다.GNU wiki에서 적응 :

    • 첫째,의 압축을 풉니 다 here

    • 에서 다음 tar zxvf gcc*

    • cd gcc*./contrib/download_prerequisites

    • 으로 원하는 GCC 타르 볼을 잡아 것은 소스 빌드 아웃을 수행 : mkdir build && cd build

    • ../gcc*/configure --prefix=$HOME/gcc-install --enable-languages=c,c++

    • makemake install

    이제 당신의 경로에 $HOME/gcc-install/bin를 추가하고 갈 수 있어야한다.

    +0

    이것이 내 문제를 해결했습니다! 또한이 작업을 시도하기 전에 수동으로 명령 줄 도구 디렉토리 *를 수동으로 제거해야한다고 덧붙이고 싶습니다. 이것이 효과가 있다는 것 이외에! 고마워요! 또한, 나는 "borked"라는 단어의 초기 사용을 위해 이것을 두 번 upvote 할 수 있었으면 좋겠다. –

    +0

    효과가 있습니까? 당신은 GCC를 그렇게 빨리 컴파일 할 수 없었을 것입니다. – OwO

    +0

    이것은 일반적으로 내 문제를 해결하기 위해 사용 된 단계입니다. 소스에서 GCC를 컴파일하고이를 내 경로에 추가했습니다. 나는 작은 문제를 겪어 왔습니다. 그래서 저는 답과 비슷한 것을 게시하지 않았습니다. 그러나 문제를 ROOT의 이전 설치로 좁혔습니다. 지난 몇 시간. 어떤 혼란에 대 한 미안 해요! –

    관련 문제