You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by SAMEER KUMAR <sa...@gmail.com> on 2009/03/25 10:13:10 UTC

[Problem] Not able to Link APR to my programs

I am new to APR. I am going to use it for developing a Apache like hybrid
architecture for OpenSIPS [www.opensips.org], which an open source SIP[RFC
3261] server.

I have downloaded APR and installed it on my Fedora 9 machine using the
configure and make commands. I tested the installation with testall. But I
am not able to use this in my programs and not able to link to the header
files in APR.

I am using a cat1.c program to run, in which I am using functions of APR
module. I have tried these gcc commands:

gcc -l lapr-1  /cat1.c

*gcc /cat1.c -L. -lapr-1*

my working directory is

*/usr/local/apr/lib*

I am getting following set of errors:

/cat1.c:1:23: error: apr_pools.h: No such file or directory
/cat1.c:2:25: error: apr_file_io.h: No such file or directory
/cat1.c: In function ‘main’:
/cat1.c:8: error: ‘apr_pool_t’ undeclared (first use in this function)
/cat1.c:8: error: (Each undeclared identifier is reported only once
/cat1.c:8: error: for each function it appears in.)
/cat1.c:8: error: ‘pool’ undeclared (first use in this function)
/cat1.c:9: error: ‘apr_file_t’ undeclared (first use in this function)
/cat1.c:9: error: ‘thefile’ undeclared (first use in this function)
/cat1.c:9: error: ‘NULL’ undeclared (first use in this function)
/cat1.c:10: error: ‘out’ undeclared (first use in this function)
/cat1.c:14: error: ‘apr_terminate’ undeclared (first use in this function)
/cat1.c:19: error: ‘APR_READ’ undeclared (first use in this function)
/cat1.c:19: error: ‘APR_CREATE’ undeclared (first use in this function)
/cat1.c:20: error: ‘APR_UREAD’ undeclared (first use in this function)
/cat1.c:20: error: ‘APR_UWRITE’ undeclared (first use in this function)
/cat1.c:20: error: ‘APR_GREAD’ undeclared (first use in this function)
/cat1.c:21: error: ‘APR_SUCCESS’ undeclared (first use in this function)
/cat1.c:25: error: ‘APR_EOF’ undeclared (first use in this function)
/cat1.c:26: error: ‘apr_size_t’ undeclared (first use in this function)
/cat1.c:26: error: expected ‘;’ before ‘bytes’
/cat1.c:29: error: ‘bytes’ undeclared (first use in this function)
/cat1.c:29: warning: incompatible implicit declaration of built-in function
‘strlen’


Can some one help me where I am lacking. Can some one track my mistake. I
will be very grateful if someone can do that. :)

Thank You in advance.

Sameer Kumar
B.Tech, Computer Engineering
Institute of Technology,
Nirma University,
Ahmedabad, Gujarat

Re: [Problem] Not able to Link APR to my programs

Posted by Jeff Trawick <tr...@gmail.com>.
On Wed, Mar 25, 2009 at 10:13 AM, SAMEER KUMAR <sa...@gmail.com>wrote:

> I have downloaded APR and installed it on my Fedora 9 machine using the
> configure and make commands. I tested the installation with testall. But I
> am not able to use this in my programs and not able to link to the header
> files in APR.


find where it installs apr-1-config and look at the help text for
apr-1-config to see which flags you need for compiling and linking (that
will handle finding apr header files)

Re: [Problem] Not able to Link APR to my programs

Posted by SAMEER KUMAR <sa...@gmail.com>.
Thanks to everyone for suggesting the solutions,


I tried, as proposed by various users and developers in response to my
query, using the -I<path of apr-$installedversion-config>. That too did not
work. Finally I managed to serve my purpose using gcc command, executing
apr-$installedversion-config file (ie apr-1-config installed in
/usr/local/apr/bin in my case). I use this file to print the options
required for complition using APR library.

Here is a snapshot of what I used:


[root@a104cc-user86 bin]# gcc $(./apr-1-config --includes) $(./apr-1-config
--libs) $(./apr-1-config --link-ld) $(./apr-1-config --cflags)
$(./apr-1-config --cppflags)  /cat.c


The options I have used with ./apr-1-config can be better undestood by
simply executing that file at shell.

Thanks once again for helping us.

Regards,
Sameer Kumar
B.Tech, Computer Engineering
Institute of Technology,
Nirma University,
Ahmedabad, Gujarat
email: sameer.kasi200x@gmail.com
         05bce032@nirmauni.ac.in
Phone: +919375220396


On Wed, Mar 25, 2009 at 6:06 PM, Eric Covener <co...@gmail.com> wrote:

> On Wed, Mar 25, 2009 at 5:13 AM, SAMEER KUMAR <sa...@gmail.com>
> wrote:
> > I am new to APR. I am going to use it for developing a Apache like hybrid
> > architecture for OpenSIPS [www.opensips.org], which an open source
> SIP[RFC
> > 3261] server.
> >
> > I have downloaded APR and installed it on my Fedora 9 machine using the
> > configure and make commands. I tested the installation with testall. But
> I
> > am not able to use this in my programs and not able to link to the header
> > files in APR.
> >
> > I am using a cat1.c program to run, in which I am using functions of APR
> > module. I have tried these gcc commands:
> >
> > gcc -l lapr-1  /cat1.c
> >
> > gcc /cat1.c -L. -lapr-1
> >
> > my working directory is
> >
> > /usr/local/apr/lib
> >
> > I am getting following set of errors:
> >
> > /cat1.c:1:23: error: apr_pools.h: No such file or directory
>
> You're not finding the installed APR headers.  Try adding apr-1-config
>  --includes to your compiler flags.
>
> (you might need to find where apr-1-config was installed when you built
> apr)
>
>
> --
> Eric Covener
> covener@gmail.com
>

Re: [Problem] Not able to Link APR to my programs

Posted by Eric Covener <co...@gmail.com>.
On Wed, Mar 25, 2009 at 5:13 AM, SAMEER KUMAR <sa...@gmail.com> wrote:
> I am new to APR. I am going to use it for developing a Apache like hybrid
> architecture for OpenSIPS [www.opensips.org], which an open source SIP[RFC
> 3261] server.
>
> I have downloaded APR and installed it on my Fedora 9 machine using the
> configure and make commands. I tested the installation with testall. But I
> am not able to use this in my programs and not able to link to the header
> files in APR.
>
> I am using a cat1.c program to run, in which I am using functions of APR
> module. I have tried these gcc commands:
>
> gcc -l lapr-1  /cat1.c
>
> gcc /cat1.c -L. -lapr-1
>
> my working directory is
>
> /usr/local/apr/lib
>
> I am getting following set of errors:
>
> /cat1.c:1:23: error: apr_pools.h: No such file or directory

You're not finding the installed APR headers.  Try adding apr-1-config
 --includes to your compiler flags.

(you might need to find where apr-1-config was installed when you built apr)


-- 
Eric Covener
covener@gmail.com

[Problem] Not able to Link APR to my programs

Posted by SAMEER KUMAR <sa...@gmail.com>.
Well thnx guys...

I tried, as proposed by various users and developers in response to my
> query, using the -I<path of apr-$installedversion-config>. That too did not
> work. Finally I managed to serve my purpose using gcc command, executing
> apr-$installedversion-config file (ie apr-1-config installed in
> /usr/local/apr/bin in my case). I use this file to print the options
> required for complition using APR library.
>
Lately I realized that, I have mistaken your advice being a novice.

Here is a snapshot of what I used:
>


> *[root@a104cc-user86 bin]# gcc $(./apr-1-config --includes)
> $(./apr-1-config --libs) $(./apr-1-config --link-ld) $(./apr-1-config
> --cflags) $(./apr-1-config --cppflags)  /cat.c
> *


You people suggested to add same thing, what i have added to my command (but
in a bit different way)...

Nick Kew wrote an excellent book on Apache 2 modules; the old "Writing
> Apache Modules in Perl and C" is still somewhat relevant as well.
>

I would like to know if some one can help me with material on programming
with APR.

Thnx alot guys...

Regards,
Sameer Kumar
B.Tech, Computer Engineering
Institute of Technology,
Nirma University,
Ahmedabad, Gujarat
email: sameer.kasi200x@gmail.com
          05bce032@nirmauni.ac.in
Phone: +919375220396

Re: [Problem] Not able to Link APR to my programs

Posted by SAMEER KUMAR <sa...@gmail.com>.
>
>
>
>    1.
>    $> export APR_LIBS="`apr-1-config --cflags --cppflags --includes --ldflags --link-ld --libs`"
>
>    2.
>    $> export APU_LIBS="`apu-1-config --includes --ldflags --link-ld --libs`"
>
>    3. $> gcc $APR_LIBS $APU_LIBS srcFile.c -o prgName
>
>

I guess you doing the same that I had done or others have suggested... your
way of doing is different...

Actually i copied the above from one of the writeups i did with APR on my
> blog. It's not much but maybe that helps you get started.
>
> http://blogs.coffeecrew.org/blogs/datapile/tags/apr
>
>

Thanks for the link :) As i said in previous posts. Help in any form is
appreciated.


Regards,
Sameer Kumar
B.Tech, Computer Engineering
Institute of Technology,
Nirma University,
Ahmedabad, Gujarat
email: sameer.kasi200x@gmail.com
          05bce032@nirmauni.ac.in
Phone: +919375220396

Re: [Problem] Not able to Link APR to my programs

Posted by Jens Frey <je...@coffeecrew.org>.
> Well thnx guys...
> I tried, as proposed by various users and developers in response to  
> my query, using the -I<path of apr-$installedversion-config>. That  
> too did not work. Finally I managed to serve my purpose using gcc  
> command, executing apr-$installedversion-config file (ie apr-1- 
> config installed in /usr/local/apr/bin in my case). I use this file  
> to print the options required for complition using APR library.
> Lately I realized that, I have mistaken your advice being a novice.
>
> Here is a snapshot of what I used:
>
> [root@a104cc-user86 bin]# gcc $(./apr-1-config --includes) $(./apr-1- 
> config --libs) $(./apr-1-config --link-ld) $(./apr-1-config -- 
> cflags) $(./apr-1-config --cppflags)  /cat.c
Maybe that works for you? I could not find the previous post

$> export APR_LIBS="`apr-1-config --cflags --cppflags --includes -- 
ldflags --link-ld --libs`"
$> export APU_LIBS="`apu-1-config --includes --ldflags --link-ld -- 
libs`"
$> gcc $APR_LIBS $APU_LIBS srcFile.c -o prgName

> You people suggested to add same thing, what i have added to my  
> command (but in a bit different way)...
>
> Nick Kew wrote an excellent book on Apache 2 modules; the old  
> "Writing Apache Modules in Perl and C" is still somewhat relevant as  
> well.
>
> I would like to know if some one can help me with material on  
> programming with APR.
Actually i copied the above from one of the writeups i did with APR on  
my blog. It's not much but maybe that helps you get started.

http://blogs.coffeecrew.org/blogs/datapile/tags/apr

Hope i could help,

Jens


Re: [Problem] Not able to Link APR to my programs

Posted by SAMEER KUMAR <sa...@gmail.com>.
Well thnx guys...

I tried, as proposed by various users and developers in response to my
> query, using the -I<path of apr-$installedversion-config>. That too did not
> work. Finally I managed to serve my purpose using gcc command, executing
> apr-$installedversion-config file (ie apr-1-config installed in
> /usr/local/apr/bin in my case). I use this file to print the options
> required for complition using APR library.
>
Lately I realized that, I have mistaken your advice being a novice.

Here is a snapshot of what I used:
>


> *[root@a104cc-user86 bin]# gcc $(./apr-1-config --includes)
> $(./apr-1-config --libs) $(./apr-1-config --link-ld) $(./apr-1-config
> --cflags) $(./apr-1-config --cppflags)  /cat.c
> *


You people suggested to add same thing, what i have added to my command (but
in a bit different way)...

Nick Kew wrote an excellent book on Apache 2 modules; the old "Writing
> Apache Modules in Perl and C" is still somewhat relevant as well.
>

I would like to know if some one can help me with material on programming
with APR.

Thnx alot guys...

Regards,
Sameer Kumar
B.Tech, Computer Engineering
Institute of Technology,
Nirma University,
Ahmedabad, Gujarat
email: sameer.kasi200x@gmail.com
          05bce032@nirmauni.ac.in
Phone: +919375220396

Fwd: [Problem] Not able to Link APR to my programs

Posted by SAMEER KUMAR <sa...@gmail.com>.
---------- Forwarded message ----------
From: SAMEER KUMAR <sa...@gmail.com>
Date: Wed, Mar 25, 2009 at 7:04 PM
Subject: Re: [Problem] Not able to Link APR to my programs
To: Wes Garland <we...@page.ca>


Dear Wes,

Thanks for your prompt reply.


> That said, if you are planning on building something that resembles a web
> server, may I suggest writing an Apache module (plug-in) rather than using
> APR to build a web server?  You'll get where you want to go a lot faster.
>

We are trying to modify an existing SIP server, OpenSIPS. SIP is session
Initiation Protocol [RFC3261]. SIP has request methods and response codes
very much like http. It is a protocol for multimedia session handling. I
will consider your advice for writing an Apache plugin.

Nick Kew wrote an excellent book on Apache 2 modules; the old "Writing
> Apache Modules in Perl and C" is still somewhat relevant as well.
>

Do you have a e-book of this? Or any idea from where can I get it? It would
be kind of you if you can help.

You are missing the include path, specified with -I; you can get the correct
> syntax for your build by using apr-1-config.
>

I had found that apr_*something*.mk file in my /usr/local/apr/build-1. I had
already tried adding that as -I but still that seemed to be of no use. I
could not locate apr-1-config file. Can you give me a hint where it might be
located with respect to the installatin directory of APR.

Thanks once again for replying.

With regards,


Sameer Kumar
B.Tech, Computer Engineering
Institute of Technology,
Nirma University,
Ahmedabad, Gujarat



On Wed, Mar 25, 2009 at 5:13 AM, SAMEER KUMAR <sa...@gmail.com>wrote:
>
>> I am new to APR. I am going to use it for developing a Apache like hybrid
>> architecture for OpenSIPS [www.opensips.org], which an open source
>> SIP[RFC 3261] server.
>>
>> I have downloaded APR and installed it on my Fedora 9 machine using the
>> configure and make commands. I tested the installation with testall. But I
>> am not able to use this in my programs and not able to link to the header
>> files in APR.
>>
>> I am using a cat1.c program to run, in which I am using functions of APR
>> module. I have tried these gcc commands:
>>
>> gcc -l lapr-1  /cat1.c
>>
>> *gcc /cat1.c -L. -lapr-1*
>>
>> my working directory is
>>
>> */usr/local/apr/lib*
>>
>> I am getting following set of errors:
>>
>> /cat1.c:1:23: error: apr_pools.h: No such file or directory
>> /cat1.c:2:25: error: apr_file_io.h: No such file or directory
>> /cat1.c: In function ‘main’:
>> /cat1.c:8: error: ‘apr_pool_t’ undeclared (first use in this function)
>> /cat1.c:8: error: (Each undeclared identifier is reported only once
>> /cat1.c:8: error: for each function it appears in.)
>> /cat1.c:8: error: ‘pool’ undeclared (first use in this function)
>> /cat1.c:9: error: ‘apr_file_t’ undeclared (first use in this function)
>> /cat1.c:9: error: ‘thefile’ undeclared (first use in this function)
>> /cat1.c:9: error: ‘NULL’ undeclared (first use in this function)
>> /cat1.c:10: error: ‘out’ undeclared (first use in this function)
>> /cat1.c:14: error: ‘apr_terminate’ undeclared (first use in this function)
>> /cat1.c:19: error: ‘APR_READ’ undeclared (first use in this function)
>> /cat1.c:19: error: ‘APR_CREATE’ undeclared (first use in this function)
>> /cat1.c:20: error: ‘APR_UREAD’ undeclared (first use in this function)
>> /cat1.c:20: error: ‘APR_UWRITE’ undeclared (first use in this function)
>> /cat1.c:20: error: ‘APR_GREAD’ undeclared (first use in this function)
>> /cat1.c:21: error: ‘APR_SUCCESS’ undeclared (first use in this function)
>> /cat1.c:25: error: ‘APR_EOF’ undeclared (first use in this function)
>> /cat1.c:26: error: ‘apr_size_t’ undeclared (first use in this function)
>> /cat1.c:26: error: expected ‘;’ before ‘bytes’
>> /cat1.c:29: error: ‘bytes’ undeclared (first use in this function)
>> /cat1.c:29: warning: incompatible implicit declaration of built-in
>> function ‘strlen’
>>
>>
>> Can some one help me where I am lacking. Can some one track my mistake. I
>> will be very grateful if someone can do that. :)
>>
>> Thank You in advance.
>>
>> Sameer Kumar
>> B.Tech, Computer Engineering
>> Institute of Technology,
>> Nirma University,
>> Ahmedabad, Gujarat
>>
>>
>
>
> --
> Wesley W. Garland
> Director, Product Development
> PageMail, Inc.
> +1 613 542 2787 x 102
>

Re: [Problem] Not able to Link APR to my programs

Posted by Wes Garland <we...@page.ca>.
Sameer:

You are missing the include path, specified with -I; you can get the correct
syntax for your build by using apr-1-config.

That said, if you are planning on building something that resembles a web
server, may I suggest writing an Apache module (plug-in) rather than using
APR to build a web server?  You'll get where you want to go a lot faster.
Nick Kew wrote an excellent book on Apache 2 modules; the old "Writing
Apache Modules in Perl and C" is still somewhat relevant as well.

Wes

On Wed, Mar 25, 2009 at 5:13 AM, SAMEER KUMAR <sa...@gmail.com>wrote:

> I am new to APR. I am going to use it for developing a Apache like hybrid
> architecture for OpenSIPS [www.opensips.org], which an open source SIP[RFC
> 3261] server.
>
> I have downloaded APR and installed it on my Fedora 9 machine using the
> configure and make commands. I tested the installation with testall. But I
> am not able to use this in my programs and not able to link to the header
> files in APR.
>
> I am using a cat1.c program to run, in which I am using functions of APR
> module. I have tried these gcc commands:
>
> gcc -l lapr-1  /cat1.c
>
> *gcc /cat1.c -L. -lapr-1*
>
> my working directory is
>
> */usr/local/apr/lib*
>
> I am getting following set of errors:
>
> /cat1.c:1:23: error: apr_pools.h: No such file or directory
> /cat1.c:2:25: error: apr_file_io.h: No such file or directory
> /cat1.c: In function ‘main’:
> /cat1.c:8: error: ‘apr_pool_t’ undeclared (first use in this function)
> /cat1.c:8: error: (Each undeclared identifier is reported only once
> /cat1.c:8: error: for each function it appears in.)
> /cat1.c:8: error: ‘pool’ undeclared (first use in this function)
> /cat1.c:9: error: ‘apr_file_t’ undeclared (first use in this function)
> /cat1.c:9: error: ‘thefile’ undeclared (first use in this function)
> /cat1.c:9: error: ‘NULL’ undeclared (first use in this function)
> /cat1.c:10: error: ‘out’ undeclared (first use in this function)
> /cat1.c:14: error: ‘apr_terminate’ undeclared (first use in this function)
> /cat1.c:19: error: ‘APR_READ’ undeclared (first use in this function)
> /cat1.c:19: error: ‘APR_CREATE’ undeclared (first use in this function)
> /cat1.c:20: error: ‘APR_UREAD’ undeclared (first use in this function)
> /cat1.c:20: error: ‘APR_UWRITE’ undeclared (first use in this function)
> /cat1.c:20: error: ‘APR_GREAD’ undeclared (first use in this function)
> /cat1.c:21: error: ‘APR_SUCCESS’ undeclared (first use in this function)
> /cat1.c:25: error: ‘APR_EOF’ undeclared (first use in this function)
> /cat1.c:26: error: ‘apr_size_t’ undeclared (first use in this function)
> /cat1.c:26: error: expected ‘;’ before ‘bytes’
> /cat1.c:29: error: ‘bytes’ undeclared (first use in this function)
> /cat1.c:29: warning: incompatible implicit declaration of built-in function
> ‘strlen’
>
>
> Can some one help me where I am lacking. Can some one track my mistake. I
> will be very grateful if someone can do that. :)
>
> Thank You in advance.
>
> Sameer Kumar
> B.Tech, Computer Engineering
> Institute of Technology,
> Nirma University,
> Ahmedabad, Gujarat
>
>


-- 
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102