Discussion:
[libhid-discuss] how to build test_libhid.c
Tristan Sun
2010-09-29 04:44:26 UTC
Permalink
Hi,

I am new in Linux. I need use libhid, but however I try to build the sample code, test_libhid.c,
I always fail. I try to search web site to find solutions for some days, but I still can not get solution.
I use Fedora 10, and Fedora 13. Install libusb 0.1<http://libusb.sourceforge.net/doc/>, libusb 1.0 and libhid.
The build fail message is in the following. It seems I can not link libhid library.
Does anyone can help to tell me how to build test_libhid.c?

Thanks.

[root at localhost hh]# gcc test_libhid.c -I/usr/local/include -L/usr/local/lib -lusb
/tmp/cc5y2JTR.o: In function `main':
hh.c:(.text+0x1c1): undefined reference to `hid_set_debug'
hh.c:(.text+0x1ce): undefined reference to `hid_set_debug_stream'
hh.c:(.text+0x1da): undefined reference to `hid_set_usb_debug'
hh.c:(.text+0x1df): undefined reference to `hid_init'
hh.c:(.text+0x217): undefined reference to `hid_new_HIDInterface'
hh.c:(.text+0x279): undefined reference to `hid_force_open'
hh.c:(.text+0x2c1): undefined reference to `hid_write_identification'
hh.c:(.text+0x309): undefined reference to `hid_dump_tree'
hh.c:(.text+0x348): undefined reference to `hid_close'
hh.c:(.text+0x384): undefined reference to `hid_delete_HIDInterface'
hh.c:(.text+0x389): undefined reference to `hid_cleanup'
collect2: ld returned 1 exit status
[root at localhost hh]#

Tristan
tristans at amrel.com<mailto:tristans at amrel.com>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20100928/b01fda0a/attachment.htm>
Charles Lepple
2010-09-29 15:34:53 UTC
Permalink
Post by Tristan Sun
I am new in Linux. I need use libhid, but however I try to build the
sample code, test_libhid.c,
I always fail. I try to search web site to find solutions for some
days, but I still can not get solution.
I use Fedora 10, and Fedora 13. Install libusb 0.1, libusb 1.0 and
libhid.
The build fail message is in the following. It seems I can not link libhid library.
Does anyone can help to tell me how to build test_libhid.c?
How did you install libhid?
Post by Tristan Sun
Thanks.
[root at localhost hh]# gcc test_libhid.c -I/usr/local/include -L/usr/
local/lib -lusb
hh.c:(.text+0x1c1): undefined reference to `hid_set_debug'
Peter Stuge
2010-09-29 23:13:19 UTC
Permalink
Post by Tristan Sun
I am new in Linux. I need use libhid,
Why? You could also take a look at HIDAPI for your HID communication
needs.
Post by Tristan Sun
[root at localhost hh]# gcc test_libhid.c -I/usr/local/include -L/usr/local/lib -lusb
You are linking with libusb (not libusb-1.0) but you are not linking
with libhid. Of course it will not work. Try adding -lhid but look at
HIDAPI too.


//Peter
skip hodgson
2010-09-30 23:41:41 UTC
Permalink
Post by Peter Stuge
Post by Tristan Sun
I am new in Linux. I need use libhid,
Why? You could also take a look at HIDAPI for your HID communication
needs.
The HIDAPI web-site contains the following note:
"These API calls can be used in any development environment that accepts DLLs
(e.g., Microsoft Visual C++ or Visual Basic).
1. System Requirements
UsbHidApi requires a Windows laptop or desktop PC with the following
minimum capabilities:
* Windows 98/2000/XP/Vista"
It is hard to see the value of sending a newbie there when he clearly states he
is trying to use Linux.

It is important to answer Charles' question though, "How did you install
libhid". Most usefully you should have the source code package available from
(for example)

svn://svn.debian.org/libhid/trunk
use the command
svn co svn://svn.debian.org/libhid/trunk

Once you have the source cd to the "trunk" and use the commands
./autogen.sh
./configure
make
make install

If you have all the necessary dependencies and nothing goes wrong with the build
you will already have the test_libhid program compiled for you and you can see
how it compiles and how it works.

We have made a copy of test_libhid.c which we are exploring for a proposed
development and which is called test_skip.c and located in the same directory as
test_libhid.c. For your information the Makefile line we use to compile it is:

gcc -g -O0 -DHAVE_CONFIG_H -I. -I.. -I../include -I../hidparser
-L/usr/lib -Wall -W -Werror test_skip.c -lusb ../src/.libs/libhid.a -o test_skip

It works fine.

Cheers,
Skip.
Peter Stuge
2010-10-01 00:20:30 UTC
Permalink
Post by skip hodgson
Post by Peter Stuge
Post by Tristan Sun
I am new in Linux. I need use libhid,
Why? You could also take a look at HIDAPI for your HID communication
needs.
..
Post by skip hodgson
1. System Requirements
UsbHidApi requires a Windows laptop or desktop PC with the following
* Windows 98/2000/XP/Vista"
It is hard to see the value of sending a newbie there when he clearly
states he is trying to use Linux.
I think you got hold of the wrong HIDAPI.

I should have included the URL: http://www.signal11.us/oss/hidapi/

Sorry if I didn't do that. It's simple, no-nonsense and Win Mac Linux.


//Peter
skip hodgson
2010-10-01 21:33:44 UTC
Permalink
Post by Peter Stuge
I think you got hold of the wrong HIDAPI.
I should have included the URL: http://www.signal11.us/oss/hidapi/
Sorry if I didn't do that. It's simple, no-nonsense and Win Mac Linux.
//Peter
Thanks. Looks very useful. Mind you I had to do
apt-get install libudev-dev
to get it to compile.
Skip.

Tristan Sun
2010-10-01 00:41:41 UTC
Permalink
Skip,

Very thanks, Now, I can build test_libhid.c and run it, and watch the result of running.

Thanks for your help.

Tristan


-----Original Message-----
From: libhid-discuss-bounces+tristans=amrel.com at lists.alioth.debian.org [mailto:libhid-discuss-bounces+tristans=amrel.com at lists.alioth.debian.org] On Behalf Of skip hodgson
Sent: Thursday, September 30, 2010 4:42 PM
To: libhid-discuss at lists.alioth.debian.org
Subject: Re: [libhid-discuss] how to build test_libhid.c
Post by Peter Stuge
Post by Tristan Sun
I am new in Linux. I need use libhid,
Why? You could also take a look at HIDAPI for your HID communication
needs.
The HIDAPI web-site contains the following note:
"These API calls can be used in any development environment that accepts DLLs
(e.g., Microsoft Visual C++ or Visual Basic).
1. System Requirements
UsbHidApi requires a Windows laptop or desktop PC with the following
minimum capabilities:
* Windows 98/2000/XP/Vista"
It is hard to see the value of sending a newbie there when he clearly states he
is trying to use Linux.

It is important to answer Charles' question though, "How did you install
libhid". Most usefully you should have the source code package available from
(for example)

svn://svn.debian.org/libhid/trunk
use the command
svn co svn://svn.debian.org/libhid/trunk

Once you have the source cd to the "trunk" and use the commands
./autogen.sh
./configure
make
make install

If you have all the necessary dependencies and nothing goes wrong with the build
you will already have the test_libhid program compiled for you and you can see
how it compiles and how it works.

We have made a copy of test_libhid.c which we are exploring for a proposed
development and which is called test_skip.c and located in the same directory as
test_libhid.c. For your information the Makefile line we use to compile it is:

gcc -g -O0 -DHAVE_CONFIG_H -I. -I.. -I../include -I../hidparser
-L/usr/lib -Wall -W -Werror test_skip.c -lusb ../src/.libs/libhid.a -o test_skip

It works fine.

Cheers,
Skip.
Loading...