Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 2036 invoked from network); 13 Jan 2009 21:36:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jan 2009 21:36:28 -0000 Received: (qmail 14771 invoked by uid 500); 13 Jan 2009 21:36:27 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 14743 invoked by uid 500); 13 Jan 2009 21:36:27 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 14732 invoked by uid 99); 13 Jan 2009 21:36:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jan 2009 13:36:27 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of wolfgang127@gmail.com designates 209.85.198.251 as permitted sender) Received: from [209.85.198.251] (HELO rv-out-0708.google.com) (209.85.198.251) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jan 2009 21:36:22 +0000 Received: by rv-out-0708.google.com with SMTP id c5so201437rvf.24 for ; Tue, 13 Jan 2009 13:36:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=6pRyf/uXPBoFVGUZmC0opljBLsLTVWZ+WuKRWdY9kAM=; b=s03MZsWzeigqp7fkyPWIdM/HT4wpWRwzFDW5BqRRaVIym3hgaOYh68C7WuXfYFiPrh d0b0MaczJtaFR6H1OvHVTXXO8uZSyq6zss53h8h7X5sgdf5Xu3qAPGyLFwOn04Fx8dvb X/QScFC303OsMcgq4mHzi+678Fu6FizpflMfs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=BsDEfaR7ju4OaVCWlAIe+2AipP5dXQm4tS2cbaA9vpKTTsRAxN7BDKc1/Kry0Yqks5 5mA2BFl+XzWWwIyCq0Xo1pTJ31E7z3tFI0qmzgvEYoEBOAScC7elhPEZ1WRabILScniL PzSHJSW/W1sVDYwgpsGYFV5vTd5cmNA/WgX1M= Received: by 10.141.76.1 with SMTP id d1mr11042527rvl.110.1231882562506; Tue, 13 Jan 2009 13:36:02 -0800 (PST) Received: by 10.141.34.15 with HTTP; Tue, 13 Jan 2009 13:36:02 -0800 (PST) Message-ID: Date: Wed, 14 Jan 2009 06:36:02 +0900 From: wolfgang To: modules-dev@httpd.apache.org Subject: Re: multiple source files in a single apache module In-Reply-To: <20170a030901131330p38768860m7767b256afbe8b71@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20170a030901131304x287dbc05n7d12c3d3567d92d8@mail.gmail.com> <20170a030901131330p38768860m7767b256afbe8b71@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi Sorin, Yes, you are right!! I made it. Thanks a million !! wolfgang ps) I should've asked here 8 hrs ago... ;( On Wed, Jan 14, 2009 at 6:30 AM, Sorin Manolache wrote: > On Tue, Jan 13, 2009 at 22:20, wolfgang wrote: >> Hi, Sorin >> >> Thanks for quick reply. >> >> Here are mod_test.c and Makefile >> >> ********************** mod_test.c **************************************** >> #include "httpd.h" >> #include "http_config.h" >> #include "http_protocol.h" >> #include "ap_config.h" >> >> #include "my_test.h" >> >> /* The sample content handler */ >> static int test_handler(request_rec *r) >> { >> if (strcmp(r->handler, "test")) { >> return DECLINED; >> } >> r->content_type = "text/html"; >> >> printf("test_handler is called\n"); >> >> if (!r->header_only){ >> ap_rputs("The sample page from mod_test.c\n", r); >> printf("%d\n", add_test(10,20)); // <--- HERE !!! >> } >> >> return OK; >> } >> >> static void test_register_hooks(apr_pool_t *p) >> { >> ap_hook_handler(test_handler, NULL, NULL, APR_HOOK_MIDDLE); >> } >> >> /* Dispatch list for API hooks */ >> module AP_MODULE_DECLARE_DATA test_module = { >> STANDARD20_MODULE_STUFF, >> NULL, /* create per-dir config structures */ >> NULL, /* merge per-dir config structures */ >> NULL, /* create per-server config structures */ >> NULL, /* merge per-server config structures */ >> NULL, /* table of config file commands */ >> test_register_hooks /* register hooks */ >> }; >> ------------------------------------------------------------------------------------------- >> >> ********************** Makefile **************************************** >> ## >> ## Makefile -- Build procedure for sample test Apache module >> ## Autogenerated via ``apxs -n test -g''. >> ## >> >> builddir=. >> top_srcdir=/usr/local/apache >> top_builddir=/usr/local/apache >> include /usr/local/apache/build/special.mk >> >> # the used tools >> APXS=apxs >> APACHECTL=apachectl >> >> # additional defines, includes and libraries >> #DEFS=-Dmy_define=my_value >> #INCLUDES=-Imy/include/dir >> #LIBS=-Lmy/lib/dir -lmylib >> >> # the default target >> all: local-shared-build >> >> # install the shared object file into Apache >> install: install-modules-yes >> >> # cleanup >> clean: >> -rm -f mod_test.o mod_test.lo mod_test.slo mod_test.la >> >> # simple test >> test: reload >> lynx -mime_header http://localhost/test >> >> # install and activate shared object by reloading Apache to >> # force a reload of the shared object file >> reload: install restart >> >> # the general Apache start/restart/stop >> # procedures >> start: >> $(APACHECTL) start >> restart: >> $(APACHECTL) restart >> stop: >> $(APACHECTL) stop >> ---------------------------------------------------------------------------------- >> >> And I have one more file, modules.mk. it was created when I did >> "/usr/local/apache/bin/apxs -g -n test". >> I have no idea what it is. ( I didn't modify this file at all ) > > Assuming that your extra source file is called my_extra_source_file.c, > add my_extra_source_file.slo and my_extra_source_file.lo to modules.mk > as shown below. > >> *************************** modules.mk *********************** >> mod_test.la: mod_test.slo my_extra_source_file.slo >> $(SH_LINK) -rpath $(libexecdir) -module -avoid-version mod_test.lo my_extra_source_file.lo >> DISTCLEAN_TARGETS = modules.mk >> shared = mod_test.la >> ----------------------------------------------------------------------------------- >> >> I built the module as follows >> $ make >> and to install >> $ make install >> >> I know I should do something at the "all" target like making >> my_test.c's object file and link it to mod_test but don't know how to >> specify at all... >> >> Thanks in advance. >> >> wolfgang >> >> >> >> >> On Wed, Jan 14, 2009 at 6:04 AM, Sorin Manolache wrote: >>> On Tue, Jan 13, 2009 at 21:48, wolfgang wrote: >>>> Hi gurus, >>>> >>>> I made a sample apache module, mod_test, by >>>> "/usr/local/apache/bin/apxs -g -n test". >>>> Now I want to make the mod_test call the following source ( actually, >>>> an add_test function ). >>>> >>>> ----------- my_test.h ------------ >>>> #ifndef _MY_TEST_H >>>> #define _MY_TEST_H 1 >>>> >>>> int add_test(int a, int b); >>>> >>>> #endif >>>> ---------------------------------------- >>>> >>>> ------------ my_test.c ----------- >>>> #include "my_test.h" >>>> >>>> int add_test(int a, int b){ >>>> return (a+b); >>>> } >>>> ---------------------------------------- >>>> >>>> I've added #include "my_test.h" in mod_test.c and also add_test(10,20) >>>> in the test_handler function as follows. >>>> >>>> /* The sample content handler */ >>>> static int test_handler(request_rec *r) >>>> { >>>> if (strcmp(r->handler, "test")) { >>>> return DECLINED; >>>> } >>>> r->content_type = "text/html"; >>>> >>>> printf("test_handler is called\n"); >>>> >>>> if (!r->header_only){ >>>> ap_rputs("The sample page from mod_test.c\n", r); >>>> printf("%d\n", add_test(10,20)); // <--- HERE !!! >>>> } >>>> return OK; >>>> } >>>> >>>> and compiled and installed as follows >>>> ( I've added LoadModule, SetHandler in httpd.conf ) >>>> >>>> $ make >>>> $ make install >>>> >>>> run apache as debug mode >>>> $ /usr/local/apache/bin/httpd -X >>>> >>>> Then, I get the following error. >>>> >>>> httpd: Syntax error on line 100 of /usr/local/apache/conf/httpd.conf: >>>> Cannot load /usr/local/apache/modules/mod_test.so into server: >>>> /usr/local/apache/modules/mod_test.so: undefined symbol: add_test >>>> >>>> Of course, I get the error since I haven't modified Makefile at all. >>>> >>>> Now, my question is how Makefile should be modified ??? >>>> >>>> ------------------------------------- >>>> # the used tools >>>> APXS=apxs >>>> APACHECTL=apachectl >>>> >>>> # additional defines, includes and libraries >>>> #DEFS=-Dmy_define=my_value >>>> #INCLUDES=-Imy/include/dir >>>> #LIBS=-Lmy/lib/dir -lmylib >>>> >>>> # the default target >>>> all: local-shared-build >>>> >>>> # install the shared object file into Apache >>>> install: install-modules-yes >>>> >>>> # cleanup >>>> clean: >>>> -rm -f mod_test.o mod_test.lo mod_test.slo mod_test.la >>>> ------------------------------------- >>> >>> Please attach your whole Makefile. >>> >>> Please indicate the list of source files. As far as I understood, you >>> have mod_test.h and mod_test.c that contain the declaration and >>> definition of add_test. Which file contains test_handler and the >>> test_module structure? >>> >>> -- >>> S >>> >>>> >>>> I'm stuck over 8 hours... I couldn't find any sites describing this >>>> kinda situation. >>>> I'm really new to Makefile but no time to learn Makefile from a >>>> scratch right now.... :( >>>> Please please please help me out... >>>> >>>> thanks in advance. >>>> >>>> wolfgang >>>> >>> >>> >>> >>> -- >>> A: Because it reverses the logical flow of conversation. >>> Q: Why is top-posting frowned upon? >>> A: Top-posting. >>> Q: What is the most annoying thing in e-mail? >>> >> > > > > -- > A: Because it reverses the logical flow of conversation. > Q: Why is top-posting frowned upon? > A: Top-posting. > Q: What is the most annoying thing in e-mail? >