LINUX.ORG.RU

Избранные сообщения usr_Vladmir

Возможно ли както скомпилить модуль ядра с параметром -DDEBUG для ядра 2.6

Форум — Development

Модуль для ядра 2.6 компилируется командой

make -C $(KDIR) M=$(PWD) modules

make -C $(KDIR) M=$(PWD) modules -DDEBUG
make: invalid option — 'D'

В коде модуля ядра хочется отключать отладочный вывод команды printk. Где-то натыкался на примеры с книжки только там для ядра 2.0 и компиляция соответственно осуществлялась по другому.

#ifdef DEBUG
  printk("DEBUG");
#endif

Можно ли как то управлять сборкой со своими параметрами под ядро 2.6.

usr_Vladmir
()

Не собирается прога с использованием libusb-1.0.9

Форум — Development

Здравствуйте Пытаюсь скомпилировать такой код:

#include <stdio.h>
#include <stdlib.h>
#include <libusb.h>

int main(void)
{
struct usb_bus *bus;
struct usb_device *dev;

libusb_init(NULL);
return 0;
}

Makefile

LIB=-L/usr/lib/libusb-1.0 -lusb-1.0 -pthread  
INC=-I/usr/include/libusb-1.0

testlibusb: testlibusb.c
	gcc -g -o $@ $@.c $(INC) $(LIB)

В ответ получаю:

[root@DSC_DKLinux> make
gcc -g -o testlibusb testlibusb.c -I/usr/include/libusb-1.0 -L/usr/lib/libusb-1.0 -lusb-1.0 -pthread  
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../libusb-1.0.so: undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
make: *** [testlibusb] Error 1

Собственно не пойму в чем проблема (undefined reference to `clock_gettime')? Что-нужно чтобы скомпилировать.

Вроде установка библиотеки прошла нормально. Библиотеку взял отсюда: http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.9/libusb-1.0.9.tar.bz2

Вот собственно процесс установки

[root@DSC_DKLinux> cd /mnt/hd3/distr/libusb-1.0.9
[root@DSC_DKLinux> ./configure --prefix=/usr
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking build system type... i586-pc-linux-gnu
checking host system type... i586-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... no
checking for dumpbin... no
checking for link... no
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 512
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... no
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... no
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... no
checking for ranlib... no
checking command to parse nm output from gcc object... failed
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... no
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for windres... no
checking for inline... inline
checking whether gcc and cc understand -c and -o together... yes
checking operating system... Linux
checking for clock_gettime in -lrt... no
checking poll.h usability... yes
checking poll.h presence... yes
checking for poll.h... yes
checking sys/timerfd.h usability... no
checking sys/timerfd.h presence... no
checking for sys/timerfd.h... no
checking whether TFD_NONBLOCK is declared... no
checking whether to use timerfd for timing... no (header not available)
checking for struct timespec... yes
checking for sigaction... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for gettimeofday... yes
configure: creating ./config.status
config.status: creating libusb-1.0.pc
config.status: creating Makefile
config.status: creating libusb/Makefile
config.status: creating examples/Makefile
config.status: creating doc/Makefile
config.status: creating doc/doxygen.cfg
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

[root@DSC_DKLinux> make
make  all-recursive
make[1]: Entering directory `/mnt/hd3/distr/libusb-1.0.9'
Making all in libusb
make[2]: Entering directory `/mnt/hd3/distr/libusb-1.0.9/libusb'
  CCLD   libusb-1.0.la
make[2]: Leaving directory `/mnt/hd3/distr/libusb-1.0.9/libusb'
Making all in doc
make[2]: Entering directory `/mnt/hd3/distr/libusb-1.0.9/doc'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/mnt/hd3/distr/libusb-1.0.9/doc'
make[2]: Entering directory `/mnt/hd3/distr/libusb-1.0.9'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/mnt/hd3/distr/libusb-1.0.9'
make[1]: Leaving directory `/mnt/hd3/distr/libusb-1.0.9'

[root@DSC_DKLinux> make install             
Making install in libusb
make[1]: Entering directory `/mnt/hd3/distr/libusb-1.0.9/libusb'
make[2]: Entering directory `/mnt/hd3/distr/libusb-1.0.9/libusb'
test -z "/usr/lib" || .././install-sh -c -d "/usr/lib"
 /bin/sh ../libtool   --mode=install /usr/bin/install -c   libusb-1.0.la '/usr/lib'
libtool: install: /usr/bin/install -c .libs/libusb-1.0.so.0.1.0 /usr/lib/libusb-1.0.so.0.1.0
libtool: install: (cd /usr/lib && { ln -s -f libusb-1.0.so.0.1.0 libusb-1.0.so.0 || { rm -f libusb-1.0.so.0 && ln -s libusb-1.0.so.0.1.0 libusb-1.0.so.0; }; })
libtool: install: (cd /usr/lib && { ln -s -f libusb-1.0.so.0.1.0 libusb-1.0.so || { rm -f libusb-1.0.so && ln -s libusb-1.0.so.0.1.0 libusb-1.0.so; }; })
libtool: install: /usr/bin/install -c .libs/libusb-1.0.lai /usr/lib/libusb-1.0.la
libtool: install: /usr/bin/install -c .libs/libusb-1.0.a /usr/lib/libusb-1.0.a
libtool: install: chmod 644 /usr/lib/libusb-1.0.a
libtool: install: : /usr/lib/libusb-1.0.a
libtool: finish: PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/sbin" ldconfig -n /usr/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
test -z "/usr/include/libusb-1.0" || .././install-sh -c -d "/usr/include/libusb-1.0"
 /usr/bin/install -c -m 644 libusb.h '/usr/include/libusb-1.0'
make[2]: Leaving directory `/mnt/hd3/distr/libusb-1.0.9/libusb'
make[1]: Leaving directory `/mnt/hd3/distr/libusb-1.0.9/libusb'
Making install in doc
make[1]: Entering directory `/mnt/hd3/distr/libusb-1.0.9/doc'
make[2]: Entering directory `/mnt/hd3/distr/libusb-1.0.9/doc'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/mnt/hd3/distr/libusb-1.0.9/doc'
make[1]: Leaving directory `/mnt/hd3/distr/libusb-1.0.9/doc'
make[1]: Entering directory `/mnt/hd3/distr/libusb-1.0.9'
make[2]: Entering directory `/mnt/hd3/distr/libusb-1.0.9'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/lib/pkgconfig" || ./install-sh -c -d "/usr/lib/pkgconfig"
 /usr/bin/install -c -m 644 libusb-1.0.pc '/usr/lib/pkgconfig'
make[2]: Leaving directory `/mnt/hd3/distr/libusb-1.0.9'
make[1]: Leaving directory `/mnt/hd3/distr/libusb-1.0.9'

К стати примеры идущие с библиотекой тоже не собираются

[root@DSC_DKLinux> cd /mnt/hd3/distr/libusb-1.0.9/examples/
[root@DSC_DKLinux> ls
Makefile         Makefile.am      Makefile.in      dpfp.c           dpfp_threaded.c  listdevs.c       listdevs.o
[root@DSC_DKLinux> make
  CCLD   listdevs
../libusb/.libs/libusb-1.0.so: undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
make: *** [listdevs] Error 1

О системе :

[root@DSC_DKLinux> uname -a
Linux DSC_DKLinux 2.6.23 #6 Mon Sep 1 05:27:54 EDT 2008 i586 unknown
[root@DSC_DKLinux> gcc -v
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/specs
Configured with: ../gcc-3.2.3/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.2.3

Кто сталкивался с «undefined reference to `clock_gettime'» при установке libusb_1.0.9 помогите плиз. Может что-то в этом (checking for clock_gettime in -lrt... no) кроется ?

usr_Vladmir
()