You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by ISF - Hassan Shabbir <ha...@isf.com.pk> on 2006/04/28 08:34:51 UTC
ERROR : (.text+0x3d): undefined reference to `apr_initialize'
Dear
I am working in Linux SUSE environment .
I am new to APR . I have made the sample program in C (gcc) using APR
library .
Every Time I run the program this error occurs :
ERROR : (.text+0x3d): undefined reference to `apr_initialize'
I have checked the paths for the apr include and lib folders . They are
correct.
The sample program is given below.
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <apr_general.h>
#include <apr_pools.h>
#define MEM_ALLOC_SIZE 1024
int main(int argc, const char *argv[])
{
system("clear");
printf("\n\n\t\t\t\t\t\tIN MAIN\n\n");
apr_status_t rv;
apr_pool_t *mp;
char *buf1;
char *buf2;
// per-process initialization //
rv = apr_initialize();
//rv = apr_app_initialize(&argc,argv,NULL);
if (rv != APR_SUCCESS) {
assert(0);
return -1;
}
// create a memory pool. //
apr_pool_create(&mp, NULL);
// allocate memory chunks from the memory pool //
buf1 = apr_palloc(mp, MEM_ALLOC_SIZE);
buf2 = apr_palloc(mp, MEM_ALLOC_SIZE);
// destroy the memory pool. These chunks above are freed by this //
apr_pool_destroy(mp);
apr_terminate();
printf("\n\n\t\t\t\t\t\tSUCCESSFUL\n\n");
return 0;
}
---------------------------------------------------------------------
The complete error information is given below:
---------------------------------------------------------------------
gcc -c -I/usr/local/include/subversion-1 -I/usr/local/apr/include/apr-0 test.c
-o test.o -L/usr/local/lib -L/usr/local/apr/lib
gcc -o test test.o -L/usr/local/lib -L/usr/local/apr/lib
test.o: In function `main':
test.c:(.text+0x3d): undefined reference to `apr_initialize'
collect2: ld returned 1 exit status
make: *** [all] Error 1
--------------------------------------------
The make file is given below :
-------------------------------------------
INC=-I/usr/local/include/subversion-1 -I/usr/local/apr/include/apr-0
LIB=-L/usr/local/lib -L/usr/local/apr/lib
all:
gcc -c $(INC) test.c -o test.o $(LIB)
gcc -o test test.o $(LIB)
./test
clean:
rm -f test.o
kindly reply me as soon as possible . I shall be grateful to you for this act
of kindness.
Regards,
Hassan Shabbir
Re: ERROR : (.text+0x3d): undefined reference to `apr_initialize'
Posted by Bojan Smojver <bo...@rexursive.com>.
On Fri, 2006-04-28 at 10:41 +0100, Nick Kew wrote:
> Which reminds me: what's the function of the numeric suffix?
Probably to be able to have multiple binary incompatible major versions
installed in parallel.
--
Bojan
Re: ERROR : (.text+0x3d): undefined reference to `apr_initialize'
Posted by Nick Kew <ni...@webthing.com>.
On Friday 28 April 2006 08:22, Bojan Smojver wrote:
> Quoting ISF - Hassan Shabbir <ha...@isf.com.pk>:
> > gcc -o test test.o $(LIB)
You forgot to link the libraries!
>
> Have you tried with "-lapr-0 -laprutil-0" (or similar) at the end of
> the above?
ITYM apr-1 :-)
Which reminds me: what's the function of the numeric suffix?
I keep forgetting that and finding myself with "-lapr -laprutil"
in a makefile.
--
Nick Kew
Re: ERROR : (.text+0x3d): undefined reference to `apr_initialize'
Posted by Bojan Smojver <bo...@rexursive.com>.
Quoting ISF - Hassan Shabbir <ha...@isf.com.pk>:
> gcc -o test test.o $(LIB)
Have you tried with "-lapr-0 -laprutil-0" (or similar) at the end of
the above?
--
Bojan