usb-relay-hid icon indicating copy to clipboard operation
usb-relay-hid copied to clipboard

run make_release_linux.sh

Open racroi3010 opened this issue 8 years ago • 25 comments

Dear Team,

I run make_release_linux.sh to build on Linux, but it's failed

cannot stat ‘commandline/makemake/hidusb-relay-cmd’: No such file or directory

I think there are some missing files, could you please help me solve it?

Best regards.

racroi3010 avatar Dec 01 '16 07:12 racroi3010

Run make_release_linux.sh after successful build. This script does not build, it only copies build products.

pavel-a avatar Jan 02 '17 02:01 pavel-a

the file name is therefore a 'lie' or at least 'misleading', i would at least expect it to MAKE (what?) a RELEASE (for what?) LINUX. Pavel, i think i'll make a fork of this and contribute with my understanding of this project, thank you for making this sources available, hope you can contribute further! Thanks!

rochajoel avatar Mar 15 '17 09:03 rochajoel

Hello rochajoel,

You are welcome to fork and contribute. Thanks!

P.

pavel-a avatar Mar 17 '17 12:03 pavel-a

I already did, i'm not an expert on using git, but i tried to make a linux folder on my fork, and added a Makefile on that root folder, have a look at it if you'd like. Given what i have on my fork, all we need is to deploy libusb artifacts to include/usb and to lib/usb/x86 to be able to build the relay cmd utility.

rochajoel avatar Mar 17 '17 14:03 rochajoel

Any decent Linux dusribution should include libusb. All you need is to install it using apt-get or whatever, then it's .h file will be found automatically.

Regards, P.

Sent from Outlookhttps://aka.ms/sdimjr for iPad


From: rochajoel [email protected] Sent: Friday, March 17, 2017 4:12:56 PM To: pavel-a/usb-relay-hid Cc: Pavel A.; Comment Subject: Re: [pavel-a/usb-relay-hid] run make_release_linux.sh (#14)

I already did, i'm not an expert on using git, but i tried to make a linux folder on my fork, and added a Makefile on that root folder, have a look at it if you'd like. Given what i have on my fork, all we need is to deploy libusb artifacts to include/usb and to lib/usb/x86 to be able to build the relay cmd utility.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/pavel-a/usb-relay-hid/issues/14#issuecomment-287364494, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHaeSbB-rovnipd39183qI8y1BklF2c3ks5rmpTogaJpZM4LBFMA.

pavel-a avatar Mar 17 '17 15:03 pavel-a

Great! If you like my changes be my guest to push them to your repository!

Cheers, Joel.

rochajoel avatar Mar 17 '17 17:03 rochajoel

How to build command line version on linux? I tried cd commandline/makemake && make as given in the wiki but encountered following error:

make: libusb-config: Command not found make: libusb-config: Command not found gcc -O -Wall -I.. -I../../lib -fPIC -c -o usbrelay-cmd.o ../usbrelay-cmd.c ../usbrelay-cmd.c: In function ‘enumFunc’: ../usbrelay-cmd.c:84:2: warning: statement with no effect [-Wunused-value] (context); // ~ unreferenced warning ^ gcc -O -Wall -I.. -I../../lib -fPIC -c -o hiddata_libusb01.o ../hiddata_libusb01.c ../hiddata_libusb01.c:14:17: fatal error: usb.h: No such file or directory compilation terminated. : recipe for target 'hiddata_libusb01.o' failed make: *** [hiddata_libusb01.o] Error 1

zeeshan-k avatar Apr 08 '17 14:04 zeeshan-k

Please have a look at my repository https://github.com/rochajoel/usb-relay-hid

As i have run into the same issue, i contributed with a makefile capable of building the cmd line utility. You are still required to build libusb on your own and to put it on the correct paths,

see my repository for more details.

rochajoel avatar Apr 09 '17 12:04 rochajoel

Probably you don’t have libusb-dev installed. This stuff comes with libusb-dev.

From: Sergeymailto:[email protected] Sent: ‎Sat‎, ‎April‎ ‎8‎, ‎2017 ‎17‎:‎25 To: pavel-a/usb-relay-hidmailto:[email protected] Cc: pavel amailto:[email protected], Commentmailto:[email protected]

How to build command line version on linux? I tried cd commandline/makemake && make as given in the wiki but encountered following error:

make: libusb-config: Command not found make: libusb-config: Command not found gcc -O -Wall -I.. -I../../lib -fPIC -c -o usbrelay-cmd.o ../usbrelay-cmd.c ../usbrelay-cmd.c: In function ‘enumFunc’: ../usbrelay-cmd.c:84:2: warning: statement with no effect [-Wunused-value] (context); // ~ unreferenced warning ^ gcc -O -Wall -I.. -I../../lib -fPIC -c -o hiddata_libusb01.o ../hiddata_libusb01.c ../hiddata_libusb01.c:14:17: fatal error: usb.h: No such file or directory compilation terminated. : recipe for target 'hiddata_libusb01.o' failed make: *** [hiddata_libusb01.o] Error 1

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/pavel-a/usb-relay-hid/issues/14#issuecomment-292721434, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHaeSRfG9pFCvwjn7Sb1hR8LP9GS5gLhks5rt5jNgaJpZM4LBFMA.

pavel-a avatar Apr 12 '17 17:04 pavel-a

You DON'T NEED libusb installed on your system, AS LONG AS you have the libraries.

See this: https://github.com/rochajoel/usb-relay-hid/tree/master/linux/include/usb https://github.com/rochajoel/usb-relay-hid/tree/master/linux/lib/usb/x86

If i wanted to have support for ARM, i would have to cross-compile libusb for ARM and include it in (...)linux/lib/usb/arm to be able to compile this utility

If you want to cross-compile run:

ARCH=arm make clean all

I never tested it, but any feedback is welcome! :)

rochajoel avatar Apr 13 '17 08:04 rochajoel

Thanks @pavel-a I installed libusb-dev and the build succeeded.

zeeshan-k avatar Apr 15 '17 11:04 zeeshan-k

@rochajoel I will try your method on another linux machine and update soon.

zeeshan-k avatar Apr 15 '17 11:04 zeeshan-k

@rochajoel cross compile won't work

ARCH=arm make clean all

host

Linux web1 4.10.17-041017-generic #201705201051 SMP Sat May 20 14:53:33 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

target Linux RT-AC68U 2.6.36.4brcmarm #16 SMP PREEMPT Sun May 28 12:34:56 CST 2017 armv7l ASUSWRT-Merlin

mengzhuo avatar Nov 05 '17 14:11 mengzhuo

Thank you for the negative feedback. However, the reason why the build fails is unclear to me. Can you be more specific?

rochajoel avatar Nov 05 '17 14:11 rochajoel

@rochajoel

root@web1:~/usb-relay-hid/commandline/makemake# ARCH=arm make clean all

rm -f *.o hidusb-relay-cmd usb_relay_device.so
gcc -O -Wall   -I.. -I../../lib -fPIC   -c -o usbrelay-cmd.o ../usbrelay-cmd.c
gcc -O -Wall   -I.. -I../../lib -fPIC   -c -o hiddata_libusb01.o ../hiddata_libusb01.c
gcc -o hidusb-relay-cmd usbrelay-cmd.o hiddata_libusb01.o -L/usr/lib/x86_64-linux-gnu -lusb
gcc -O -Wall   -I.. -I../../lib -fPIC   -c -o usb_relay_lib.o ../../lib/usb_relay_lib.c
../../lib/usb_relay_lib.c: In function ‘usb_relay_device_enumerate’:
../../lib/usb_relay_lib.c:382:9: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
     int ret;
         ^
../../lib/usb_relay_lib.c: At top level:
../../lib/usb_relay_lib.c:74:20: warning: ‘usbErrorMessage’ defined but not used [-Wunused-function]
 static const char *usbErrorMessage(int errCode)
                    ^
gcc -shared -Wl,-shared hiddata_libusb01.o usb_relay_lib.o -L/usr/lib/x86_64-linux-gnu -lusb -o usb_rela
y_device.so

and I copy hidusb-relay-cmd to my router

admin@RT-AC68U:/mnt/sda# ./hidusb-relay-cmd
bash: ./hidusb-relay-cmd: cannot execute binary file: Exec format error

mengzhuo avatar Nov 05 '17 15:11 mengzhuo

Your build is probably not using any cross compiler such as arm-linux-gnueabi-gcc (or something of the like). It uses plain gcc. Are you using the sources from my fork of this repository? It's been a long time since i've looked into this. Please inspect my makefile and make sure it contains instructions to use a cross-compiler. (Maybe you have to define it?)

Any way. The problem is that you are not cross compiling. Use readelf or ldd to inspect the output binary so that you know it is in the proper ARM format.

rochajoel avatar Nov 05 '17 15:11 rochajoel

If you look closely into my Makefile, it does not declare the ARM GCC compiler, it just has some statements that help you organize the libs in folders preceeded by the name of the arch you are targeting. It is hard coded to work with GCC so, either you create a sym link of GCC to your cross compiler, or you change the CC definition to your cross compiler name. You can even change it so that if ARCH == x86 it uses gcc, otherwise it will use arm-linux-****-gcc.

Also: from your log i can see you are probably forgetting to cross compile libusb! Compile it and add the library to the proper lib folder. If you are going to use 'arm' as ARCH=arm, you have to put it under 'lib/usb/arm'.

rochajoel avatar Nov 05 '17 15:11 rochajoel

Is there ARM binary available or any instructions how to compile this on Raspberry Pi?

ekakela avatar Mar 25 '18 14:03 ekakela

@ekakela if you like Golang , you can try my lib https://github.com/mengzhuo/go-usb-relay no cross compile issue

mengzhuo avatar Mar 25 '18 14:03 mengzhuo

https://github.com/ekakela : I think one can manage to build this for ARM, at least i think i did (it's been a while and i did not save the bin) however, you have to change some stuff as i say in the previous comments above. I'm not saying for sure it will work on your case (i never tried) but that there is a chance you can build it using the sources available at my branch.

rochajoel avatar Mar 26 '18 08:03 rochajoel

Managed to get it working with your branch.

ekakela avatar Mar 26 '18 10:03 ekakela

Can someone help me with more instructions to run this on a respberrypi? I copied rochajoel git to /domoticz/scripts/ but it's unable to run... I also used input from this git: https://github.com/bbqkees/Domoticz-Pi-USB8-relay-board-SOS-solutions. I have that board I want to run on the pi. But it's always giving this error:

image

deurenkletser avatar Aug 02 '18 13:08 deurenkletser

Have you built the executable? Please make sure to build it before you try to run it.

And if you run into some issue, please post the build log so that we can help.

Thanks!

rochajoel avatar Aug 02 '18 15:08 rochajoel

Of course. There is no such file usbrelay-cmd. The correct name is hidusb-relay.cmd.

Regards, P.

pavel-a avatar Aug 02 '18 18:08 pavel-a

Ik was following BBQkees instructions to get this to run. Where can I find more instructions on how you build this on the pi? Or does someone know where i can find more on how they build/compile. I now some Linux commands but nothing from programming. Sorry

deurenkletser avatar Aug 07 '18 10:08 deurenkletser