cubietruck의 gpio_lib로 작업하려고합니다. 그러므로 나는 내 작업 디렉토리에있는 gpio_lib.h
(https://github.com/youyudehexie/node-cubieboard-gpio/blob/master/lib/gpio_lib.h 참조) 파일을 가지고 : 나는 다음과 같은 한 내 test.cpp
에서C++에서 헤더 파일을 컴파일하고 링크하는 방법은 무엇입니까?
> l
gpio_lib.h
test.cpp
은 다음과 같습니다
#include "gpio_lib.h"
및 sunxi_gpio_init
및 sunxi_gpio_output
같은 gpio_lib의 일부 기능 통화 main()
함수 내에서.
> g++ -o test -O3 -Wall gpio_lib.h test.cpp
> g++ -o test -O3 -Wall -I. -L. gpio_lib.h test.cpp
: 나는
> g++ -o test -O3 -Wall test.cpp
를 통해 send.cpp를 컴파일 및 링크하려고하면
그러나 나는 또한 동일한 오류가 전화를 다음 시도
/tmp/ccULAi2f.o: In function `sequence_up()':
test.cpp:(.text+0x26a): undefined reference to `sunxi_gpio_output(unsigned int, unsigned int)'
/tmp/ccULAi2f.o:test.cpp:(.text.startup+0xa2): more undefined references to `sunxi_gpio_output(unsigned int, unsigned int)' follow
collect2: error: ld returned 1 exit status
를 얻을 수 test.cpp
을 컴파일하고 연결하는 올바른 방법은 무엇입니까?
당신이 필요 gpio 라이브러리도 링크하십시오. – Ashalynd
질문은 : 어떻게? – phortx
프로젝트에 gpio_lib.c 파일을 적어도 추가하십시오. -} – Ashalynd