English 中文(简体)
在将一个定制的Apache 2.4模块静态地与httpd/apr 图书馆连接到Libert
原标题:Errors when linking a custom Apache 2.4 modules statically with httpd/apr libraries on Linux

我正试图将我的模块移至北拉诺·帕帕帕奇,我正在把问题联系起来。 窗户上的校正 校准可与执业图书馆和执业/实用图书馆连接。 lib* httpd pr和prutil在我的窗户安装上都有固定的联系。 我也想对六氯环己烷的安装采取同样的做法。

根据现有文件有限,我无法使用APXS,因为我的模块是用C++书写的。

我难以找到服务器的档案文件。 我需要与我的模块联系起来吗?

来文方能够把视窗户连接起来并安装。

样本错误:

    /home/ec2-user/httpd-2.4.2/srclib/apr/locks/unix/proc_mutex.c:367: undefined reference to `pthread_mutexattr_init 
    /home/ec2-user/httpd-2.4.2/srclib/apr/locks/unix/proc_mutex.c:374: undefined reference to `pthread_mutexattr_setpshared 
    /home/ec2-user/httpd-2.4.2/srclib/apr/locks/unix/proc_mutex.c:384: undefined reference to `pthread_mutexattr_setrobust_np 
    /home/ec2-user/httpd-2.4.2/srclib/apr/locks/unix/proc_mutex.c:393: undefined reference to `pthread_mutexattr_setprotocol 
    /home/ec2-user/httpd-2.4.2/srclib/apr/locks/unix/proc_mutex.c:414: undefined reference to `pthread_mutexattr_destroy 
    /home/ec2-user/httpd-2.4.2/srclib/apr/locks/unix/proc_mutex.c:408: undefined reference to `pthread_mutexattr_destroy 

成就

最佳回答

这些错误是指你在汇编指挥线上添加<条码>-pthread,因此你不再照搬<条码>pthread的图书馆。

(说明:其编号为-pthread, not-lpthread - 它不单单是联系人选择。)

问题回答

对于C++的建筑帕帕奇模块,并想要动态连接,这里使用的是G++指挥线一,用于成功建造一个单元;在App2.2.22/CentOS 6.2上进行了简要测试。

g++ [my files].cpp  -I/httpd/include/ -I/httpd/srclib/apr/include/ 
    -I/httpd/srclib/apr-util/include/ -I/usr/include/ -I/usr/include/apr-1/ 
    -I/httpd/os/unix/ -shared -fPIC -o mod_mymodule.so

I m an Apache/linux programming noob and was unable to find this info anywhere else; thanks to the OP s solution I was able to finish the job after a few days of frustration.

Here s also a link which helped explain how to work around the unresolved reference linker issue when it couldn t find the apache functions contained within the httpd server core code (libhttpd.lib on Windows) -- which doesn t exist in *nix, unless you make it manually like the OP did. Basically, the answer was to use the -shared flag so these references are automagically resolved at run time. http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

Don t 忘记了你模块代码中的C,并在建设住房和财产部支助中加以发展。

Hope this helps someone else!

So anyone else searching for this may get the answer.

  1. Download whatever Apache version (higher than 2.2) source from the apache httpd site to the home directory
  2. Unpack
  3. Configure with everything or simply just specify no options (You can reconfigure later for the actual build)
  4. perform a make on the source ( don t do a make install yet! just need the object files)
  5. create a directory that will hold your libraries and source for your own module. Say "foo" at the top level of your home dir (or any you desire)
  6. assuming home dir: execute (find ~/httpdX.X -name *.o -exec cp {} ~/foo ;) The command is in parenthesis. This will copy all compiled objects to foo.
  7. execute (find ~/foo -name *.o -exec ar r libhttpd.a {} ;) which will create an archive of the code for you.
  8. Then just include these switches in your compile definition for gcc or g++ (-Wl,-Bstatic -lhttpd -lpcre -lpcreposix -lapr-1 -laprutil-1 -Wl,-Bdynamic -pthread -ldl -lcrypt)
  9. Clean up your foo directory if you like by running rm on the *.o files

You do not need to compile statically like I needed to, but I wanted to be able to move my module to any Linux host without worry about the necessary components. Apache needs pcre(regex), apr(all libraries), threads (proc/thread mutex), dl(dynamic loading), and crypt(apr password) to work. Since thread, dl, and crypt will most like already be on the machine, I chose to not compile them statically.

Happy hunting. I hope my never ending story over 3 days helps someone else!





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签