Hi,

i tried it again but without success

so what i have tried to do is just change the main of tcpreplay.c to be a 
function that i will call it in my project.

my_function(int c,char* v[])
{
/*copy of the main of tcpreplay.c*/
}

i have compiled it and i got all the needed .o files, i have used the same 
makefile (it is huge and really i couldn't understand all as libtool and 
autogen... to figure out how should i compile it)  :: i got error for build of 
binary (no main) of tcpreplay which i don't need it but i got at the end the 
objects files

and i have created the tcpreplay library using this shell script

#!/bin/sh
AR="ar"
ARFLAGS="cru"
libtcprewrite_a_AR="$AR $ARFLAGS"
libtcpreplay_a_AR="$AR $ARFLAGS"
LIBOPTS_LDADD="../libopts/libopts.la"
libtcprewrite_a_LIBADD=
libtcpreplay_a_LIBADD="./common/libcommon.a ../../lib/libstrl.a  
/usr/lib/libpcap.a ../libopts/libopts.la"
LIBTOOL="libtool"
RANLIB="ranlib"

am_libtcprewrite_a_OBJECTS="tcpreplay-tcpreplay.o \
    tcprewrite-tcprewrite_opts.o"

am_libtcpreplay_a_OBJECTS="tcpreplay-tcpreplay_opts.o \
    tcpreplay-send_packets.o \
    tcpreplay-signal_handler.o \
    tcpreplay-tcpreplay.o \
    tcpreplay-sleep.o"

libtcprewrite_a_OBJECTS="$am_libtcprewrite_a_OBJECTS"
libtcpreplay_a_OBJECTS="$am_libtcpreplay_a_OBJECTS"

rm -f libtcprewrite.a
rm -f libtcpreplay.a

$libtcpreplay_a_AR libtcpreplay.a $libtcpreplay_a_OBJECTS $libtcpreplay_a_LIBADD
$RANLIB libtcpreplay.a

#$libtcprewrite_a_AR libtcprewrite.a $libtcprewrite_a_OBJECTS 
$libtcprewrite_a_LIBADD
#$RANLIB libtcprewrite.a

and i have compiled my project using this libraries too -lcommon -lstrl -lopts 
-ltcpreplay -lpcap
but it doesn't work

here are the linker errors: the problem is that all these undefined references 
should exist in the libraries --> so i have built wrong libraries.

/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay.o):
 In function `post_args':
tcpreplay.c:(.text+0xc8): undefined reference to `get_interface'
tcpreplay.c:(.text+0xf6): undefined reference to `_our_safe_strdup'
tcpreplay.c:(.text+0x10f): undefined reference to `sendpacket_open'
tcpreplay.c:(.text+0x124): undefined reference to `sendpacket_get_dlt'
tcpreplay.c:(.text+0x177): undefined reference to `notice'
tcpreplay.c:(.text+0x235): undefined reference to `_our_safe_strdup'
tcpreplay.c:(.text+0x2a3): undefined reference to `get_interface'
tcpreplay.c:(.text+0x2cb): undefined reference to `_our_safe_strdup'
tcpreplay.c:(.text+0x2e4): undefined reference to `sendpacket_open'
tcpreplay.c:(.text+0x2f9): undefined reference to `sendpacket_get_dlt'
tcpreplay.c:(.text+0x339): undefined reference to `_our_safe_strdup'
tcpreplay.c:(.text+0x353): undefined reference to `read_cache'
tcpreplay.c:(.text+0x37e): undefined reference to `_our_safe_free'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay.o):
 In function `init':
tcpreplay.c:(.text+0x56d): undefined reference to `_our_safe_malloc'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay.o):
 In function `replay_file':
tcpreplay.c:(.text+0x64f): undefined reference to `tcpdump_open'
tcpreplay.c:(.text+0x664): undefined reference to `sendpacket_get_dlt'
tcpreplay.c:(.text+0x69e): undefined reference to `tcpdump_close'
tcpreplay.c:(.text+0x70c): undefined reference to `notice'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay.o):
 In function `tcpreplay_principal_function':
tcpreplay.c:(.text+0x824): undefined reference to `optionProcess'
tcpreplay.c:(.text+0x868): undefined reference to `_our_safe_malloc'
tcpreplay.c:(.text+0x89b): undefined reference to `notice'
tcpreplay.c:(.text+0x8cf): undefined reference to `_our_safe_strdup'
tcpreplay.c:(.text+0xa2c): undefined reference to `packet_stats'
tcpreplay.c:(.text+0xa39): undefined reference to `sendpacket_getstat'
tcpreplay.c:(.text+0xa5a): undefined reference to `sendpacket_getstat'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):
 In function `doOptVersion':
tcpreplay_opts.c:(.text+0x47): undefined reference to `svn_version'
tcpreplay_opts.c:(.text+0xe9): undefined reference to `get_pcap_version'
tcpreplay_opts.c:(.text+0x19b): undefined reference to `sendpacket_get_method'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):
 In function `doOptPps_Multi':
tcpreplay_opts.c:(.text+0x25a): undefined reference to `option_usage_fp'
tcpreplay_opts.c:(.text+0x276): undefined reference to `optionShowRange'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):
 In function `doOptLimit':
tcpreplay_opts.c:(.text+0x30a): undefined reference to `option_usage_fp'
tcpreplay_opts.c:(.text+0x326): undefined reference to `optionShowRange'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):
 In function `doOptLoop':
tcpreplay_opts.c:(.text+0x3ba): undefined reference to `option_usage_fp'
tcpreplay_opts.c:(.text+0x3d6): undefined reference to `optionShowRange'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):
 In function `doOptListnics':
tcpreplay_opts.c:(.text+0x422): undefined reference to `list_interfaces'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):(.data+0x54):
 undefined reference to `optionUsage'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):(.data+0x188):
 undefined reference to `optionNumericVal'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):(.data+0x1c8):
 undefined reference to `optionNumericVal'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):(.data+0x4c8):
 undefined reference to `optionNumericVal'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):(.data+0x708):
 undefined reference to `optionPagedUsage'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-tcpreplay_opts.o):(.data+0x788):
 undefined reference to `optionLoadOpt'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-send_packets.o):
 In function `cache_mode':
send_packets.c:(.text+0x67): undefined reference to `check_cache'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-send_packets.o):
 In function `do_sleep':
send_packets.c:(.text+0x60f): undefined reference to `timerdiv'
/home/yassine/MasterThesis/workspace/workdirectory/lib/libtcpreplay.a(tcpreplay-send_packets.o):
 In function `send_packets':
send_packets.c:(.text+0x764): undefined reference to `catcher'
send_packets.c:(.text+0x8aa): undefined reference to `sendpacket'
send_packets.c:(.text+0x963): undefined reference to `_our_safe_malloc'
send_packets.c:(.text+0x9a2): undefined reference to `_our_safe_malloc'
send_packets.c:(.text+0x9f2): undefined reference to `break_now'
send_packets.c:(.text+0xa2f): undefined reference to `sendpacket_geterr'
send_packets.c:(.text+0xa6c): undefined reference to `tcpdump_print'
send_packets.c:(.text+0xac0): undefined reference to `_our_safe_malloc'
send_packets.c:(.text+0xb1c): undefined reference to `break_now'
collect2: ld returned 1 exit status

Sorry for this question, really i spent a lot of time to get it working and i 
need help

Thanks.
 
> From: synfina...@gmail.com
> Date: Thu, 20 Aug 2009 11:00:18 -0700
> To: tcpreplay-users@lists.sourceforge.net
> Subject: Re: [Tcpreplay-users] creating a library
> 
> On Thu, Aug 20, 2009 at 10:51 AM, yassine antir<ensi_...@hotmail.com> wrote:
> > Hi every body,
> >
> > i am Yassine, i am student and i am writing an application that uses
> > tcprewrite and tcpreplay what i have done till now is a system call for
> > these 2 binaries  system("tcpreplay...")
> > but this method is not sufficient for me (not efficient: the processing time
> > is very important for my application and i want not lost time with this
> > system calls, and another reason is that's not elegant too).
> > so instead of going through the source code (which is huge) to take only
> > what i need, i thought that creating a static library will be more better.
> > but unfortunately i could not do it
> > what i have done is:
> >
> > !/bin/sh
> > AR="ar"
> > ARFLAGS="cru"
> > libtcprewrite_a_AR="$AR $ARFLAGS"
> > libtcpreplay_a_AR="$AR $ARFLAGS"
> > libtcprewrite_a_LIBADD=
> > libtcpreplay_a_LIBADD=
> > LIBTOOL="libtool"
> > RANLIB="ranlib"
> > OBJEXT=" o"
> >
> > am_libtcprewrite_a_OBJECTS="tcpreplay-tcpreplay.o \
> >     tcprewrite-tcprewrite_opts.o"
> >
> > am_libtcpreplay_a_OBJECTS="tcpreplay-send_packets.o \
> >     tcpreplay-signal_handler.o \
> >     tcpreplay-sleep.o \
> >     tcpreplay-tcpreplay_opts.o"
> >
> > libtcprewrite_a_OBJECTS="$am_libtcprewrite_a_OBJECTS"
> > libtcpreplay_a_OBJECTS="$am_libtcpreplay_a_OBJECTS"
> >
> > rm -f libtcprewrite.a
> > rm -f libtcpreplay.a
> >
> > $libtcprewrite_a_AR libtcprewrite.a $libtcprewrite_a_OBJECTS
> > $libtcprewrite_a_LIBADD
> > $RANLIB libtcprewrite.a
> > $libtcpreplay_a_AR libtcpreplay.a $libtcpreplay_a_OBJECTS
> > $libtcpreplay_a_LIBADD
> > $RANLIB libtcpreplay.a
> >
> > and i have rewrite the main of tcpreplay in my application as a function
> > that i will use it there (i thought that i have added all headers files and
> > libraries that i need  libopts.a libcommon.a libsrtl.a libtcpreplay.a ...)
> > but i failed to do it.
> >
> > so if somebody have an idea or can give me a tip i will be very grateful. i
> > hope that i get a quick answer :)
> > and sorry for my english :D
> 
> Without any errors & more details I can't really be much of a help.
> You should look at the existing Makefile.am files to know what needs
> to be linked and the appropriate orders.
> 
> Alternatively, you can try the source code in trunk (the future 4.0
> release) which supports building libraries and a full API to all the
> tcpreplay/edit functionality.  The caveat with that though, is that
> 4.0 uses cmake (www.cmake.org) rather then Autotools for building.
> Unfortunately, 4.0 is is still a work in progress so not everything is
> complete, but a large part of the librarization effort is complete and
> I'm more then happy to accept patches which complete the work. :)
> 
> -- 
> Aaron Turner
> http://synfin.net/
> http://tcpreplay.synfin.net/ - Pcap editing and replay tools for Unix & 
> Windows
> Those who would give up essential Liberty, to purchase a little temporary
> Safety, deserve neither Liberty nor Safety.
>     -- Benjamin Franklin
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Tcpreplay-users mailing list
> Tcpreplay-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tcpreplay-users
> Support Information: http://tcpreplay.synfin.net/trac/wiki/Support

_________________________________________________________________
Avec Windows Live, vous organisez, retouchez et partagez vos photos.
http://www.microsoft.com/northafrica/windows/windowslive/products/photo-gallery-edit.aspx
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcpreplay-users mailing list
Tcpreplay-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcpreplay-users
Support Information: http://tcpreplay.synfin.net/trac/wiki/Support

Reply via email to