I am trying to crosscompile some stuff for android and I am getting the following....
In file included from /Users/me/Development/Android/android-ndk-r8c/platforms/android-14/arch-arm/usr/include/stdio.h:50:0,
from ./src/z_zone.h:52,
from ./src/doomdef.h:49,
from ./src/d_items.h:38,
from ./src/d_player.h:43,
from ./src/doomstat.h:43,
from ./src/am_map.c:39:
/Users/me/Development/Android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/include/stddef.h:212:23: error: duplicate 'unsigned'
/Users/me/Development/Android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/include/stddef.h:212:23: error: two or more data types in declaration specifiers
In file included from /Users/jackiegleason/Development/Android/android-ndk-r8c/platforms/android-14/arch-arm/usr/include/stdio.h:55:0,
from ./src/z_zone.h:52,
from ./src/doomdef.h:49,
from ./src/d_items.h:38,
from ./src/d_player.h:43,
from ./src/doomstat.h:43,
from ./src/am_map.c:39:
/Users/me/Development/Android/android-ndk-r8c/platforms/android-14/arch-arm/usr/include/sys/types.h:59:30: error: two or more data types in declaration specifiers
/Users/me/Development/Android/android-ndk-r8c/platforms/android-14/arch-arm/usr/include/sys/types.h:59:1: warning: useless type name in empty declaration [enabled by default]
/Users/me/Development/Android/android-ndk-r8c/platforms/android-14/arch-arm/usr/include/sys/types.h:101:33: error: two or more data types in declaration specifiers
/Users/me/Development/Android/android-ndk-r8c/platforms/android-14/arch-arm/usr/include/sys/types.h:101:1: warning: useless type name in empty declaration [enabled by default]
Do I need to configure differently or something?
Update
One thing I did notice is that it is using....
/Users/me/Development/Android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6...
When I am using a standalone toolchain...
echo $PATH
/Users/me/toolchain/bin
From the output...
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
checking build system type... i386-apple-darwin12.4.0
checking host system type... arm-unknown-linux-gnu
checking target system type... arm-unknown-linux-gnu
Also noticed this in the configure....
# FIXME: To remove some day.
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used." >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
fi
I of course can hack this so cross compile is always yes, this lets it work with....
checking build system type... arm-unknown-linux-gnu
checking host system type... arm-unknown-linux-gnu
checking target system type... arm-unknown-linux-gnu
Related
I am new to linux, C and stack overflow. I was trying to view page tables of all processes running. For this I am using dump_pagetable.c.
I tried to run first by normal compiling gcc dump_pagetables.c -o dump_pagetables.out. But it gave me error:
dump_pagetable.c:15:27: fatal error: linux/debugfs.h: No such file or directory #include linux/debugfs.h></code><br/><br/>Then I tried to use a make command <code>make -C /lib/modules/$(uname -r)/build M=$PWD modules</code>. So it gave me this error<code>CC [M] /home/varma/Desktop/TLB/dump_pagetable.o
/home/varma/Desktop/TLB/dump_pagetable.c:420:1: warning: data definition has no type or storage class
__initcall(pt_dump_init);
^
/home/varma/Desktop/TLB/dump_pagetable.c:420:1: error: type defaults to ‘int’ in declaration of ‘__initcall’ [-Werror=implicit-int]
/home/varma/Desktop/TLB/dump_pagetable.c:420:1: warning: parameter names (without types) in function declaration
/home/varma/Desktop/TLB/dump_pagetable.c:398:12: warning: ‘pt_dump_init’ defined but not used [-Wunused-function]
static int pt_dump_init(void)
^
cc1: some warnings being treated as errors
scripts/Makefile.build:263: recipe for target '/home/varma/Desktop/TLB/dump_pagetable.o' failed
make[1]: *** [/home/varma/Desktop/TLB/dump_pagetable.o] Error 1
Makefile:1394: recipe for target '_module_/home/varma/Desktop/TLB' failed
make: *** [_module_/home/varma/Desktop/TLB] Error 2
make: Leaving directory '/usr/src/linux-headers-3.19.0-23-generic'</code>
How do I get this code running?
How do modify the dump_pagetables.c So that I can see huge pages also.
The file you are trying to compile is a utility function for use within the Linux kernel for a somewhat obscure CPU used in IBM mainframes (the IBM System/390). It cannot be used outside of the kernel, and even there, it's only applicable to systems of that particular architecture, not to any desktop computers.
Needless to say, this won't work.
There is an equivalent feature (CONF_X86_PTDUMP) available in the kernel for x86 systems, but it is not enabled. If you want to use it, you will probably need to recompile your kernel. For more details, see the answer to the question "Print kernel's page tables".
Trying to build an open source project (systemd, not necesarilly relevant), I am stuck on the following error (also not directly relevant):
CC src/libsystemd/sd-rtnl/libsystemd_la-rtnl-types.lo
src/libsystemd/sd-rtnl/rtnl-types.c:278:10: error: 'IFLA_INET6_ADDR_GEN_MODE' undeclared here (not in a function)
[IFLA_INET6_ADDR_GEN_MODE] = { .type = NLA_U8 },
^
src/libsystemd/sd-rtnl/rtnl-types.c:278:9: error: array index in initializer not of integer type
[IFLA_INET6_ADDR_GEN_MODE] = { .type = NLA_U8 },
^
src/libsystemd/sd-rtnl/rtnl-types.c:278:9: error: (near initialization for 'rtnl_af_spec_inet6_types')
src/libsystemd/sd-rtnl/rtnl-types.c:278:9: warning: excess elements in array initializer [enabled by default]
src/libsystemd/sd-rtnl/rtnl-types.c:278:9: warning: (near initialization for 'rtnl_af_spec_inet6_types') [enabled by default]
My question is then:
How do I figured out where IFLA_INET6_ADDR_GEN_MODE should have been defined / what header I'm missing
My own ideas are:
Google the error message (no luck, ofc, otherwise I wouldn't be here..)
Search for it in all my files sudo rgrep IFLA_INET6_ADDR_GEN_MODE /
Your ideas???
A great answer would be the way you reason/study/learn to get to know where this constant is declared, enabling me and other readers to learn, rather than simply read a fact.
Update (Build procedure):
git clone git#github.com:systemd/systemd.git
cd systemd/
./autogen.sh
./configure CFLAGS='-g -O0 -ftrapv' --enable-compat-libs --enable-kdbus --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --enable-gtk-doc --with-rootprefix= --with-rootlibdir=/lib --disable-gnutls
make
I googgled the constant and got a pointer to http://permalink.gmane.org/gmane.linux.network/322662. It seems to be declared in b/include/uapi/linux/if_link.h
I had the same problem and after looking trough the problem, I realized my kernel header was not updated.
This variable was introduced between version 3.16 ~ 3.17 (not quite sure when but mine was 3.13 ).
To check out what you use
run the following:
% rpm -qf /usr/include/linux/if_link.h
or
uname -r
Also, this is a v219 new systemd feature which adds this dependency.
More info:
http://cgit.freedesktop.org/systemd/systemd/tree/NEWS#n291
You are trying to compile the origin/master HEAD, to test, try building v218.
I am new to cmake and gcc.
The first assignment in my new role in the company was to clean the errors from our linux compilation
I did most of it, and now the only warning I see is
cc1: warning: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C [enabled by default]
I want wither to suppress the warning or to solve the issue in the cmake file.
Unfortunately, I still haven't found the correct -Wno-xxx statement that fits here.
Thanks!
Code issue warnings can be silenced with -Wno-xxx options because sometimes you don't have control over the source code. But a warning telling you that a command-line option is incorrect cannot be silenced with yet another command-line option — if you can affect compiler invocation, then why not just remove the incorrect option?
This particular warning tells you that you cannot set standard to C++11 when compiling C code. To get rid of it, find where -std=c++11 is defined in the build configuration, and make sure it is only applied to C++ compilation, and not for C. For example, move it from CFLAGS to CXXFLAGS, or cmake's equivalent thereof.
I am trying to compile some code on linux that I KNOW compiles on OSX, but I am getting some issues.
All of the files have headers named .h, and all of the files are in the same directory. I am compiling like this:
gcc *.c -std=c99 -lpthread
And while this code does compile on OSX, I get a bunch of weird linker errors on my Ubuntu install. Am I missing a few compiler options? It is a default Ubuntu-server install with the additional packages gcc and build-essential installed.
In file included from errorLogger.h:24:0,
from configParser.h:17,
from configParser.c:9:
signalHandling.h:24:18: error: unknown type name ‘sigset_t’
configParser.c: In function ‘parseConfigFile’:
configParser.c:114:5: warning: implicit declaration of function ‘getline’ [-Wimplicit-function-declaration]
In file included from errorLogger.h:24:0,
from global.h:18,
from connection.h:19,
from connection.c:10:
signalHandling.h:24:18: error: unknown type name ‘sigset_t’
connection.c: In function ‘createConnectionQueue’:
connection.c:189:28: warning: assignment makes integer from pointer without a cast [enabled by default]
In file included from errorLogger.h:24:0,
from database.h:16,
from database.c:9:
signalHandling.h:24:18: error: unknown type name ‘sigset_t’
In file included from errorLogger.h:24:0,
from errorLogger.c:10:
signalHandling.h:24:18: error: unknown type name ‘sigset_t’
errorLogger.c: In function ‘reportError’:
errorLogger.c:63:5: warning: implicit declaration of function ‘strerror_r’ [-Wimplicit-function-declaration]
errorLogger.c: In function ‘logMessage’:
errorLogger.c:87:5: warning: implicit declaration of function ‘localtime_r’ [-Wimplicit-function-declaration]
errorLogger.c: In function ‘processErrorQueue’:
errorLogger.c:131:17: warning: implicit declaration of function ‘open’ [-Wimplicit-function-declaration]
errorLogger.c:131:57: error: ‘O_APPEND’ undeclared (first use in this function)
errorLogger.c:131:57: note: each undeclared identifier is reported only once for each function it appears in
errorLogger.c:131:68: error: ‘O_CREAT’ undeclared (first use in this function)
errorLogger.c:131:78: error: ‘O_WRONLY’ undeclared (first use in this function)
errorLogger.c:131:88: error: ‘S_IWRITE’ undeclared (first use in this function)
errorLogger.c:131:99: error: ‘S_IREAD’ undeclared (first use in this function)
errorLogger.c:146:13: warning: implicit declaration of function ‘fsync’ [-Wimplicit-function-declaration]
errorLogger.c: In function ‘startErrorLogger’:
errorLogger.c:167:36: error: ‘O_APPEND’ undeclared (first use in this function)
errorLogger.c:167:47: error: ‘O_CREAT’ undeclared (first use in this function)
errorLogger.c:167:57: error: ‘O_WRONLY’ undeclared (first use in this function)
errorLogger.c:167:67: error: ‘S_IWRITE’ undeclared (first use in this function)
errorLogger.c:167:78: error: ‘S_IREAD’ undeclared (first use in this function)
errorLogger.c:214:57: error: ‘O_EXCL’ undeclared (first use in this function)
errorLogger.c:231:27: warning: assignment makes integer from pointer without a cast [enabled by default]
errorLogger.c: In function ‘closeErrorLogger’:
errorLogger.c:246:9: warning: implicit declaration of function ‘pthread_kill’ [-Wimplicit-function-declaration]
In file included from errorLogger.h:24:0,
from global.h:18,
from global.c:9:
signalHandling.h:24:18: error: unknown type name ‘sigset_t’
In file included from main.c:23:0:
signalHandling.h:24:18: error: unknown type name ‘sigset_t’
main.c: In function ‘main’:
main.c:53:5: warning: implicit declaration of function ‘blockSignals’ [-Wimplicit-function-declaration]
main.c:61:45: error: invalid application of ‘sizeof’ to incomplete type ‘struct addrinfo’
main.c:62:29: error: invalid application of ‘sizeof’ to incomplete type ‘struct addrinfo’
main.c:64:10: error: dereferencing pointer to incomplete type
main.c:65:10: error: dereferencing pointer to incomplete type
main.c:66:10: error: dereferencing pointer to incomplete type
main.c:66:23: error: ‘AI_PASSIVE’ undeclared (first use in this function)
main.c:66:23: note: each undeclared identifier is reported only once for each function it appears in
main.c:69:5: warning: implicit declaration of function ‘getaddrinfo’ [-Wimplicit-function-declaration]
main.c:73:9: warning: implicit declaration of function ‘gai_strerror’ [-Wimplicit-function-declaration]
main.c:73:9: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Wformat]
main.c:73:9: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Wformat]
main.c:81:41: error: dereferencing pointer to incomplete type
main.c:83:30: error: dereferencing pointer to incomplete type
main.c:83:46: error: dereferencing pointer to incomplete type
main.c:83:64: error: dereferencing pointer to incomplete type
main.c:96:30: error: dereferencing pointer to incomplete type
main.c:96:44: error: dereferencing pointer to incomplete type
main.c:112:5: warning: implicit declaration of function ‘freeaddrinfo’ [-Wimplicit-function-declaration]
main.c:138:9: error: unknown type name ‘fd_set’
main.c:142:9: warning: implicit declaration of function ‘FD_ZERO’ [-Wimplicit-function-declaration]
main.c:143:9: warning: implicit declaration of function ‘FD_SET’ [-Wimplicit-function-declaration]
main.c:145:9: warning: implicit declaration of function ‘pselect’ [-Wimplicit-function-declaration]
In file included from signalHandling.c:10:0:
signalHandling.h:24:18: error: unknown type name ‘sigset_t’
signalHandling.c:12:18: error: unknown type name ‘sigset_t’
signalHandling.c: In function ‘setHandler’:
signalHandling.c:51:53: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigaction’
signalHandling.c:52:36: error: invalid application of ‘sizeof’ to incomplete type ‘struct sigaction’
signalHandling.c:54:5: warning: implicit declaration of function ‘sigemptyset’ [-Wimplicit-function-declaration]
signalHandling.c:54:30: error: dereferencing pointer to incomplete type
signalHandling.c:60:9: warning: implicit declaration of function ‘sigaddset’ [-Wimplicit-function-declaration]
signalHandling.c:60:35: error: dereferencing pointer to incomplete type
signalHandling.c:67:17: error: dereferencing pointer to incomplete type
signalHandling.c:72:9: warning: implicit declaration of function ‘sigaction’ [-Wimplicit-function-declaration]
You are probably missing some #includes which are brought in implicitly on OS X, but not on Linux.
Judging from the error messages, you are probably missing includes for at least:
<signal.h> (for sigset_t and others)
<fcntl.h> (for O_*)
<unistd.h> (for a bunch of stuff)
<netdb.h> (for various network functions and constants)
<stdio.h> (for getline)
You may also need to define some feature macros (e.g, _POSIX_C_SOURCE) to get certain system-dependent functions, including strerror_r and pselect.
I'm assuming that the immediate objective is to get the code to compile at all, and that once that's done, you'll go back and revise the source so it works out of the box on both platforms. That means that hacks are acceptable very short-term; they'll be fixed properly as you gain knowledge about what the portability issues are. (If it's any consolation, the first alternative system to the one where the software was originally developed is usually the hardest; after that, it generally gets easier.)
The first thing to try is:
gcc *.c -std=gnu99 -lpthread
This tells system header files to define many more symbols than -std=c99. (There's some dissent on this topic, which is OK. At the least, if you add -pedantic to a -std=c99 compilation, then symbols in standard C headers defined by POSIX are not exposed unless you also request POSIX support — see below. Since you don't have -pedantic, that may not be a factor in the compilations, in which case quietly move on to the next recommendation, which is the basis for future portability to POSIX systems.)
If that is insufficient to get you back on track, then you'll probably need to use something like:
gcc *.c -std=gnu99 -D_XOPEN_SOURCE=700 -lpthread
This says "Provide me with the POSIX and X/Open functions corresponding to POSIX 2008". You can try 600 and 500 for older versions, but you probably won't need to do so on Linux. In due course, you're likely to set _XOPEN_SOURCE automatically, either through a configuration header or via a configuration tool. While you're getting things to compile at all, specifying it on the command line is OK. In due course, you'll be using a makefile or equivalent to control the compilation and not typing a gcc command line at the shell.)
The sigset_t is defined in <signal.h> under POSIX. So, requesting POSIX support explicitly should get things to compile again properly. If you still get types such as sigset_t undeclared, then there must be a header on Mac OS X that includes the standard headers such as <signal.h> but which does some unrelated task on Linux (and therefore does not include <signal.h>). That will require source code scrutiny. However, it is relatively unlikely to be necessary.
You need to include additional header files because different system headers include other different system headers.
Also for example gcc has been working hard to not included headers that it should not.
Is signalHandling.h including #include <signal.h> where sigset_t is defined?
EDIT
After talking with the OP it seems the problems was a compile/link problem. Compiling the source into object files first and then linking them after seemed to have solved their problem.
I am a newbie to C/Pro*C
I compile a C code in Linux. I get the following error.
/usr/include/sys/proc.h:560: error: conflicting types for 'exit'
/usr/include/sys/proc.h:560: error: conflicting types for 'exit'
In proc.h, exit function is defined as
extern void exit(int, int);
The header proc.h is an OS defined header and I have no idea why I get this error.
If there is a conflicting type, it is as well defined elsewhere, probably with a different type - either as a function with a different signature, or as a variable.
Check if this is the case, and if so, rename your variable.