Re: Trouble compiling a simple program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 02, 2004 at 05:32:13PM -0500, Andrew Robert <arobert@xxxxxxxxxxx> st
ated:
>Rather than specify specific linux header files, I recommend you use
>
>#include <stdlib.h>
>#include <stdio.h>

I'm not #including them to make my Foo World program work, I'm 
just doing that as a demonstration.

The actual software I'm having issues compiling is libdnet, which
does use low-level packet structure information. I'm not aware of
a good way to make that low-level interface work without referencing
linux header files. The offending file is src/fw-ipchains.c, and
the software is available at libdnet.sourceforge.net.

BTW, the linux/types.h worked like a champ on ip.h, thanks very much
for the help, but I'm now hitting issues compiling files that 
#include <linux/tcp.h>. Example code would be:

#include <endian.h>
#include <netinet/in.h>
#include <byteswap.h>
#include <linux/types.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <stdio.h>

int main() {

  printf("Foo\n");
  return(0);
}

And the errors would be:

[tmacd@bahamut src]$ gcc -g -O2 -Wall -c test.c 
In file included from /usr/include/linux/tcp.h:21,
                 from test.c:7:
/usr/include/asm/byteorder.h:6: warning: #warning using private kernel header; include <endian.h> instead!
In file included from test.c:7:
/usr/include/linux/tcp.h:105: braced-group within expression allowed only inside a function
/usr/include/linux/tcp.h:105: enumerator value for `TCP_FLAG_CWR' not integer constant
/usr/include/linux/tcp.h:106: parse error before `__u32'
/usr/include/linux/tcp.h:107: parse error before `__u32'
/usr/include/linux/tcp.h:108: parse error before `__u32'
/usr/include/linux/tcp.h:109: parse error before `__u32'
/usr/include/linux/tcp.h:110: parse error before `__u32'
/usr/include/linux/tcp.h:111: parse error before `__u32'
/usr/include/linux/tcp.h:112: parse error before `__u32'
/usr/include/linux/tcp.h:113: parse error before `__u32'
/usr/include/linux/tcp.h:114: parse error before `__u32'

I'm #including endian, but it doesn't seem to be picking up on the
#definition of htonl(). If I #include <bits/byteswap.h> directly, 
I can get the parse erros to go away, but then it scolds me about
#including <bits/byteswap.h>, and that I should #include <byteswap.h>
directly. I'm doing that, but then it doesn't seem to be picking
up on the htonl(), for whatever reason.

Thanks for helping me play detective,

Todd

>Bevan C. Bennett wrote:
>
>>Todd MacDermid wrote:
>>
>>>Hey all, I appear to be having an issue compiling a simple program
>>>under Fedora Core 1. the program is as follows:
>>>
>>>#include <linux/ip.h>
>>>#include <stdio.h>
>>>
>>>int main() {
>>>
>>>  printf("Foo\n");
>>>  return(0);
>>>}
>>>
>>>And attempting to compile it gives me:
>>>
>>>[tmacd@bahamut src]$ gcc -g -O2 -Wall -c test.c In file included from 
>>>test.c:1:
>>>/usr/include/linux/ip.h:95: parse error before `__u8'
>>>/usr/include/linux/ip.h:95: warning: no semicolon at end of struct or 
>>>union
>>>/usr/include/linux/ip.h:101: warning: data definition has no type or 
>>>storage class
>>>/usr/include/linux/ip.h:102: parse error before `tot_len'
>>>/usr/include/linux/ip.h:102: warning: data definition has no type or 
>>>storage class
>>>/usr/include/linux/ip.h:103: parse error before `id'
>>>/usr/include/linux/ip.h:103: warning: data definition has no type or 
>>>storage class
>>>/usr/include/linux/ip.h:104: parse error before `frag_off'
>>>/usr/include/linux/ip.h:104: warning: data definition has no type or 
>>>storage class
>>>/usr/include/linux/ip.h:105: parse error before `ttl'
>>>/usr/include/linux/ip.h:105: warning: data definition has no type or 
>>>storage class
>>>/usr/include/linux/ip.h:106: parse error before `protocol'
>>>/usr/include/linux/ip.h:106: warning: data definition has no type or 
>>>storage class
>>>/usr/include/linux/ip.h:107: parse error before `check'
>>>/usr/include/linux/ip.h:107: warning: data definition has no type or 
>>>storage class
>>>/usr/include/linux/ip.h:108: parse error before `saddr'
>>>/usr/include/linux/ip.h:108: warning: data definition has no type or 
>>>storage class
>>>/usr/include/linux/ip.h:109: parse error before `daddr'
>>>/usr/include/linux/ip.h:109: warning: data definition has no type or 
>>>storage class
>>>[tmacd@bahamut src]$
>>>This is just an example of a problem that's been keeping me from 
>>>compiling
>>>a more complex program, which compiled under RH9, but doesn't compile
>>>due to header file problems under Fedora. Is there a prerequisite to
>>>including linux/ip.h, or am I hitting some other issue?
>>>
>>>Any insight is much appreciated,
>>
>>
>>Add:
>>#include <linux/types.h>
>>
>>and it should be fine.
>>
>>linux/ip.h should probably include it itself.
>>It wasn't in bugzilla, so I added it.
>>
>>
>
>
>-- 
>Thank you,
>Andrew Robert
>Principal Systems Analyst
>TS&S Infrastructure Support - OpenVMS
>Massachusetts Financial Services
>Phone:  (617) 954-5882
>Pager:  (781) 764-7321
>E-mail: arobert@xxxxxxx
>
>
>-- 
>fedora-list mailing list
>fedora-list@xxxxxxxxxx
>To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux