2013-03-15 7 views
1

우분투 12.04에서 hidapi 라이브러리를 사용하려고합니다. 나는 github의 튜토리얼을 따라 갔지만, 함께 제공되는 테스트 코드조차 작동하지 않는다. 정의되지 않은 참조에 대해서는 항상 불평합니다. 나는 해결책을 찾을 수 없다. 성공적인 설치 후에도 라이브러리를 찾을 수 없습니다.Hidapi가 우분투에서 코드를 컴파일 할 수 없습니다.

hidtest.cpp를 컴파일하려고하는데 첫 번째 오류는 hid_init() 행에 있습니다.

누군가 나를 도울 수 있습니까?

편집 :

make all 

Building target: hidtest 

Invoking: Cross G++ Linker 

g++ -o "hidtest" ./src/hidtest.o 

./src/hidtest.o: In function `main': 
/../src/hidtest.cpp:35: undefined reference to `hid_init' 
/../src/hidtest.cpp:38: undefined reference to `hid_enumerate' 
/../src/hidtest.cpp:53: undefined reference to `hid_free_enumeration' 
/../src/hidtest.cpp:63: undefined reference to `hid_open' 
/../src/hidtest.cpp:71: undefined reference to `hid_get_manufacturer_string' 
/../src/hidtest.cpp:78: undefined reference to `hid_get_product_string' 
/../src/hidtest.cpp:85: undefined reference to `hid_get_serial_number_string' 
/../src/hidtest.cpp:93: undefined reference to `hid_get_indexed_string' 
/../src/hidtest.cpp:99: undefined reference to `hid_set_nonblocking' 
/../src/hidtest.cpp:103: undefined reference to `hid_read' 
/../src/hidtest.cpp:111: undefined reference to `hid_send_feature_report' 
/../src/hidtest.cpp:120: undefined reference to `hid_get_feature_report' 
/../src/hidtest.cpp:123: undefined reference to `hid_error' 
/../src/hidtest.cpp:137: undefined reference to `hid_write' 
/../src/hidtest.cpp:140: undefined reference to `hid_error' 
/../src/hidtest.cpp:146: undefined reference to `hid_write' 
/../src/hidtest.cpp:155: undefined reference to `hid_read' 
/../src/hidtest.cpp:173: undefined reference to `hid_close' 
/../src/hidtest.cpp:176: undefined reference to `hid_exit' 

collect2: ld returned 1 exit status 

make: *** [hidtest] Error 1 

이 우분투 12.04에서 수행 이클립스 주노

+0

오류 로그를 게시 할 수 있습니까? 유용 할 겁니다 – lucasg

+0

프로젝트 루트 디렉토리에서'make'를 실행하고 있습니까, 아니면'hidtest' 디렉토리의'Makefile'을 호출하고 있습니까? – jazzbassrob

+0

소스에 # hidapi.h가 포함되어 있습니까? – TheMathemagician

답변

3

를 사용하는 사람들은 링커 오류 :

collect2 : 1 종료 상태

을 반환 LD

처음에는 코드를 hidapi 라이브러리에 연결하지 않았다고 생각했지만 실수로 gcc 매개 변수를 잘못 입력하면 실수를 다시 생성 할 수있었습니다. 동일한 출력으로 실패합니다 :

$ g++ -c -Ihidapi hidtest/hidtest.cpp -o hidtest/hidtest.o 
$ g++ -Llinux/.libs -lhidapi-hidraw hidtest/hidtest.o -o test 

오브젝트 파일은 연결 단계의 gcc 인수에 라이브러리 앞에 있어야합니다.

잘 다음 작품 :

$ g++ -c -Ihidapi hidtest/hidtest.cpp -o hidtest/hidtest.o 
$ g++ -Llinux/.libs hidtest/hidtest.o -lhidapi-hidraw -o test 
$ LD_LIBRARY_PATH=linux/.libs ./test 

주 내가 hidapi를 설치하지 않았기 때문에 -I, -L과 LD_LIBRARY_PATH를 사용해야합니다, 나는 hidapi 소스 폴더에서 모든 것을했다.

+0

고맙습니다. 그런 생각이 들기는했지만, 확실하지 않았습니다. – Fred

관련 문제