yesterday I successfully build mtdev2tuio, but there were still some warnings left. So today I try to resolve these warnings.
There are 4 warning of 3 types.
the first one is "Attempt to use kernel headers from user space"
check the website
The problem comes from using wrong header files. To solve this problem, we should make our gcc to use correct include path.
In our bsp, go to root of kernel and type the command
sudo make headers_install ARCH=arm INSTALL_HDR_PATH=./usr/
It will generate header files of the kernel
check the usr directory and we find the include directory in it, good.
next, in our make file, we have to add this path for gcc while compiling
arm-none-linux-gnueabi-gcc -nostdlib -I/media/DM8134/src/board-support/linux-2.6.37-psp04.04.00.01/usr/include/ -I/mnt/hgfs/share/qtuio/liblo/include/ -I/mnt/hgfs/share/qtuio/mtdev-1.1.2/include -c mtdev2tuio.c
check the result, the warning disappeared, great!!
Next, let's take a look of these two warnings
e-linux-gnueabi-ld: warning: library search path "/usr/local/lib/liblo/lib/" is unsafe for cross-compilation
arm-none-linux-gnueabi-ld: warning: library search path "/usr/local/lib/mtdev/lib/" is unsafe for cross-compilation
These warnings come with (probably) wrong lib path setting. We cross compile object files for TI DM8134 (ARM arch) but out library refer to the path of Ubuntu(i386). It seems something wrong.
While I started to port TUIO to DM8134, I found a great reference. The author told us to cross compile necessary libs (liblo, mtdev), install them to /usr/local/lib/, and then load them in the linking stage. It is not wrong, but it is very dirty.
The better way to solve these two warnings is to set the install path of libs to our development directory. In this case, it is under targetfs/usr/lib/. So first, install them to targetfs/usr/lib/.
Second, add the path to our ld command
arm-none-linux-gnueabi-ld mtdev2tuio.o -o mtdev2tuio -L/media/DM8134/targetfs/usr/lib/liblo/lib/ -L/media/DM8134/targetfs/usr/lib/mtdev/lib/ -lmtdev -llo -lc -lgcc_s -lm
check the result again
the warning disappeared
Wwwonderful!!
Last, the warning
warning: cannot find entry symbol _start; defaulting to 000096e0
please refer to this website
add "--entry main" to tell ld what the entry function is
arm-none-linux-gnueabi-ld --entry main mtdev2tuio.o -o mtdev2tuio -L/media/DM8134/targetfs/usr/lib/liblo/lib/ -L/media/DM8134/targetfs/usr/lib/mtdev/lib/ -lmtdev -llo -lc -lgcc_s -lm
OK, we can see all warnings generated from gcc and ld are cleared.
P.S. there is still a warning, this is because I use VM to develop, and it seems cause the clock skew.
2014年8月29日 星期五
2014年8月28日 星期四
cross compile mtdev2tuio for TI DM8134
refer to this article
Building mtdev2tuio needs header files of mtdev and liblo, since these two packages are built and install into directories respectively. We can add -I option to gcc command
arm-none-linux-gnueabi-gcc -I/mnt/hgfs/share/qtuio/liblo/include/ -I/mnt/hgfs/share/qtuio/mtdev-1.1.2/include -c mtdev2tuio.c
and we can find the object file is generated (mtdev2tuio.o).
next, link corresponding libs to generate executable.
mtdev and liblo was made and installed into its directories, so we can use -L to load the path and -l to load the lib
arm-none-linux-gnueabi-ld -o mtdev2tuio mtdev2tuio.o -L/media/DM8134/targetfs/lib -L/usr/lib/liblo/lib/ -L/usr/local/lib/mtdev/lib/ -lmtdev -llo
and we get
God damn it! I never got so many errors in one make.
No worry. It seems that we lack of some libs (printf, free)
so add -lc to add libc into the link stage
arm-none-linux-gnueabi-ld -o mtdev2tuio mtdev2tuio.o -L/media/DM8134/targetfs/lib -L/usr/lib/liblo/lib/ -L/usr/local/lib/mtdev/lib/ -lmtdev -llo -lc
again, we get a bunch of error messages.
no worry. Just search Google and it give us a good result as usual
the error message is about lacking libs of gcc, so find something looks like "libgcc" in our building environment
and we found there is a libgcc_s in lib, that is it. add it into our link command
arm-none-linux-gnueabi-ld -o mtdev2tuio mtdev2tuio.o -L/media/DM8134/targetfs/lib -L/usr/lib/liblo/lib/ -L/usr/local/lib/mtdev/lib/ -lmtdev -llo -lc -lgcc_s
press enter! unfortunately there are still errors while linking.
Search Google and I found it
add -lm to the command
arm-none-linux-gnueabi-ld -o mtdev2tuio mtdev2tuio.o -L/media/DM8134/targetfs/lib -L/usr/lib/liblo/lib/ -L/usr/local/lib/mtdev/lib/ -lmtdev -llo -lc -lgcc_s -lm
and we can find the binary is generated
There are still 3 warnings while linking.
Leave it tomorrow.
:Q
Building mtdev2tuio needs header files of mtdev and liblo, since these two packages are built and install into directories respectively. We can add -I option to gcc command
arm-none-linux-gnueabi-gcc -I/mnt/hgfs/share/qtuio/liblo/include/ -I/mnt/hgfs/share/qtuio/mtdev-1.1.2/include -c mtdev2tuio.c
next, link corresponding libs to generate executable.
mtdev and liblo was made and installed into its directories, so we can use -L to load the path and -l to load the lib
arm-none-linux-gnueabi-ld -o mtdev2tuio mtdev2tuio.o -L/media/DM8134/targetfs/lib -L/usr/lib/liblo/lib/ -L/usr/local/lib/mtdev/lib/ -lmtdev -llo
and we get
God damn it! I never got so many errors in one make.
No worry. It seems that we lack of some libs (printf, free)
so add -lc to add libc into the link stage
arm-none-linux-gnueabi-ld -o mtdev2tuio mtdev2tuio.o -L/media/DM8134/targetfs/lib -L/usr/lib/liblo/lib/ -L/usr/local/lib/mtdev/lib/ -lmtdev -llo -lc
again, we get a bunch of error messages.
no worry. Just search Google and it give us a good result as usual
the error message is about lacking libs of gcc, so find something looks like "libgcc" in our building environment
and we found there is a libgcc_s in lib, that is it. add it into our link command
arm-none-linux-gnueabi-ld -o mtdev2tuio mtdev2tuio.o -L/media/DM8134/targetfs/lib -L/usr/lib/liblo/lib/ -L/usr/local/lib/mtdev/lib/ -lmtdev -llo -lc -lgcc_s
press enter! unfortunately there are still errors while linking.
Search Google and I found it
add -lm to the command
arm-none-linux-gnueabi-ld -o mtdev2tuio mtdev2tuio.o -L/media/DM8134/targetfs/lib -L/usr/lib/liblo/lib/ -L/usr/local/lib/mtdev/lib/ -lmtdev -llo -lc -lgcc_s -lm
and we can find the binary is generated
There are still 3 warnings while linking.
Leave it tomorrow.
:Q
cross compile mtdev for TI DM8134
while making mtdev, the error log shows that
'const struct input_absinfo' has no member named 'resolution'
so check the include file first
go to the include directory, and type the command : $CC -M mtdev.h to get the path of all header files
the result is as follows
we can find that the file input.h is from CodeSourcery directory. We want to reference it from our source tree(/media/DM8134/src/...). So I set the env parameter
export C_INCLUDE_PATH=/media/DM8134/src/board-support/linux-2.6.37-psp04.04.00.01/include
observe the parameter
C_INCLUDE_PATH is now set
make again
OK, we got a new error message.
error: asm/bitsperlong.h: No such file or directory
check my include path again, I find there is a "asm-generic" directory in it but no "asm" directory.
brute force!! copy asm-generic to asm
OK
make again
so it seems that it can be built now
go to upper (mtdev) directory, make and install
make
lot of warnings...
make install
remember to set PATH parameter when using sudo to make install
sudo env PATH=$PATH make install
all files are installed into corresponding directories under /usr/local/lib/mtdev/
done!!
見招拆招!!
'const struct input_absinfo' has no member named 'resolution'
go to the include directory, and type the command : $CC -M mtdev.h to get the path of all header files
the result is as follows
we can find that the file input.h is from CodeSourcery directory. We want to reference it from our source tree(/media/DM8134/src/...). So I set the env parameter
export C_INCLUDE_PATH=/media/DM8134/src/board-support/linux-2.6.37-psp04.04.00.01/include
observe the parameter
C_INCLUDE_PATH is now set
make again
OK, we got a new error message.
error: asm/bitsperlong.h: No such file or directory
check my include path again, I find there is a "asm-generic" directory in it but no "asm" directory.
brute force!! copy asm-generic to asm
OK
make again
so it seems that it can be built now
go to upper (mtdev) directory, make and install
make
lot of warnings...
make install
remember to set PATH parameter when using sudo to make install
sudo env PATH=$PATH make install
all files are installed into corresponding directories under /usr/local/lib/mtdev/
done!!
見招拆招!!
訂閱:
文章 (Atom)