Building lejos_nxj 0.3 under linux

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Postby NVRAM » Wed Sep 05, 2007 6:32 am

optiluca wrote:OK so one step at a time...

1) I'm not really practical with java (not at all actually), but hoping to learn ;-) I ran the javac command on this
--SNIP--
and that returned no errors. Is that what you meant?

No, I meant actually build and run, or at least do the C compilation, which is what you're having problems with on leJOS.

optiluca wrote:3)
Code: Select all
ant -v
Apache Ant version 1.7.0 compiled on January 29 2007
Buildfile: build.xml
Detected Java version: 1.6 in: /opt/sun-jdk-1.6.0.02/jre
Detected OS: Linux
--SNIP--
Code: Select all
       [cc] gcc -Wall -std=gnu99 -g -ggdb -D_NXT_LITTLE_ENDIAN -c -Os -fPIC -I/home/luca/bin/lejos_nxj/src/libnxt /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c
       [cc] In file included from /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c:29:
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/jlibnxt.h:2:17: error: jni.h: No such file or directory


Okay, you're using gcc, and the failing line does not have an include directory for the JNI files, so try adding C_INCLUDE_DIRECTORY to the environment (or edit the buid.xml files -- search the forum for "include" and "pathelement") before invoking ant. It looks like you need:
export C_INCLUDE_DIRECTORY=.:/opt/sun-jdk-1.6.0.02/include:/opt/sun-jdk-1.6.0.02/include/linux

optiluca wrote:5) Not sure which line you mean exactly.. :S
--SNIP
PS Used the 0.4 beta, which gives the same error... Wonder why 0.2 works...

Hmm... well, you wouldn't have found it anyhow, so it doesn't matter a lot... try the C_INCLUDE_DIRECTORY or a slight variation. If my guess fails, check for the "jni.h" and "jni_md.h" files in the JDK subdirectories and use the directories containing those files.

G'luck,
NVRAM
NVRAM
New User
 
Posts: 17
Joined: Tue Aug 21, 2007 5:25 am

Postby NVRAM » Wed Sep 05, 2007 6:37 am

Actually, if all the above fails, try this, too -- all one line, under src/libnxt:
Code: Select all
gcc -v -Wall -std=gnu99 -g -ggdb -D_NXT_LITTLE_ENDIAN -c -Os -fPIC -I. -Iopt/sun-jdk-1.6.0.02/include -I/opt/sun-jdk-1.6.0.02/include/linux main_jlibnxt.c
NVRAM
New User
 
Posts: 17
Joined: Tue Aug 21, 2007 5:25 am

Postby optiluca » Mon Sep 10, 2007 4:05 pm

Nope none of that seems to work... Btw the code snippets i used were from trying to install 0.4. Would that make a difference in any way?

Thanks for your help
optiluca
Novice
 
Posts: 44
Joined: Wed Jul 18, 2007 6:12 pm

Postby lawrie » Mon Sep 10, 2007 7:10 pm

0.4 and 0.3 are no different in the way they are built.

0.2 worked for you because it did not use JNI. We need to use JNI so that the tools (nxj, nxjbrowse etc.) can be written in Java and so that user Java programs can use USB.

What result did you get from the direct call to gcc that NVRAM asked you to try?
lawrie
leJOS Team Member
 
Posts: 840
Joined: Mon Feb 05, 2007 1:27 pm

Postby optiluca » Tue Sep 11, 2007 2:34 pm

Code: Select all
gcc -v -Wall -std=gnu99 -g -ggdb -D_NXT_LITTLE_ENDIAN -c -Os -fPIC -I. -Iopt/sun-jdk-1.6.0.02/include -I/opt/sun-jdk-1.6.0.02/include/linux main_jlibnxt.c
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.2.0/work/gcc-4.2.0/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --enable-multilib --enable-libmudflap --disable-libssp --enable-languages=c,c++,java,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.2.0 (Gentoo 4.2.0 p1.4)
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.2.0/cc1 -quiet -v -I. -Iopt/sun-jdk-1.6.0.02/include -I/opt/sun-jdk-1.6.0.02/include/linux -D_NXT_LITTLE_ENDIAN main_jlibnxt.c -quiet -dumpbase main_jlibnxt.c -mtune=generic -auxbase main_jlibnxt -g -ggdb -Os -Wall -std=gnu99 -version -fPIC -o /tmp/ccFmzwpR.s
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/include"
ignoring nonexistent directory "opt/sun-jdk-1.6.0.02/include"
#include "..." search starts here:
#include <...> search starts here:
 .
 /opt/sun-jdk-1.6.0.02/include/linux
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include
 /usr/include
End of search list.
GNU C version 4.2.0 (Gentoo 4.2.0 p1.4) (x86_64-pc-linux-gnu)
        compiled by GNU C version 4.2.0 (Gentoo 4.2.0 p1.4).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 47ec019bb611c90bc79276754626830e
main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1find':
main_jlibnxt.c:54: warning: cast from pointer to integer of different size
main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1open':
main_jlibnxt.c:61: warning: cast to pointer from integer of different size
main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1close':
main_jlibnxt.c:67: warning: cast to pointer from integer of different size
main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1send_1data':
main_jlibnxt.c:81: warning: cast to pointer from integer of different size
main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1read_1data':
main_jlibnxt.c:97: warning: cast to pointer from integer of different size
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy -o main_jlibnxt.o /tmp/ccFmzwpR.s
GNU assembler version 2.18.50.0.1 (x86_64-pc-linux-gnu) using BFD version (Linux/GNU Binutils) 2.18.50.0.1.20070908


Thanks for your time
optiluca
Novice
 
Posts: 44
Joined: Wed Jul 18, 2007 6:12 pm

Postby lawrie » Tue Sep 11, 2007 8:13 pm

There was a typo in the command line that NVRAM suggested.

-Iopt/sun-jdk-1.6.0.02/include should have been -I/opt/sun-jdk-1.6.0.02/include

Try it with that.

However, unless there were any other errors, it looks as if the compile worked. Is there now a file, libjlibnxt.so, in src/libnxt?

If there is move it to the NXJ bin directory.

I don't know why the ant build did not work for you.
lawrie
leJOS Team Member
 
Posts: 840
Joined: Mon Feb 05, 2007 1:27 pm

Postby Shawn » Wed Sep 12, 2007 7:34 am

Code: Select all
 
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/jlibnxt.h:2:17: error: jni.h: No such   
...


Ok here is the mother-of-all hacks.
Put:
jni.h
jni_md.h

in the :
../lejos_nxj/src/jbluez
../lejos_nxj/src/libnxt

folders.

Physically copy them there.

Worked for me using 0.4
Had been getting the same error as you.

rei@rei-desktop:~/lejos_nxj/src/jbluez$ ls
build.xml jbluez.c jbluez.o jni_md.h makefile
history.xml jbluez.h jni.h libjbluez.so

rei@rei-desktop:~/lejos_nxj/src/libnxt$ ls
AUTHORS flash.c libjlibnxt.so main_runc.c
build.xml flash.h libnxt.a main_sambaget.c
COPYING flash.o lowlevel.c make_flash_header.py
docs flash_routine.h lowlevel.h nxjflash
error.c flash_routine.h.base lowlevel.o README
error.h flash_write main_fwflash.c samba.c
error.o history.xml main_jlibnxt.c samba.h
firmware.c jlibnxt.h main_jlibnxt.o samba.o
firmware.h jni.h main_nxjflash.c SConstruct
firmware.o jni_md.h main_nxjflash.o


Shawn
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby NVRAM » Thu Sep 13, 2007 6:12 am

lawrie wrote:There was a typo in the command line that NVRAM suggested.
-Iopt/sun-jdk-1.6.0.02/include should have been -I/opt/sun-jdk-1.6.0.02/include

Geez, my bad. Sorry.

optiluca -- did you try this:
export C_INCLUDE_DIRECTORY=.:/opt/sun-jdk-1.6.0.02/include:/opt/sun-jdk-1.6.0.02/include/linux
before trying ant? Did it work? What about the (revised) gcc command?
NVRAM
New User
 
Posts: 17
Joined: Tue Aug 21, 2007 5:25 am

Postby NVRAM » Thu Sep 13, 2007 10:12 pm

I wrote:optiluca -- did you try this:
export C_INCLUDE_DIRECTORY=.:/opt/sun-jdk-1.6.0.02/include:/opt/sun-jdk-1.6.0.02/include/linux
before trying ant? Did it work? What about the (revised) gcc command?

Aaarrrggg!!! Double snafu. I had the wrong environment variable name! I'm really sorry.

But, presuming you set JAVA_HOME set, you should use something like this:
export JAVA_HOME=/opt/sun-jdk-1.6.0.02
# Yours may vary
export C_INCLUDE_PATH=.:${JAVA_HOME}/include:${JAVA_HOME}/include/linux
export PATH=$PATH:${JAVA_HOME}/bin

Actually, you could put this into a file named /etc/profile.d/jdk.sh (presuming that is where your profile add-ons go).

BTW, I moved the "jni.h" and "jni_md.h" files from the libgjc-devel package out of the way and tried this (with a different JAVA_HOME), and it did work for me, using 0.4.0...

Again, sorry for the confusion,
NVRAM
NVRAM
New User
 
Posts: 17
Joined: Tue Aug 21, 2007 5:25 am

Postby optiluca » Thu Sep 13, 2007 10:29 pm

Code: Select all
luca@optilaptop ~ $ export JAVA_HOME=/opt/sun-jdk-1.6.0.02
luca@optilaptop ~ $ export C_INCLUDE_PATH=.:${JAVA_HOME}/include:${JAVA_HOME}/include/linux
luca@optilaptop ~ $ export PATH=$PATH:${JAVA_HOME}/bin
luca@optilaptop ~ $ cd bin/lejos_nxj/src/libnxt/
luca@optilaptop ~/bin/lejos_nxj/src/libnxt $ gcc -v -Wall -std=gnu99 -g -ggdb -D_NXT_LITTLE_ENDIAN -c -Os -fPIC -I. -I/opt/sun-jdk-1.6.0.02/include -I/opt/sun-jdk-1.6.0.02/include/linux main_jlibnxt.c
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.2.0/work/gcc-4.2.0/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --enable-multilib --enable-libmudflap --disable-libssp --enable-languages=c,c++,java,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.2.0 (Gentoo 4.2.0 p1.4)
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.2.0/cc1 -quiet -v -I. -I/opt/sun-jdk-1.6.0.02/include -I/opt/sun-jdk-1.6.0.02/include/linux -D_NXT_LITTLE_ENDIAN main_jlibnxt.c -quiet -dumpbase main_jlibnxt.c -mtune=generic -auxbase main_jlibnxt -g -ggdb -Os -Wall -std=gnu99 -version -fPIC -o /tmp/ccXgrF7C.s
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/include"
ignoring duplicate directory "."
  as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/opt/sun-jdk-1.6.0.02/include"
  as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/opt/sun-jdk-1.6.0.02/include/linux"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 .
 /opt/sun-jdk-1.6.0.02/include
 /opt/sun-jdk-1.6.0.02/include/linux
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include
 /usr/include
End of search list.
GNU C version 4.2.0 (Gentoo 4.2.0 p1.4) (x86_64-pc-linux-gnu)
        compiled by GNU C version 4.2.0 (Gentoo 4.2.0 p1.4).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 47ec019bb611c90bc79276754626830e
main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1find':
main_jlibnxt.c:54: warning: cast from pointer to integer of different size
main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1open':
main_jlibnxt.c:61: warning: cast to pointer from integer of different size
main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1close':
main_jlibnxt.c:67: warning: cast to pointer from integer of different size
main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1send_1data':
main_jlibnxt.c:81: warning: cast to pointer from integer of different size
main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1read_1data':
main_jlibnxt.c:97: warning: cast to pointer from integer of different size
main_jlibnxt.c:104: warning: assignment from incompatible pointer type
main_jlibnxt.c:105: warning: passing argument 2 of '(*env)->SetByteArrayRegion' from incompatible pointer type
main_jlibnxt.c:106: warning: return from incompatible pointer type
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy -o main_jlibnxt.o /tmp/ccXgrF7C.s
GNU assembler version 2.18 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.18
luca@optilaptop ~/bin/lejos_nxj/src/libnxt $ ls
AUTHORS     firmware.o            libnxt.a         main_runc.c
build.xml   flash.c               lowlevel.c       main_sambaget.c
COPYING     flash.h               lowlevel.h       make_flash_header.py
docs        flash.o               lowlevel.o       nxjflash
error.c     flash_routine.h       main_fwflash.c   README
error.h     flash_routine.h.base  main_jlibnxt.c   samba.c
error.o     flash_write           main_jlibnxt.o   samba.h
firmware.c  history.xml           main_nxjflash.c  samba.o
firmware.h  jlibnxt.h             main_nxjflash.o  SConstruct


Also tried running ant, but it miserably fails again...

Code: Select all
luca@optilaptop ~ $ ls bin/lejos_nxj/src/jbluez/
build.xml  jbluez.c  jbluez.h  jni.h  jni_md.h  makefile

Code: Select all
luca@optilaptop ~ $ ls bin/lejos_nxj/src/libnxt/
AUTHORS     firmware.h            history.xml  main_fwflash.c        nxjflash
build.xml   firmware.o            jlibnxt.h    main_jlibnxt.c        README
COPYING     flash.c               jni.h        main_jlibnxt.o        samba.c
docs        flash.h               jni_md.h     main_nxjflash.c       samba.h
error.c     flash.o               libnxt.a     main_nxjflash.o       samba.o
error.h     flash_routine.h       lowlevel.c   main_runc.c           SConstruct
error.o     flash_routine.h.base  lowlevel.h   main_sambaget.c
firmware.c  flash_write           lowlevel.o   make_flash_header.py

Code: Select all
ant
Buildfile: build.xml

clean:
     [echo] saving existing files to .bak files

libnxt:

clean:

libnxt:
       [cc] 5 total files to be compiled.
       [cc] Starting link
       [cc] a - samba.o
       [cc] a - flash.o
       [cc] a - error.o
       [cc] a - lowlevel.o
       [cc] a - firmware.o
       [cc] ar: creating libnxt.a

nxjflash:
       [cc] 1 total files to be compiled.
       [cc] Starting link

jlibnxt:
       [cc] 1 total files to be compiled.
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1find':
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c:54: warning: cast from pointer to integer of different size
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1open':
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c:61: warning: cast to pointer from integer of different size
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1close':
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c:67: warning: cast to pointer from integer of different size
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1send_1data':
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c:81: warning: cast to pointer from integer of different size
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1read_1data':
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c:97: warning: cast to pointer from integer of different size
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c:104: warning: assignment from incompatible pointer type
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c:105: warning: passing argument 2 of '(*env)->SetByteArrayRegion' from incompatible pointer type
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c:106: warning: return from incompatible pointer type
       [cc] Starting link
       [cc] /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /home/luca/bin/lejos_nxj/src/libnxt/libnxt.a(lowlevel.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/libnxt.a: could not read symbols: Bad value
       [cc] collect2: ld returned 1 exit status

BUILD FAILED
/home/luca/bin/lejos_nxj/build/build.xml:65: The following error occurred while executing this line:
/home/luca/bin/lejos_nxj/src/libnxt/build.xml:126: gcc failed with return code 1

Total time: 2 seconds


Yes i did
Code: Select all
 export C_INCLUDE_DIRECTORY=.:/opt/sun-jdk-1.6.0.02/include:/opt/sun-jdk-1.6.0.02/include/linux
before that...

I'm starting to think I'm doing something wrong... Anyone know what??

Sorry for my n00bness...

Thanks for your time

Luca :oops:
optiluca
Novice
 
Posts: 44
Joined: Wed Jul 18, 2007 6:12 pm

Postby NVRAM » Fri Sep 14, 2007 3:05 pm

optiluca wrote:Also tried running ant, but it miserably fails again...

No! It's working well, you've gotten the compiler/environment problems ironed out! Typically, with remote support (like forums, email, even by phone) that's much harder!

Now you just have the build script problems left, and that problem should be duplicatable by many others. However -- you're on a 64-bit system and I don't have access to one.

The jist of the problem is that the code is casting pointers to a 32-bit integer. If you can compile it for 32-bit instead, you should be on your way.
optiluca wrote: [cc] 1 total files to be compiled.
[cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c: In function 'Java_lejos_pc_comm_NXTCommLibnxt_jlibnxt_1find':
[cc] /home/luca/bin/lejos_nxj/src/libnxt/main_jlibnxt.c:54: warning: cast from pointer to integer of different size[/code]
I'm starting to think I'm doing something wrong... Anyone know what??

Okay, I'm not sure how to force GCC to compile 32 bit code on a 64-bit system, but try this:
    1. Run man gcc and see what parameter is needed to force 32-bit compilation and linking; my cursory search makes me think it's "-m32" but if that's wrong, then adjust the following.
    2. Make a backup of, then edit the four 'build.xml' files: build/build.xml src/jbluez/build.xml src/libnxt/build.xml src/nxtvm/platform/unix/build.xml -- and after every line with <compilerarg value="-g"/>, add a similar line with <compilerarg value="-m32"/> (You probably should add <compilerarg value="-v"/> too, just for debugging.)
    3. Build with ant, making sure you've set your C_INCLUDE_PATH envar.


Good luck!
NVRAM
New User
 
Posts: 17
Joined: Tue Aug 21, 2007 5:25 am

Postby NVRAM » Fri Sep 14, 2007 3:18 pm

optiluca wrote:
Code: Select all
       [cc] Starting link
       [cc] /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /home/luca/bin/lejos_nxj/src/libnxt/libnxt.a(lowlevel.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
       [cc] /home/luca/bin/lejos_nxj/src/libnxt/libnxt.a: could not read symbols: Bad value


As a SWAG -- you may also need to add <compilerarg value="-fPIC"/> flags, so ifcompiling as 32-bit fails, try adding that, too.

Good luck
NVRAM
New User
 
Posts: 17
Joined: Tue Aug 21, 2007 5:25 am

Postby Shawn » Fri Sep 14, 2007 4:56 pm

Sorry for my n00bness...


No, no you are doing great!

I tried under CentOS86_64 and saw a similar error.

I tried the recent two suggestions over this and got:
(more importantly though, what do you get? -- as I mentioned I got it to compile under an Ubuntu 32 bit system - but kinda want it in this env too.)


libnxt:
[cc] 5 total files to be compiled.
[cc] Starting link
[cc] a - samba.o
[cc] a - flash.o
[cc] a - error.o
[cc] a - lowlevel.o
[cc] a - firmware.o
[cc] /usr/bin/ar: creating libnxt.a
nxjflash:
[cc] 1 total files to be compiled.
[cc] Starting link
[cc] /usr/bin/ld: skipping incompatible /home/javauser/Rei/lego/lejos_nxj/src/libnxt/libnxt.a when searching for -lnxt
[cc] /usr/bin/ld: cannot find -lnxt
[cc] collect2: ld returned 1 exit status
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby CoBB » Fri Sep 14, 2007 9:52 pm

Are you guys sure this code can be compiled on a 64-bit architecture without modifications? You might probably want to change jint to jlong where applicable.
User avatar
CoBB
Novice
 
Posts: 73
Joined: Tue Apr 24, 2007 12:24 pm

Postby optiluca » Sat Sep 15, 2007 11:57 am

Code: Select all
luca@optilaptop ~ $ export JAVA_HOME=/opt/sun-jdk-1.6.0.02
luca@optilaptop ~ $ export C_INCLUDE_PATH=.:${JAVA_HOME}/include:${JAVA_HOME}/include/linux
luca@optilaptop ~ $ export PATH=$PATH:${JAVA_HOME}/bin
luca@optilaptop ~/bin/lejos_nxj/src/libnxt $  export C_INCLUDE_DIRECTORY=.:/opt/sun-jdk-1.6.0.02/include:/opt/sun-jdk-1.6.0.02/include/linux
luca@optilaptop ~/bin/lejos_nxj $ cd build/
luca@optilaptop ~/bin/lejos_nxj/build $ ant
Buildfile: build.xml

clean:
     [echo] saving existing files to .bak files

libnxt:

clean:

libnxt:
       [cc] 5 total files to be compiled.
       [cc] Using built-in specs.
       [cc] Target: x86_64-pc-linux-gnu
       [cc] Configured with: /var/tmp/portage/sys-devel/gcc-4.2.0/work/gcc-4.2.0/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --enable-multilib --enable-libmudflap --disable-libssp --enable-languages=c,c++,java,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
       [cc] Thread model: posix
       [cc] gcc version 4.2.0 (Gentoo 4.2.0 p1.4)
       [cc]  /usr/libexec/gcc/x86_64-pc-linux-gnu/4.2.0/cc1 -quiet -v -I/home/luca/bin/lejos_nxj/src/libnxt -imultilib 32 -D_NXT_LITTLE_ENDIAN /home/luca/bin/lejos_nxj/src/libnxt/samba.c -quiet -dumpbase samba.c -m32 -mtune=generic -auxbase samba -g -ggdb -Os -Wall -std=gnu99 -version -fPIC -o /tmp/ccAlVY55.s
       [cc] ignoring nonexistent directory "/usr/local/include"
       [cc] ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/include"
       [cc] ignoring duplicate directory "/home/luca/bin/lejos_nxj/src/libnxt"
       [cc]   as it is a non-system directory that duplicates a system directory
       [cc] #include "..." search starts here:
       [cc] #include <...> search starts here:
       [cc]  .
       [cc]  /opt/sun-jdk-1.6.0.02/include
       [cc]  /opt/sun-jdk-1.6.0.02/include/linux
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include
       [cc]  /usr/include
       [cc] End of search list.
       [cc] GNU C version 4.2.0 (Gentoo 4.2.0 p1.4) (x86_64-pc-linux-gnu)
       [cc]     compiled by GNU C version 4.2.0 (Gentoo 4.2.0 p1.4).
       [cc] GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
       [cc] Compiler executable checksum: d6ee7d1ccd204f46b6eeefedfe06bc67
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy --32 -o samba.o /tmp/ccAlVY55.s
       [cc] GNU assembler version 2.18 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.18
       [cc]  /usr/libexec/gcc/x86_64-pc-linux-gnu/4.2.0/cc1 -quiet -v -I/home/luca/bin/lejos_nxj/src/libnxt -imultilib 32 -D_NXT_LITTLE_ENDIAN /home/luca/bin/lejos_nxj/src/libnxt/flash.c -quiet -dumpbase flash.c -m32 -mtune=generic -auxbase flash -g -ggdb -Os -Wall -std=gnu99 -version -fPIC -o /tmp/ccAlVY55.s
       [cc] ignoring nonexistent directory "/usr/local/include"
       [cc] ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/include"
       [cc] ignoring duplicate directory "/home/luca/bin/lejos_nxj/src/libnxt"
       [cc]   as it is a non-system directory that duplicates a system directory
       [cc] #include "..." search starts here:
       [cc] #include <...> search starts here:
       [cc]  .
       [cc]  /opt/sun-jdk-1.6.0.02/include
       [cc]  /opt/sun-jdk-1.6.0.02/include/linux
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include
       [cc]  /usr/include
       [cc] End of search list.
       [cc] GNU C version 4.2.0 (Gentoo 4.2.0 p1.4) (x86_64-pc-linux-gnu)
       [cc]     compiled by GNU C version 4.2.0 (Gentoo 4.2.0 p1.4).
       [cc] GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
       [cc] Compiler executable checksum: d6ee7d1ccd204f46b6eeefedfe06bc67
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy --32 -o flash.o /tmp/ccAlVY55.s
       [cc] GNU assembler version 2.18 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.18
       [cc]  /usr/libexec/gcc/x86_64-pc-linux-gnu/4.2.0/cc1 -quiet -v -I/home/luca/bin/lejos_nxj/src/libnxt -imultilib 32 -D_NXT_LITTLE_ENDIAN /home/luca/bin/lejos_nxj/src/libnxt/error.c -quiet -dumpbase error.c -m32 -mtune=generic -auxbase error -g -ggdb -Os -Wall -std=gnu99 -version -fPIC -o /tmp/ccAlVY55.s
       [cc] ignoring nonexistent directory "/usr/local/include"
       [cc] ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/include"
       [cc] ignoring duplicate directory "/home/luca/bin/lejos_nxj/src/libnxt"
       [cc]   as it is a non-system directory that duplicates a system directory
       [cc] #include "..." search starts here:
       [cc] #include <...> search starts here:
       [cc]  .
       [cc]  /opt/sun-jdk-1.6.0.02/include
       [cc]  /opt/sun-jdk-1.6.0.02/include/linux
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include
       [cc]  /usr/include
       [cc] End of search list.
       [cc] GNU C version 4.2.0 (Gentoo 4.2.0 p1.4) (x86_64-pc-linux-gnu)
       [cc]     compiled by GNU C version 4.2.0 (Gentoo 4.2.0 p1.4).
       [cc] GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
       [cc] Compiler executable checksum: d6ee7d1ccd204f46b6eeefedfe06bc67
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy --32 -o error.o /tmp/ccAlVY55.s
       [cc] GNU assembler version 2.18 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.18
       [cc]  /usr/libexec/gcc/x86_64-pc-linux-gnu/4.2.0/cc1 -quiet -v -I/home/luca/bin/lejos_nxj/src/libnxt -imultilib 32 -D_NXT_LITTLE_ENDIAN /home/luca/bin/lejos_nxj/src/libnxt/lowlevel.c -quiet -dumpbase lowlevel.c -m32 -mtune=generic -auxbase lowlevel -g -ggdb -Os -Wall -std=gnu99 -version -fPIC -o /tmp/ccAlVY55.s
       [cc] ignoring nonexistent directory "/usr/local/include"
       [cc] ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/include"
       [cc] ignoring duplicate directory "/home/luca/bin/lejos_nxj/src/libnxt"
       [cc]   as it is a non-system directory that duplicates a system directory
       [cc] #include "..." search starts here:
       [cc] #include <...> search starts here:
       [cc]  .
       [cc]  /opt/sun-jdk-1.6.0.02/include
       [cc]  /opt/sun-jdk-1.6.0.02/include/linux
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include
       [cc]  /usr/include
       [cc] End of search list.
       [cc] GNU C version 4.2.0 (Gentoo 4.2.0 p1.4) (x86_64-pc-linux-gnu)
       [cc]     compiled by GNU C version 4.2.0 (Gentoo 4.2.0 p1.4).
       [cc] GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
       [cc] Compiler executable checksum: d6ee7d1ccd204f46b6eeefedfe06bc67
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy --32 -o lowlevel.o /tmp/ccAlVY55.s
       [cc] GNU assembler version 2.18 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.18
       [cc]  /usr/libexec/gcc/x86_64-pc-linux-gnu/4.2.0/cc1 -quiet -v -I/home/luca/bin/lejos_nxj/src/libnxt -imultilib 32 -D_NXT_LITTLE_ENDIAN /home/luca/bin/lejos_nxj/src/libnxt/firmware.c -quiet -dumpbase firmware.c -m32 -mtune=generic -auxbase firmware -g -ggdb -Os -Wall -std=gnu99 -version -fPIC -o /tmp/ccAlVY55.s
       [cc] ignoring nonexistent directory "/usr/local/include"
       [cc] ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/include"
       [cc] ignoring duplicate directory "/home/luca/bin/lejos_nxj/src/libnxt"
       [cc]   as it is a non-system directory that duplicates a system directory
       [cc] #include "..." search starts here:
       [cc] #include <...> search starts here:
       [cc]  .
       [cc]  /opt/sun-jdk-1.6.0.02/include
       [cc]  /opt/sun-jdk-1.6.0.02/include/linux
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include
       [cc]  /usr/include
       [cc] End of search list.
       [cc] GNU C version 4.2.0 (Gentoo 4.2.0 p1.4) (x86_64-pc-linux-gnu)
       [cc]     compiled by GNU C version 4.2.0 (Gentoo 4.2.0 p1.4).
       [cc] GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
       [cc] Compiler executable checksum: d6ee7d1ccd204f46b6eeefedfe06bc67
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy --32 -o firmware.o /tmp/ccAlVY55.s
       [cc] GNU assembler version 2.18 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.18
       [cc] Starting link
       [cc] ar: creating libnxt.a
       [cc] a - samba.o
       [cc] a - flash.o
       [cc] a - error.o
       [cc] a - lowlevel.o
       [cc] a - firmware.o

nxjflash:
       [cc] 1 total files to be compiled.
       [cc] Using built-in specs.
       [cc] Target: x86_64-pc-linux-gnu
       [cc] Configured with: /var/tmp/portage/sys-devel/gcc-4.2.0/work/gcc-4.2.0/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --enable-multilib --enable-libmudflap --disable-libssp --enable-languages=c,c++,java,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
       [cc] Thread model: posix
       [cc] gcc version 4.2.0 (Gentoo 4.2.0 p1.4)
       [cc]  /usr/libexec/gcc/x86_64-pc-linux-gnu/4.2.0/cc1 -quiet -v -I/home/luca/bin/lejos_nxj/src/libnxt -imultilib 32 -D_NXT_LITTLE_ENDIAN /home/luca/bin/lejos_nxj/src/libnxt/main_nxjflash.c -quiet -dumpbase main_nxjflash.c -m32 -mtune=generic -auxbase main_nxjflash -g -ggdb -Os -Wall -std=gnu99 -version -fPIC -o /tmp/cckdKJyO.s
       [cc] ignoring nonexistent directory "/usr/local/include"
       [cc] ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/include"
       [cc] ignoring duplicate directory "/home/luca/bin/lejos_nxj/src/libnxt"
       [cc]   as it is a non-system directory that duplicates a system directory
       [cc] #include "..." search starts here:
       [cc] #include <...> search starts here:
       [cc]  .
       [cc]  /opt/sun-jdk-1.6.0.02/include
       [cc]  /opt/sun-jdk-1.6.0.02/include/linux
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/include
       [cc]  /usr/include
       [cc] End of search list.
       [cc] GNU C version 4.2.0 (Gentoo 4.2.0 p1.4) (x86_64-pc-linux-gnu)
       [cc]     compiled by GNU C version 4.2.0 (Gentoo 4.2.0 p1.4).
       [cc] GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
       [cc] Compiler executable checksum: d6ee7d1ccd204f46b6eeefedfe06bc67
       [cc]  /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy --32 -o main_nxjflash.o /tmp/cckdKJyO.s
       [cc] GNU assembler version 2.18 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.18
       [cc] Starting link
       [cc] /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: skipping incompatible /home/luca/bin/lejos_nxj/src/libnxt/libnxt.a when searching for -lnxt
       [cc] /usr/lib/gcc/x86_64-pc-linux-gnu/4.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lnxt
       [cc] collect2: ld returned 1 exit status

BUILD FAILED
/home/luca/bin/lejos_nxj/build/build.xml:65: The following error occurred while executing this line:
/home/luca/bin/lejos_nxj/src/libnxt/build.xml:105: gcc failed with return code 1

Total time: 1 second


This is after adding the 3 compilerarg lines to src/jbluez/build.xml and src/libnxt/build.xml. The other two files didn't have a <compilerarg value="-g"/> line, so weren't edited.


Has anyone succeed in getting this working in a 64 bit environment??

Thanks for all your help

Luca
optiluca
Novice
 
Posts: 44
Joined: Wed Jul 18, 2007 6:12 pm

PreviousNext

Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff