Sorry, i missed in linking adding the object of the the application, generated from compilation step that's why it give error "undefined reference to `main'".
In linking statically use this command for linking: gcc -static -L./../rohc-1.2.0/ -o packetforwardrohc packetforwardrohc.o -lrohc_decomp -lrohc_comp -lrohc_common -lm Thanks - Yasser Nour El-Din On Thu, 2009-10-08 at 14:27 +0200, Josephine Kakande wrote: > Hi Yasser, > > Thanks a lot for the feedback and suggestions. > > > Hello, > > I had a problem similar to this when trying to link statically > with rohc > libraries, and found that the order of libraries to link is > important. > > Here is the commands i use to link with rohc libraries: > > Compiling my application (rohc_proc.c): > > gcc -I./../RoHC-1.1.0 -I./../RoHC-1.1.0/include -c rohc_proc.c > -o > rohc_proc.o > > Then, Linking my application with rohc libraries: > > gcc -static -L./../RoHC-1.1.0/lib -lrohc_decomp -lrohc_comp > -lrohc_common -lm > > I noticed also you use absolute path in includes used in your > application: > > #include "/home/josie/rohc-1.2.0/src/common/rohc.h" > #include "/home/josie/rohc-1.2.0/src/comp/rohc_comp.h" > > i think it should be replaced by: > > #include "rohc.h" > #include "rohc_comp.h" > > Thanks for the suggestion, I made the changes to the includes. > > > > and -I./../RoHC-1.2.0/include in the compilation flags should > take care > of translating this includes to absolute path. > > Can you please provide the commands or makefile you use for > building > your application with rohc library, and if you try to build it > statically? > > > I've recompiled with this command and this is the error output: > > > $ gcc packetforwardrohc.c -o packetforwardrohc -I/usr/include > -L/usr/lib -lpcap `libnet-config --defines --cflags --libs` > -lrohc_comp -lrohc_common -lm > > > In file included from headers.h:8, > from packetforwardrohc.c:24: > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:197: warning: ‘struct > ip_packet’ declared inside parameter list > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:197: warning: its scope is > only this definition or declaration, which is probably not what you > want > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:205: warning: ‘struct > ip_packet’ declared inside parameter list > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:210: warning: ‘struct > ip_packet’ declared inside parameter list > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:279: warning: ‘struct > ip_packet’ declared inside parameter list > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:280: warning: ‘struct > ip_packet’ declared inside parameter list > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:290: warning: ‘struct > ip_packet’ declared inside parameter list > In file included from packetforwardrohc.c:24: > headers.h:14:1: warning: "ETHER_ADDR_LEN" redefined > In file included from /usr/include/libnet.h:57, > from packetforwardrohc.c:23: > /usr/include/net/ethernet.h:52:1: warning: this is the location of the > previous definition > packetforwardrohc.c: In function ‘got_packet’: > packetforwardrohc.c:509: warning: passing argument 2 of > ‘rohc_compress’ discards qualifiers from pointer target type > /usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o: In function > `_start': > (.text+0x18): undefined reference to `main' > collect2: ld returned 1 exit status > > Statically > > > $ gcc -I./../rohc-1.2.0 -I./../rohc-1.2.0/src -c packetforward.c -o > packetforward.o > > In file included from packetforward.c:8: > /usr/include/libnet.h:87:2: error: #error "byte order has not been > specified, you'll" "need to #define either LIBNET_LIL_ENDIAN or > LIBNET_BIG_ENDIAN. See the" "documentation regarding the > libnet-config script." > In file included from headers.h:8, > from packetforward.c:9: > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:197: warning: ‘struct > ip_packet’ declared inside parameter list > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:197: warning: its scope is > only this definition or declaration, which is probably not what you > want > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:205: warning: ‘struct > ip_packet’ declared inside parameter list > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:210: warning: ‘struct > ip_packet’ declared inside parameter list > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:279: warning: ‘struct > ip_packet’ declared inside parameter list > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:280: warning: ‘struct > ip_packet’ declared inside parameter list > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:290: warning: ‘struct > ip_packet’ declared inside parameter list > packetforward.c:648:2: warning: no newline at end of file > > > $ gcc -static -L./../rohc-1.2.0/ -lrohc_decomp -lrohc_comp > -lrohc_common -lm > > /usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o: In function > `_start': > (.text+0x18): undefined reference to `main' > collect2: ld returned 1 exit status > jo...@josie-laptop:~/packetforward$ > > Kindly advise. > > Thanks, > Josephine > > > > > On Wed, 2009-10-07 at 22:49 +0200, Josephine Kakande wrote: > > Hello, > > > > I'm wondering if anyone has been able to figure out a > solution to my > > problem. > > > > I'd really appreciate your feedback. > > > > Thanks and regards, > > Josephine > > > > On Wed, Sep 23, 2009 at 11:27 AM, Josephine Kakande > > <[email protected]> wrote: > > > > Hello, > > > > I'm trying to use the rohc-compressor in a program > I'm using > > for packet injection. > > > > However I get the following error when i attempt to > compile : > > > > > > In file included from headers.h:8, > > from packetforwardrohc.c:9: > > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:197: > warning: > > ‘struct ip_packet’ declared inside parameter list > > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:197: > warning: its > > scope is only this definition or declaration, which > is > > probably not what you want > > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:205: > warning: > > ‘struct ip_packet’ declared inside parameter list > > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:210: > warning: > > ‘struct ip_packet’ declared inside parameter list > > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:279: > warning: > > ‘struct ip_packet’ declared inside parameter list > > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:280: > warning: > > ‘struct ip_packet’ declared inside parameter list > > /home/josie/rohc-1.2.0/src/comp/rohc_comp.h:290: > warning: > > ‘struct ip_packet’ declared inside parameter list > > In file included from packetforwardrohc.c:9: > > headers.h:14:1: warning: "ETHER_ADDR_LEN" redefined > > In file included from /usr/include/libnet.h:57, > > from packetforwardrohc.c:8: > > /usr/include/net/ethernet.h:52:1: warning: this is > the > > location of the previous definition > > packetforwardrohc.c: In function ‘got_packet’: > > packetforwardrohc.c:494: warning: passing argument 2 > of > > ‘rohc_compress’ discards qualifiers from pointer > target type > > > /usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o: In > > function `_start': > > (.text+0x18): undefined reference to `main' > > /tmp/cc2r5eZ0.o: In function `got_packet': > > packetforwardrohc.c:(.text+0xd38): undefined > reference to > > `rohc_compress' > > /tmp/cc2r5eZ0.o: In function `main.5994': > > packetforwardrohc.c:(.text+0xe08): undefined > reference to > > `crc_get_polynom' > > packetforwardrohc.c:(.text+0xe16): undefined > reference to > > `crc_table_3' > > packetforwardrohc.c:(.text+0xe1b): undefined > reference to > > `crc_init_table' > > packetforwardrohc.c:(.text+0xe27): undefined > reference to > > `crc_get_polynom' > > packetforwardrohc.c:(.text+0xe35): undefined > reference to > > `crc_table_7' > > packetforwardrohc.c:(.text+0xe3a): undefined > reference to > > `crc_init_table' > > packetforwardrohc.c:(.text+0xe46): undefined > reference to > > `crc_get_polynom' > > packetforwardrohc.c:(.text+0xe54): undefined > reference to > > `crc_table_8' > > packetforwardrohc.c:(.text+0xe59): undefined > reference to > > `crc_init_table' > > packetforwardrohc.c:(.text+0xe7d): undefined > reference to > > `rohc_alloc_compressor' > > packetforwardrohc.c:(.text+0xffa): undefined > reference to > > `rohc_activate_profile' > > packetforwardrohc.c:(.text+0x1010): undefined > reference to > > `rohc_activate_profile' > > packetforwardrohc.c:(.text+0x1026): undefined > reference to > > `rohc_activate_profile' > > packetforwardrohc.c:(.text+0x103c): undefined > reference to > > `rohc_activate_profile' > > packetforwardrohc.c:(.text+0x1052): undefined > reference to > > `rohc_activate_profile' > > packetforwardrohc.c:(.text+0x121f): undefined > reference to > > `rohc_alloc_compressor' > > packetforwardrohc.c:(.text+0x13a1): undefined > reference to > > `rohc_free_compressor' > > collect2: ld returned 1 exit status > > > > > > Could you tell me what I might be doing wrong? > Attached is the > > sample code. > > > > Would really appreciate your feedback, thanks. > > > > Regards, > > Josephine > > > > > > > > > > > > > > > _______________________________________________ > > Mailing list: https://launchpad.net/~rohc > > Post to : [email protected] > > Unsubscribe : https://launchpad.net/~rohc > > More help : https://help.launchpad.net/ListHelp > > > _______________________________________________ > Mailing list: https://launchpad.net/~rohc > Post to : [email protected] > Unsubscribe : https://launchpad.net/~rohc > More help : https://help.launchpad.net/ListHelp > _______________________________________________ Mailing list: https://launchpad.net/~rohc Post to : [email protected] Unsubscribe : https://launchpad.net/~rohc More help : https://help.launchpad.net/ListHelp

