I am converting a gnome panel applet to xfce panel plugin. I have so far removed the few gnome specific parts in the source and replaced them with xfce specific source as appropriate.
I created makefile.am and configure.ac files using templates such as the weather plugin and the example plugin. However I am unsuccessful in getting it compiled properly. I am probably missing something obvious, but I double checked the examples with my own files and found no obvious problems.
I have attached the appropriate files as well as output of the errors in the hope someone has an idea. I don't think the problem is in the actual source, but I can add some of that later if necessary.
Errors while compiling:
make all-recursive
make[1]: Entering directory `/source/my_example_xfce'
Making all in panel-plugin
make[2]: Entering directory `/source/my_example_xfce/panel-plugin'
gcc -DHAVE_CONFIG_H -I. -I.. -I.. -DTHEMESDIR=\"/usr/local/share/xfce4/my_example/icons\" -DPACKAGE_LOCALE_DIR=\"/usr/local/share/locale\" -DG_LOG_DOMAIN=\"my_example\" -DNDEBUG -pthread -I/usr/include/xfce4/libxfce4panel-1.0 -I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/xfce4 -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/atk-1.0 -I/usr/include/xfce4 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/xfce4 -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -g -O2 -MT xfce4_my_example_plugin-my_example.o -MD -MP -MF .deps/xfce4_my_example_plugin-my_example.Tpo -c -o xfce4_my_example_plugin-my_example.o `test -f 'my_example.c' || echo './'`my_example.c
my_example.c:25:25: warning: ‘struct Example_Data’ declared inside parameter list [enabled by default]
my_example.c:25:25: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
my_example.c: In function ‘setdefaults’:
my_example.c:28:3: warning: incompatible implicit declaration of built-in function ‘strncpy’ [enabled by default]
my_example.c:28:21: error: dereferencing pointer to incomplete type
my_example.c:28:45: warning: incompatible implicit declaration of built-in function ‘strlen’ [enabled by default]
my_example.c:28:3: warning: passing argument 1 of ‘strlen’ makes pointer from integer without a cast [enabled by default]
my_example.c:28:3: note: expected ‘const char *’ but argument is of type ‘int’
my_example.c:28:3: warning: passing argument 2 of ‘strncpy’ makes pointer from integer without a cast [enabled by default]
my_example.c:28:3: note: expected ‘const char *’ but argument is of type ‘int’
my_example.c:30:21: error: dereferencing pointer to incomplete type
my_example.c:30:42: error: dereferencing pointer to incomplete type
my_example.c:30:67: error: dereferencing pointer to incomplete type
my_example.c:31:3: warning: incompatible implicit declaration of built-in function ‘strncat’ [enabled by default]
my_example.c:31:21: error: dereferencing pointer to incomplete type
my_example.c:31:32: error: ‘SIGFILE’ undeclared (first use in this function)
SIGFILE is one of the defines in my header files. Then it goes on as if it never read my header files with all the declarations.
Last bit:
my_example.c:248:17: error: unknown type name ‘XfcePanelPlugin’
my_example.c:248:42: error: unknown type name ‘GtkWidget’
my_example.c:248:60: error: unknown type name ‘GtkWidget’
make[2]: *** [xfce4_my_example_plugin-example.o] Error 1
make[2]: Leaving directory `/source/my_example_xfce/panel-plugin'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/source/my_example_xfce'
make: *** [all] Error 2
Below I pasted Makefile.am, configure.ac and panel-plugin/Makefile.am which are required for xfce4 xdt-autogen tool, which when run in the source directory will generate the appropriate make and configure files.
***************
* Makefile.am *
***************
SUBDIRS = \
panel-plugin \
po
AUTOMAKE_OPTIONS = \
1.8 \
dist-bzip2
*****************
* configure.ac *
*****************
dnl Version information
m4_define([my_example_version_major], [1])
m4_define([my_example_version_minor], [3])
m4_define([my_example_version_micro], [0])
m4_define([my_example_version], [my_example_version_major().my_example_version_minor().my_example_version_micro()])
dnl Initialize autoconf
AC_COPYRIGHT([Copyright (c) 2013
Example <bug#example.org>])
AC_INIT([xfce4-my_example-plugin], [my_example_version()], [bug#example.org])
AC_PREREQ([2.50])
dnl Initialize automake
AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar])
AM_CONFIG_HEADER([config.h])
AM_MAINTAINER_MODE()
dnl Check for basic programs
AC_PROG_CC()
AC_PROG_LD()
AC_PROG_INSTALL()
AC_PROG_INTLTOOL()
AC_PROG_LIBTOOL()
AM_PROG_CC_C_O()
dnl Check for standard headers
AC_HEADER_STDC()
AC_CHECK_HEADERS([string.h fcntl.h errno.h sys/socket.h netdb.h \
netinet/in.h sys/types.h time.h unistd.h stdio.h \
sys/stat.h stddef.h stdlib.h netinet/in.h])
dnl Check for i18n support
XDT_I18N([])
dnl Check for required packages
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0])
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.90.2])
XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.3.90.2])
XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.99.1])
dnl Check for debugging support
XDT_FEATURE_DEBUG()
AC_OUTPUT([
Makefile
po/Makefile.in
panel-plugin/Makefile
])
****************************
* panel-plugin/Makefile.am *
****************************
INCLUDES = \
-I$(top_srcdir) \
-DTHEMESDIR=\"$(datadir)/xfce4/my_example/icons\" \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
-DG_LOG_DOMAIN=\"my_example\"
plugin_PROGRAMS = \
xfce4-my_example-plugin
plugindir = $(libexecdir)/xfce4/panel-plugins
xfce4_my_example_plugin_SOURCES = \
my_example_dat.h \
my_example_func.h \
my_example_images.h \
my_example_applet.c \
my_example.c \
my_example_processdata.c \
my_example_menu.c
xfce4_my_example_plugin_CFLAGS = \
$(LIBXFCE4PANEL_CFLAGS) \
$(LIBXFCEGUI4_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
$(GTK_CFLAGS)
xfce4_my_example_plugin_LDADD = \
$(LIBXFCE4PANEL_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
$(LIBXFCEGUI4_LIBS) \
$(GTK_LIBS)
desktopdir = $(datadir)/xfce4/panel-plugins
desktop_DATA = \
my_example.desktop
#INTLTOOL_DESKTOP_RULE#
EXTRA_DIST = \
my_example.desktop.in
CLEANFILES = \
$(desktop_DATA)
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
I do have the right header files included in my source files in addition the source files compile fine before making the xfce4 related changes.
Makefile.am
xfce4_my_example_plugin_SOURCES = \
example_dat.h \
example_func.h \
example_images.h \
example_applet.c \
example.c \
example_processdata.c \
example_menu.c
From example_applet.c which is the first source file entered. Originally I only had "xfce4_my_example_plugin_SOURCES = example_applet.c" since the rest would be found through that file. It gave the same error.
#include <gtk/gtk.h>
#include <glib-object.h>
#include <string.h>
#include <libxfce4util/libxfce4util.h>
#include <libxfce4panel/xfce-panel-plugin.h>
#include <libxfce4panel/xfce-hvbox.h>
#include "example_dat.h" /* contains all structures */
#include "example_func.h" /* contains all function prototypes used in this program */
#include "example_images.h"
#include "example.c"
#include "example_processdata.c"
#include "example_menu.c"
/* register the xfce plugin */
XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(example_applet_fill);
It looks like I solved the problem. The build process for xfce is slightly different than what I am using to build the gnome panel applet.
For the gnome applet I use one source file to include all other source and header files.
In xfce it appears, after having looked over various plugin source trees, each source file includes the necessary headers, however none of the source files include other source files.
The fix was to not include any other source files at all and change each source file to include the header files.
Related
I' m trying to setup a simple tool to measure different aspects of a system. I build a project which can log an accelerometer, gyroscope and a magnetometer. I want full control of the the program so I decided not to use any usr/local kind of libraries and keep all files in the project folder. All files all working. I want to make the structure of my program as follows: https://www.dropbox.com/s/59s3si8spvkdq98/filestructure.png (not enough REP). I don't have much experience in making Makefiles, except changing a few variables. I work in the Embedded environment and mostly with IDE's.
I tried building my project with the following Makefile:
# Project name
NAME = TEST
# Tools
CC = gcc
CFLAGS = -o
# Paths
DRV_PATH = drivers
SRC_PATH = src
LIB_PATH = libs
# includes
INCLUDES = -I $(DRV_PATH) -I $(LIB_PATH) -I $(SRC_PATH)
# what files do we need to compile?
# libraries
MY_LIB = $(LIB_PATH)/bcm2835.c
# main files
MAIN = main.c
# src files
#MY_SRC = $(SRC_PATH)/vector.c
MY_SRC += $(SRC_PATH)/dcm.c
# select drivers to compile
DRV_SRC = $(DRV_PATH)/adxl345.c
DRV_SRC += $(DRV_PATH)/itg3200.c
DRV_SRC += $(DRV_PATH)/hmc5883l.c
DRV_SRC += $(DRV_PATH)/gy-85.c
DRV_SRC += $(DRV_PATH)/nrf24l01.c
# bundle files
ALL_SRC = $(MY_LIB) $(DRV_SRC) $(MY_SRC) $(MAIN)
OBJ = $(ALL:.c=.o)
BIN = $(ALL:.c=)
# make commands
all:
$(CC) $(CFLAGS) $(NAME) $(ALL_SRC)
debug:
$(CC) $(CFLAGS) $(NAME) $(ALL_SRC) -DDEBUG=1
imudebug:
$(CC) $(CFLAGS) $(NAME) $(ALL_SRC) -DIMUDEBUG=1
nrfdebug:
$(CC) $(CFLAGS) $(NAME) $(ALL_SRC) -DNRFDEBUG=1
I use the different make commands to generate some debug output.
The config file currently includes all files and is as follows:
#ifndef CONFIG_H
#define CONFIG_H
/* includes */
#include <stdio.h>
#include <math.h>
/* libs */
#include <bcm2835.h>
/* drivers */
#include "gy-85.h"
#include "adxl345.h"
#include "itg3200.h"
#include "hmcl5883l.h"
#include "nrf24l01.h"
/* src */
#include "dcm.h"
#endif // __CONFIG_H__
And the dcm.h file looks as follows. I tried t keep all .h files like this:
#ifndef DCM_H
#define DCM_H
#include <bcm2835.h>
#include <stdio.h>
#include <math.h>
#include "gy-85.h"
double pitch, roll, yaw;
double DCM_Matrix[3][3];
uint64_t stamp;
void resetFusion(void);
#endif
This is my make result:
gcc -o TEST libs/bcm2835.c drivers/adxl345.c drivers/itg3200.c drivers/hmc5883l.c drivers/gy-85.c drivers/nrf24l01.c src/dcm.c main.c
In file included from drivers/adxl345.c:1:0:
drivers/adxl345.h:4:21: fatal error: bcm2835.h: No such file or directory
compilation terminated.
In file included from drivers/itg3200.c:1:0:
drivers/itg3200.h:4:21: fatal error: bcm2835.h: No such file or directory
compilation terminated.
drivers/hmc5883l.c: In function ‘magInit’:
drivers/hmc5883l.c:7:30: error: ‘MAG_ADDR’ undeclared (first use in this function)
drivers/hmc5883l.c:7:30: note: each undeclared identifier is reported only once for each function it appears in
drivers/hmc5883l.c:14:17: error: ‘MODE’ undeclared (first use in this function)
drivers/hmc5883l.c:14:23: error: ‘CONTINUOUS’ undeclared (first use in this function)
drivers/hmc5883l.c:22:17: error: ‘CONA’ undeclared (first use in this function)
drivers/hmc5883l.c:22:23: error: ‘RATE_50HZ’ undeclared (first use in this function)
drivers/hmc5883l.c: In function ‘magRead’:
drivers/hmc5883l.c:37:30: error: ‘MAG_ADDR’ undeclared (first use in this function)
drivers/hmc5883l.c:38:18: error: ‘DATA’ undeclared (first use in this function)
drivers/hmc5883l.c: In function ‘magGetRegister’:
drivers/hmc5883l.c:60:13: error: ‘BCM2835_I2C_REASON_OK’ undeclared (first use in this function)
drivers/hmc5883l.c:61:3: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
drivers/hmc5883l.c: At top level:
drivers/hmc5883l.c:71:6: warning: conflicting types for ‘magGetRegisters’ [enabled by default]
drivers/hmc5883l.c:38:2: note: previous implicit declaration of ‘magGetRegisters’ was here
drivers/hmc5883l.c: In function ‘magGetRegisters’:
drivers/hmc5883l.c:79:13: error: ‘BCM2835_I2C_REASON_OK’ undeclared (first use in this function)
drivers/hmc5883l.c:80:3: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
drivers/hmc5883l.c: At top level:
drivers/hmc5883l.c:97:6: warning: conflicting types for ‘magSetRegister’ [enabled by default]
drivers/hmc5883l.c:14:2: note: previous implicit declaration of ‘magSetRegister’ was here
drivers/hmc5883l.c: In function ‘magSetRegister’:
drivers/hmc5883l.c:107:13: error: ‘BCM2835_I2C_REASON_OK’ undeclared (first use in this function)
drivers/hmc5883l.c:108:3: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
drivers/gy-85.c: In function ‘gyInit’:
drivers/gy-85.c:15:30: error: ‘BCM2835_I2C_CLOCK_DIVIDER_2500’ undeclared (first use in this function)
drivers/gy-85.c:15:30: note: each undeclared identifier is reported only once for each function it appears in
drivers/gy-85.c: In function ‘gyUpdate’:
drivers/gy-85.c:29:2: error: unknown type name ‘int16_t’
drivers/gy-85.c:30:2: error: unknown type name ‘uint8_t’
drivers/gy-85.c:32:9: error: ‘int16_t’ undeclared (first use in this function)
drivers/gy-85.c:32:18: error: expected expression before ‘)’ token
drivers/gy-85.c:40:18: error: expected expression before ‘)’ token
drivers/gy-85.c:47:18: error: expected expression before ‘)’ token
drivers/gy-85.c:61:2: warning: return from incompatible pointer type [enabled by default]
In file included from drivers/nrf24l01.c:1:0:
drivers/nrf24l01.h:5:21: fatal error: bcm2835.h: No such file or directory
compilation terminated.
In file included from src/dcm.c:1:0:
src/dcm.h:4:21: fatal error: bcm2835.h: No such file or directory
compilation terminated.
In file included from main.c:1:0:
config.h:9:21: fatal error: bcm2835.h: No such file or directory
compilation terminated.
make: *** [all] Error 1
If you can point out the main problem with my file structure I would be so glad!
Current error list:
gcc -o TEST -I libs -I drivers -I src libs/bcm2835.c drivers/adxl345.c drivers/itg3200.c drivers/hmc5883l.c drivers/gy-85.c drivers/nrf24l01.c src/dcm.c main.c
drivers/gy-85.c: In function ‘gyUpdate’:
drivers/gy-85.c:63:2: warning: return from incompatible pointer type [enabled by default]
main.c: In function ‘main’:
main.c:51:4: warning: passing argument 1 of ‘nrf24Transmit’ from incompatible pointer type [enabled by default]
drivers/nrf24l01.h:145:9: note: expected ‘uint8_t *’ but argument is of type ‘uint64_t *’
/tmp/ccOWR401.o:(.bss+0x0): multiple definition of `accelRaw'
/tmp/cc1gy1Bh.o:(.bss+0x0): first defined here
/tmp/ccOWR401.o:(.bss+0x8): multiple definition of `accelBias'
/tmp/cc1gy1Bh.o:(.bss+0x8): first defined here
/tmp/ccyZlhJe.o:(.bss+0x0): multiple definition of `accelRaw'
/tmp/cc1gy1Bh.o:(.bss+0x0): first defined here
/tmp/ccyZlhJe.o:(.bss+0x8): multiple definition of `accelBias'
/tmp/cc1gy1Bh.o:(.bss+0x8): first defined here
/tmp/ccUbOIyA.o:(.bss+0x0): multiple definition of `accelRaw'
/tmp/cc1gy1Bh.o:(.bss+0x0): first defined here
/tmp/ccUbOIyA.o:(.bss+0x8): multiple definition of `accelBias'
/tmp/cc1gy1Bh.o:(.bss+0x8): first defined here
/tmp/ccyZlhJe.o: In function `resetFusion':
dcm.c:(.text+0x38): undefined reference to `atan2'
collect2: ld returned 1 exit status
make: *** [all] Error 1
You don't have your includes in your rule
INCLUDES = -I $(DRV_PATH) -I $(LIB_PATH) -I $(SRC_PATH)
This just seems to dangle. Simplest solution to my eyes is to move down your CFLAGS definition and add in the includes:
INCLUDES = -I $(DRV_PATH) -I $(LIB_PATH) -I $(SRC_PATH)
CFLAGS = -o $(INCLUDES)
This way you don't have to change anything else. Of course, there are alternatives, this one just looks easiest.
Trying to build vSphere Perl SDK on Centos 2.6. Got all dependencies except one, namely UUID-0.05.
The problem seems to be that the uuid.h include file references unistd.h for the definition of uuid_t, but unistd.h has no such thing. Worse, though some people have described a conflict between the two include files for the variable, I cannot find a unistd.h file on the Internet with the definition.
Can someone point to such a unistd.h file? Or, even, a better approach to take?
Here's some info about the original issue:
In Changelog for uuid.1.6.2:
o Apply workaround to uuid.h to avoid conflicts with
vendor UUID implementations where uuid_t (Darwin/MacOSX)
or uuid_create/uuid_compare (POSIX) might exist.
[Ralf S. Engelschall]
In uuid.h:
/* workaround conflicts with system headers */
#define uuid_t __vendor_uuid_t
#define uuid_create __vendor_uuid_create
#define uuid_compare __vendor_uuid_compare
#include <sys/types.h>
#include <unistd.h>
#undef uuid_t
#undef uuid_create
#undef uuid_compare
Here's the original problem (compiling):
jloiacon#flowviewerprime /home/jloiacon/UUID-0.05 249 >make
cp UUID.pm blib/lib/UUID.pm
/usr/bin/perl /usr/share/perl5/ExtUtils/xsubpp -typemap /usr/share/perl5/ExtUtils/typemap UUID.xs > UUID.xsc && mv UUID.xsc UUID.c
gcc -c -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DVERSION=\"0.05\" -DXS_VERSION=\"0.05\" -fPIC "-I/usr/lib64/perl5/CORE" UUID.c
UUID.xs: In function âdo_generateâ:
UUID.xs:13: error: storage size of âuuidâ isnât known
UUID.xs:14: warning: implicit declaration of function âuuid_generateâ
UUID.xs:13: warning: unused variable âuuidâ
UUID.xs: In function âdo_unparseâ:
UUID.xs:20: error: storage size of âuuidâ isnât known
UUID.xs:23: warning: implicit declaration of function âuuid_unparseâ
UUID.xs:20: warning: unused variable âuuidâ
UUID.xs: In function âdo_parseâ:
UUID.xs:29: error: storage size of âuuidâ isnât known
UUID.xs:33: warning: implicit declaration of function âuuid_parseâ
UUID.xs:30: warning: unused variable âstrâ
UUID.xs:29: warning: unused variable âuuidâ
make: *** [UUID.o] Error 1
Thanks
Install uuid-c++-devel.
lorem ipsum
if I build my program, it gives me many errors and warning. Everything is from compiled highest source file - main.o.
...
./main.o:16:819: warning: null character(s) ignored [enabled by default]
./main.o:16:824: warning: null character(s) ignored [enabled by default]
./main.o:16:829: warning: null character(s) ignored [enabled by default]
./main.o:16:844: warning: null character(s) ignored [enabled by default]
./main.o:16:854: warning: null character(s) ignored [enabled by default]
./main.o:16:864: warning: null character(s) ignored [enabled by default]
./main.o:16:886: error: too many decimal points in number
./main.o:16:892: error: invalid suffix "ubuntu5" on integer constant
./main.o:16:902: error: too many decimal points in number
./main.o:16:907: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\24’ in program
./main.o:16:914: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\1’ in program
./main.o:16:924: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\1’ in program
./main.o:16:2: error: stray ‘\20’ in program
./main.o:16:2: error: stray ‘\1’ in program
./main.o:16:2: error: stray ‘\33’ in program
./main.o:16:2: error: stray ‘\7’ in program
./main.o:16:2: error: stray ‘\10’ in program
./main.o:16:2: error: stray ‘\220’ in program
./main.o:16:2: error: stray ‘\1’ in program
./main.o:16:935: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\34’ in program
./main.o:16:938: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\34’ in program
./main.o:16:942: warning: null character(s) ignored [enabled by default]
./main.o:16:950: warning: null character(s) ignored [enabled by default]
./main.o:16:2: error: stray ‘\16’ in program
./main.o:16:2: error: stray ‘\20’ in program
./main.o:16:2: error: stray ‘\206’ in program
./main.o:16:2: error: stray ‘\2’ in program
In file included from <command-line>:0:0:
./main.o:17:1: error: stray ‘\6’ in program
./main.o:17:1: error: stray ‘\2’ in program
....
Where can a problem be?
These errors are caused be "-include" command and source file /usr/include/glib-2.0/glib/gregex.h to makefile. But if I remove this command it will give me errors with "undefined reference to ..." ... declarations from glib. Problem will be with using glib. Before I tried (without an effect):
INCLUDES = -I/usr/include/glib-2.0 \
-I/usr/include/glib-2.0/glib
LIBS := -lglib-2.0
Does anyone have the correct makefile commands with glib? Thanks
EDIT: I would like to create a program, which using streamripper for recording internet audio streams.
CC = gcc
CFLAGS = -g -Wall $(shell pkg-config --cflags glib-2.0) -D__UNIX__
LFLAGS = -L/usr/include/x86_64-linux-gnu \
-L/usr/local/lib/ \
-L/usr/include/x86_64-linux-gnu
SRCS = main.c \
streamripper.c #\
/usr/include/glib-2.0/glib/gregex.h
OBJS = $(SRCS:.c=.o)
MAIN = radio
INCLUDES = -I/home/honza/workspace/Radio_processing/streamripper/libmad-0.15.1b \
-I/usr/include \
-I/usr/include/x86_64-linux-gnu \
-I/usr/include/x86_64-linux-gnu/4.6/include \
-I/usr/include/x86_64-linux-gnu/4.6/include-fixed \
-I/usr/local/include \
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include \
-I/usr/lib/x86_64-linux-gnu/glib-2.0 \
-I/usr/include/glib-2.0 \
-I/usr/include/glib-2.0/glib
LIBS := -lm libmad.a libstreamripper.a -glib -lglib-2.0 \
$(shell pkg-config --libs glib-2.0)
#-lavcodec -lavutil -lavformat -lpthread
all: $(MAIN)
#echo 'My makefile finished'
$(MAIN): $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LFLAGS) $(LIBS)
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $#
clean:
$(RM) *.o *~ $(MAIN)
depend: $(SRCS)
makedepend $(INCLUDES) $^
Everything is from compiled highest source file - main.o
strange thing to compile an object-file again, or to name a source-file like an object-file.
.o normally is what comes from the compilation step with a .c file.
I'm currently trying to compile a Linux USB UART driver, which is provided here:
http://www.exar.com/connectivity/uart-and-bridging-solutions/usb-uarts/xr21v1410
The driver consists of 2 header files and one large C file. These are the contents of the Makefile:
obj-m := vizzini.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
EXTRA_CFLAGS := -DDEBUG=0
all:
$(MAKE) -C $(KERNELDIR) M=$(PWD)
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions vtty
This is the error the compiler is throwing when I run make:
[sj755#localhost xr21v141x-lnx-2.6.35-pak]$ make
make -C /lib/modules/3.4.9-2.fc16.x86_64/build M=/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak
make[1]: Entering directory `/usr/src/kernels/3.4.9-2.fc16.x86_64'
LD /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/built-in.o
CC [M] /home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.o
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1643:9: warning: initialization from incompatible pointer type [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1643:9: warning: (near initialization for ‘vizzini_device.ioctl’) [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1646:9: warning: initialization from incompatible pointer type [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1646:9: warning: (near initialization for ‘vizzini_device.tiocmget’) [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1647:9: warning: initialization from incompatible pointer type [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1647:9: warning: (near initialization for ‘vizzini_device.tiocmset’) [enabled by default]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c: In function ‘vizzini_init’:
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1663:9: error: implicit declaration of function ‘usb_serial_register’ [-Werror=implicit-function-declaration]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1677:9: error: implicit declaration of function ‘usb_serial_deregister’ [-Werror=implicit-function-declaration]
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c: In function ‘__check_debug’:
/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.c:1698:83: warning: return from incompatible pointer type [enabled by default]
cc1: some warnings being treated as errors
make[2]: *** [/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak/vizzini.o] Error 1
make[1]: *** [_module_/home/sj755/Downloads/xr21v141x-lnx-2.6.35-pak] Error 2
make[1]: Leaving directory `/usr/src/kernels/3.4.9-2.fc16.x86_64'
make: *** [all] Error 2
These are the headers included in the main c source file:
#include <linux/kernel.h>
#include <linux/jiffies.h>
#include <linux/errno.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
#include <linux/serial.h>
#include <linux/slab.h>
#include <asm/unaligned.h>
#include <asm/uaccess.h>
#include <linux/usb/cdc.h>
#ifndef CDC_DATA_INTERFACE_TYPE
#define CDC_DATA_INTERFACE_TYPE 0x0a
#endif
#ifndef USB_RT_ACM
#define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
#define ACM_CTRL_DTR 0x01
#define ACM_CTRL_RTS 0x02
#define ACM_CTRL_DCD 0x01
#define ACM_CTRL_DSR 0x02
#define ACM_CTRL_BRK 0x04
#define ACM_CTRL_RI 0x08
#define ACM_CTRL_FRAMING 0x10
#define ACM_CTRL_PARITY 0x20
#define ACM_CTRL_OVERRUN 0x40
#endif
#include "linux/version.h"
#include "vizzini.h"
Running Linux kernel 3.4.9-2.fc16.x86_64
I would greatly appreciate any help in resolving the errors.
EDIT
It seems that usb_serial_register and usb_serial_deregister were never defined in my kernel's API. However, usb_serial_register_drivers and usb_serial_deregister_drivers are. Below are the definitions:
int usb_serial_register(struct usb_serial_driver *driver);
void usb_serial_deregister(struct usb_serial_driver *device);
int usb_serial_register_drivers(struct usb_driver *udriver,
struct usb_serial_driver * const serial_drivers[]);
void usb_serial_deregister_drivers(struct usb_driver *udriver,
struct usb_serial_driver * const serial_drivers[]);
The API inside the kernel (available header files, their contents, function prototypes (or if they exist in the first place), ...) is not fixed (see Documentation/stable_api_nonsense.txt in your nearest Linux source if you are curious), so a driver can typically only be compiled for a rather narrow range of kernels. Check if the source is (roughly) contemporary with the kernel.
You should also check if a driver for that has already been included in the kernel, either as an official driver or in the staging area. Look around Linux USB to check for alternative drivers and other news. If nothing else helps, you should take a look at LWN's kernel pages (search there for functions you can't find in the current source and discussion on replacement), probably after using something like cscope to create an index of your source (kernel and driver). Please do get in touch with the people responsible for this area, so they know you are groping around and perhaps give some pointers.
I'm trying to compile a 3rd party kernel module for RHEL 5.6 and it is failing due to function name conflicts with mutex_acquire and mutex_release. This kernel module compiles cleanly on RHEL 4.7 so something changed between kernels 2.6.9 and 2.6.18. Sadly, this kernel module is no longer supported by the vendor but I do have the source code for mutex.c and mutex.h which define these functions. Unfortunately there is an object file nivxi.o upon which no source code is distributed and this object file is calling mutex_acquire and mutex_release so I cannot just simply alter their names.
As an aside, I originally attempted to just modify the names slightly and the compile errors went away but when it went to make the .ko kernel module it complained that it couldn't find mutex_acquire or mutex_release; presumably due to nivxi.o
How do I force the compiler/linker to use the function definitions in my local .c/.h files even though they trounce over like-named functions elsewhere?
mutex.h
NIVXICC void mutex_acquire(mutex_t *mutex);
NIVXICC void mutex_release(mutex_t *mutex);
nivxicc.h (just incase this is pertinent)
#ifndef NIVXICC_H
#define NIVXICC_H
#define NIVXICC __attribute__((regparm(0))) __attribute__((cdecl))
#endif
/usr/include/lockdep.h (conflicting definition)
#ifdef CONFIG_DEBUG_LOCK_ALLOC
# ifdef CONFIG_PROVE_LOCKING
# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i)
# else
# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i)
# endif
# define mutex_release(l, n, i) lock_release(l, n, i)
#else
# define mutex_acquire(l, s, t, i) do { } while (0)
# define mutex_release(l, n, i) do { } while (0)
#endif
Error
# make
make -C /lib/modules/2.6.18-238.el5/build SUBDIRS=/usr/local/nivxi/src KBUILD_VERBOSE=1 modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-238.el5-i686'
test -e include/linux/autoconf.h -a -e include/config/auto.conf || ( \
echo; \
echo " ERROR: Kernel configuration is invalid."; \
echo " include/linux/autoconf.h or include/config/auto.conf are missing."; \
echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo; \
/bin/false)
mkdir -p /usr/local/nivxi/src/.tmp_versions
rm -f /usr/local/nivxi/src/.tmp_versions/*
make -f scripts/Makefile.build obj=/usr/local/nivxi/src
gcc -m32 -Wp,-MD,/usr/local/nivxi/src/.vxi.o.d -nostdinc -isystem \
/usr/lib/gcc/i386-redhat-linux/4.1.2/include -D__KERNEL__ -Iinclude \
-include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes \
-Wno-trigraphs -fno-strict-aliasing -fno-common -Wstrict-prototypes \
-Wundef -Werror-implicit-function-declaration \
-fno-delete-null-pointer-checks -fwrapv -Os -pipe -msoft-float \
-fno-builtin-sprintf -fno-builtin-log2 -fno-builtin-puts \
-mpreferred-stack-boundary=2 -march=i686 -mtune=generic -mtune=generic \
-mregparm=3 -ffreestanding -Iinclude/asm-i386/mach-generic \
-Iinclude/asm-i386/mach-default -fomit-frame-pointer -g -fno-stack-protector \
-Wdeclaration-after-statement -Wno-pointer-sign -DVXI_MAJOR=0 \
-DREMAP_PAGE_RANGE_VMA -D__DEBUG__ -DMODULE -D"KBUILD_STR(s)=#s" \
-D"KBUILD_BASENAME=KBUILD_STR(vxi)" -D"KBUILD_MODNAME=KBUILD_STR(vximod)" \
-c -o /usr/local/nivxi/src/.tmp_vxi.o /usr/local/nivxi/src/vxi.c
In file included from /usr/local/nivxi/src/vxi.c:13:
/usr/local/nivxi/src/mutex.h:59:42: error: macro "mutex_acquire" requires 4 arguments, but only 1 given
In file included from /usr/local/nivxi/src/vxi.c:13:
/usr/local/nivxi/src/mutex.h:59: warning: ‘regparm’ attribute only applies to function types
/usr/local/nivxi/src/mutex.h:59: warning: ‘cdecl’ attribute only applies to function types
/usr/local/nivxi/src/mutex.h:61:42: error: macro "mutex_release" requires 3 arguments, but only 1 given
/usr/local/nivxi/src/mutex.h:61: warning: ‘regparm’ attribute only applies to function types
/usr/local/nivxi/src/mutex.h:61: warning: ‘cdecl’ attribute only applies to function types
/usr/local/nivxi/src/vxi.c:128:31: error: macro "mutex_acquire" requires 4 arguments, but only 1 given
/usr/local/nivxi/src/vxi.c:133:31: error: macro "mutex_release" requires 3 arguments, but only 1 given
/usr/local/nivxi/src/vxi.c:146:31: error: macro "mutex_acquire" requires 4 arguments, but only 1 given
/usr/local/nivxi/src/vxi.c:158:31: error: macro "mutex_release" requires 3 arguments, but only 1 given
/usr/local/nivxi/src/vxi.c: In function ‘vxi_mmap’:
/usr/local/nivxi/src/vxi.c:243: error: implicit declaration of function ‘remap_page_range’
make[2]: *** [/usr/local/nivxi/src/vxi.o] Error 1
make[1]: *** [_module_/usr/local/nivxi/src] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.18-238.el5-i686'
make: *** [default] Error 2
The problem will not be in your object file as macros have file-scope and are replaced by the preprocessor. Thus after being compiled, the macro no longer exists as far as your nivxi.o file is concerned.
The issue is probably in your mutex.h file. I would look at the top and you will likely see an #include <lockdep.h> line. Thus once the preprocessor gets down to your function definition, it treats mutex_acquire as a token to be replaced (with the wrong number of arguments).
The easiest way to solve your problem will be to #undef mutex_acquire and #undef mutex_release at the beginning of mutex.h. This will prevent the preprocessor from replacing the tokens in your mutex.h. Since defines have file-scope, you don't need to worry about this propagating beyond your application