LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-31-2013, 09:33 AM   #1
blesbok
LQ Newbie
 
Registered: May 2008
Posts: 21

Rep: Reputation: 1
Question LibNXT for Lego Mindstorms won't compile with scons; usb.h is needed


Hi community, I'm trying to get LibNXT working for Lego Mindstorms.

According to the libnxt-0.3 README

To compile all of this you'll need a copy of libusb 0.1 on your
system, as well as the scons project manager.

- Libusb 0.1: http://libusb.sf.net/
- Scons: http://www.scons.org/

Here's the output of

Code:
apt-file search -x 'libusb\.h$'
apcupsd-doc: /usr/share/doc/apcupsd/examples/libusb.h
libusb-1.0-0-dev: /usr/include/libusb-1.0/libusb.h

So I've installed the libusb that's available and scons. Here's where the problem appears:

run 'scons' in the libnxt directory, and compilation should follow

Attempting that, the following happened:

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o firmware.o -c -Wall -std=gnu99 -g -ggdb -D_NXT_LITTLE_ENDIAN firmware.c
In file included from firmware.c:31:0:
lowlevel.h:25:17: fatal error: usb.h: No such file or directory
compilation terminated.
scons: *** [firmware.o] Error 1
scons: building terminated because of errors.

In the hope that libusb.h would be a suitable substitute for usb.h, I did this

Code:
$ sudo cp /usr/include/libusb-1.0/libusb.h /usr/include/usb.h
but it gave a screenful of error messages.

This issue (or similar) has been mentioned on
http://code.google.com/p/libnxt/issues/detail?id=6

Which recommends the following:

Quote:
change these two lines in SConstruct:
Code:
Default(BuildEnv.Program('fwflash', 'main_fwflash.c',
                         LIBS=['nxt', 'usb'], LIBPATH='.'))

Default(BuildEnv.Program('fwexec', 'main_fwexec.c',
                         LIBS=['nxt', 'usb'], LIBPATH='.'))
But having done that, the usb.h file is still missing.

Can anyone shed some light?
 
Old 08-31-2013, 10:37 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
README : To compile all of this you'll need a copy of libusb 0.1

Quote:
In the hope that libusb.h would be a suitable substitute for usb.h, I did this
$ sudo cp /usr/include/libusb-1.0/libusb.h /usr/include/usb.h
Solution : 1) Delete /usr/include/usb.h
2) Install "libusb 0.1" from source, to --prefix=/usr/
http://packages.ubuntu.com/quantal/libusb-0.1-4 (No -dev package)
Source [libusb_0.1.12.orig.tar.gz] + [libusb_0.1.12-23.debian.tar.gz]
Or use old Debian packages if your OS is 32bits
http://archive.debian.org/debian-arc...n/libu/libusb/
libusb-0.1-4_0.1.5-4_i386.deb + libusb-dev_0.1.5-4_i386.deb

Any questions ? Then please specify your OS :
a) $ uname -m <Enter>
b) $ cat /etc/issue <Enter>

-
 
Old 08-31-2013, 02:40 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
the LEGO software needs the almost ancient USB1 software
-- yes usb1 in a usb3 world
it dates to 1998 - 2000

so use the LEGACY version and not the current libusb

also from the error
Quote:
lowlevel.h:25:17:
read line 25 of the file in the LibNXT source "lowlevel.h"
it is an "include" statement
it should be this ( a guess so )
Code:
#include  < usb.h >
that means it is looking for the file here "/usr/include/usb.h"
now sometimes some programs look for it in the build folder
if so it will look like this
Code:
#include  "usb.h"
 
Old 08-31-2013, 02:59 PM   #4
blesbok
LQ Newbie
 
Registered: May 2008
Posts: 21

Original Poster
Rep: Reputation: 1
Thank you knudfl for your prompt assistance. That usb.h change was undone when it didn't work.

The OS:
i686; Ubuntu 12.04.2 LTS \n \l; 32-bit

Do I need to first uninstall libusb 1.0 before installing libusb 0.1? If so, how would I go about that? Since it's 32-bit, I'll install the two .deb packages you mention. Is this the right way to install each package?

Quote:
sudo dpkg -i package.deb to --prefix=/usr/
 
Old 08-31-2013, 03:32 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
both can be installed
but you will likely need to hack the old lego program to look in the right place for the old code .
 
Old 08-31-2013, 05:48 PM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
# 4 .

Sorry, the old packages have conflicts with the installed libusb-0.1-4 (0.1.12-20).
Somehow the new libusb-1.0-0 depends on the already installed libusb-0.1-4,
so libusb-0.1-4 can't be replaced by another package.

On some of the rpm based OS, both libusb versions are available as development packages.
Which means that libNXT can easily be compiled.
And I guess you can use a binary set of "LibNXT" files :
LibNXT provides two executable {fwexec, fwflash} and 'libnxt.a'.
Please try out "libnxt-i386.tar.gz", 19.6 kB :
https://docs.google.com/file/d/0B7S2...it?usp=sharing

"libnxt-i386.tar.gz" is based on https://github.com/rvs/libnxt

-
 
Old 09-01-2013, 09:58 AM   #7
blesbok
LQ Newbie
 
Registered: May 2008
Posts: 21

Original Poster
Rep: Reputation: 1
Thanks John and Knud

An rpm-based OS is not an option. Not sure what to do with executables. What's the best way to install these? Would you agree with...?

Quote:
cp fwexec /tmp/fwexec; sudo /tmp/fwexec
cp fwflash /tmp/fwflash; sudo /tmp/fwflash
cp libnxt.a /tmp/fwflash; sudo /tmp/fwflash
Or should I use scons?

Quote:
mkdir /tmp/libnxt
cp fwexec /tmp/libnxt/fwexec
cp fwflash /tmp/libnxt/fwflash
cp libnxt.a /tmp/libnxt/fwflash
cd /tmp/libnxt
sudo scons
 
Old 09-01-2013, 02:39 PM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
# 7.
Quote:
An rpm-based OS is not an option.
No ... but that's what I used to create {fwexec, fwflash, libnxt.a}.

The two executable fwexec, fwflash : Copy those to /usr/local/bin/.
The library libnxt.a : To /usr/local/lib/.

Definitely not to /tmp/ !
** Users should not store files in /tmp. Use /home/** for all build jobs.

And : scons is used only when you compile source code.


-
 
Old 09-01-2013, 03:59 PM   #9
blesbok
LQ Newbie
 
Registered: May 2008
Posts: 21

Original Poster
Rep: Reputation: 1
Thanks again, Knud. It's installed but have yet to find a way to make it do anything useful. It looks like nxt-python's the way to go...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Lego Mindstorms on WINE Elmo187 Linux - Software 6 01-01-2016 05:45 PM
Lego mindstorms ide cosmogod Slackware 3 11-14-2010 04:05 AM
Need help Installing LEGO MINDSTORMS Using Wine on Ubuntu 10.04.1 9876543210 Linux - Software 3 10-01-2010 09:50 AM
linux and lego mindstorms, is it possible? tuneout Linux - Software 2 03-28-2006 05:49 PM
LEGO Mindstorms RIS 2.0 L.Tilley Linux - General 2 03-12-2002 12:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration