LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   compilation error (https://www.linuxquestions.org/questions/programming-9/compilation-error-320407/)

Varadharajan 05-05-2005 11:16 AM

compilation error
 
Hello everyone,
I have installed libpcap,libnet libraries for ICMP packet generation.While trying to compile the file icmpnum.c ,i am getting the following errors.Can anyone give a solution to rectify
this problem.


[root@core-2-06 root]# gcc 'libnetnet-config --defines' -o icmpenum icmpenum.c -lnet -lpcap

gcc: libnetnet-config --defines: No such file or directory
In file included from icmpenum.c:5:/usr/include/libnet.h:87:2: #error "byte order has not been specified, you'llneed to #define either LIBNET_LIL_ENDIAN or LIBNET_BIG_ENDIAN. See the
documentation regarding the libnet-config script."

thanking you,
S.Varadharajan.

pedro.velho 05-05-2005 12:13 PM

Try libnet instead libnetnet.

Code:

# gcc 'libnetnet-config --defines' -o icmpenum icmpenum.c -lnet -lpcap ==> wrong

# gcc 'libnet-config --defines' -o icmpenum icmpenum.c -lnet -lpcap ==> right


Dark_Helmet 05-05-2005 01:02 PM

I think you're using the wrong quotation marks. You're using single quotes ( ' ) when I believe you should be using backticks ( ` ). Here's the difference:

The command treats anything inside sigle quotes literally. So your command says to treat 'libnetnet-config --defines' exactly as it appears. So, gcc is expecting to find a file named 'libnetnet-config --defines' (with a space and the dashes as part of its name).

The backticks are treated much differently. The shell interprets anything between backticks as a command. Then, the shell replaces the command with the command's output before executing the remaining item(s).

Try your compile with backticks instead of single quotes. On my keyboard (US layout), the backtick is on the same key as the tilde ( ~ ); near the top-left of the keyboard.

hhegab 02-01-2007 07:10 PM

Same Problem
 
I have this same problem, with the following output:
----
[hatim@D0-Atlas icmpenum-1.1.1]$ gcc `libnet-config --defines` -o icmpenum icmpenum.c -lnet -lpcap
icmpenum.c: In function ‘send_packets’:
icmpenum.c:146: error: ‘LIBNET_IP_H’ undeclared (first use in this function)
icmpenum.c:146: error: (Each undeclared identifier is reported only once
icmpenum.c:146: error: for each function it appears in.)
icmpenum.c:152: error: ‘LIBNET_ERR_FATAL’ undeclared (first use in this function)
icmpenum.c:171: error: ‘LIBNET_ICMP_TS_H’ undeclared (first use in this function)
icmpenum.c:196: warning: passing argument 1 of ‘libnet_do_checksum’ from incompatible pointer type
icmpenum.c:196: warning: passing argument 2 of ‘libnet_do_checksum’ makes pointer from integer without a cast
icmpenum.c:196: error: too few arguments to function ‘libnet_do_checksum’
icmpenum.c:238: error: ‘LIBNET_ERR_WARNING’ undeclared (first use in this function)
icmpenum.c: In function ‘receive_packets_normal’:
icmpenum.c:284: error: dereferencing pointer to incomplete type
icmpenum.c: In function ‘grab_icmp’:
icmpenum.c:321: error: dereferencing pointer to incomplete type
icmpenum.c: In function ‘main’:
icmpenum.c:550: error: ‘LIBNET_ICMP_ECHO_H’ undeclared (first use in this function)
icmpenum.c:554: error: ‘LIBNET_ICMP_TS_H’ undeclared (first use in this function)
[hatim@D0-Atlas icmpenum-1.1.1]$
----

What should I do?

H H

Dark_Helmet 02-01-2007 08:32 PM

Your problem is not with the linking stage, but with the compilation stage. The errors seem to suggest that one (or more) of your files are missing a necessary #include file.

hhegab 02-01-2007 08:58 PM

Thanks for the reply,

Have you any idea how may I solve this?
I mean what should I do to have icmpenum compiled?

H H

Dark_Helmet 02-01-2007 09:22 PM

I can't say with any certainty how to solve it. Without having a copy of the code to examine, all I can say is look at your source code files to make sure you #include all the files that are necessary. All of this should be in either the man pages for the functions in libnet or on some web-based online documentation for libnet.

Some libraries require only #includes.

Some libraries require #includes and #defines.

Some libraries support commands such as "libnet-config --cflags".

You need to read the libnet documentation carefully. It should answer any and all questions you have in using the library properly.

I haven't used libnet before and I can't say what it wants.

hhegab 02-02-2007 03:53 AM

Thanks a lot?

H H

Dark_Helmet 02-02-2007 04:20 PM

I'm sorry if you feel like my help isn't what you were looking for, but let me point out a few things.

First, Varadharajan's original message identified a problem he was having with a compilation command, and he gave the command he was using. I was able to look at the command he used, saw the problem, and told him how to correct it. You, on the other hand, chose to identify a compilation problem, but provided no source code. Very few people can diagnose a compilation error by looking at only error results--there is simply not enough information.

Second, without code to look at, I cannot possibly fathom what you're trying to use the library for or in what way. Clearly, someone (e.g. Varadharajan) has used libnet to create their own program. The library works and can be used. There many ways that a library setup can be broken. Again, you have chosen only to show the error messages which gives no information to the root cause.

Third, you posted your response in an already existing thread. I have not professed to be a libnet expert of any sort. The original problem was solved because of a syntactical problem Varadharajan had with his command--a shell issue, not a libnet issue. I am not going to download libnet, read its documentation, and then write you a reader's digest version on how to use the library. All that is out there already. You should have read it yourself. And again, without source code, I would be at a loss even if I did do your research for you.

You have posted an error you received. You have given no source code. You haven't indicated anything else you've tried and what results those attempts gave. All things considered, my advice is still legitimate: re-read the documentation to make sure you're doing what you need to use the library properly. Until you give more information, that's the only advice anyone can give.

If you feel I'm being a jerk, feel free start a new thread, post the message you used above, and count the number of replies before someone says to "post the source code".

Dark_Helmet 02-04-2007 01:56 AM

Because I actually am a nice guy, I looked around some more. For anyone that reads this, icmpenum.c appears to be a file provided by Symantec (which no one mentioned previously, leading me to believe these were from-scratch projects). Its purpose, according to the description, is a proof-of-concept utility to map network machines by using ICMP requests. Because it's a proof of concept tool by a security company, I have a hard time believing there's a legitimate use here because network administrators actually interested in testing their networks would probably know how to compile this software easily. Similarly, any university/college where this type of detection would be put to use for research purposes would likely be used by people fully capable of compiling it.

Regardless, on the off-chance that anyone using this utility is not some script-kiddie trying to break into other machines, verify that both required libraries are installed completely on the system - not just compiled in a local, home directory. The compilation error above is likely caused by a failure to find an appropriate header file (or finding the wrong one). If installing required libraries is still too cumbersome, a pre-compiled executable can be found at Packet Storm (something that could have been found by minimal searching - perhaps in looking to find the answer for a compilation problem).


All times are GMT -5. The time now is 10:47 PM.