I'm creating a an apache module which is basically a shared library (not in C, but in rust, so I can't use the usual apache tooling that hides all this stuff).
When I go to link, ld
is telling me there's a bunch of undefined symbols. These symbols are all defined in the executable that will be loading this shared library, namely /usr/sbin/httpd
. I verified this with nm
. I can't find them in any other static or shared libs.
How do I tell the linker the symbols are in httpd
?
here is an abbreviated linker command it is firing off:
"cc" "-m64" "-L" "/Users/me/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/me/dev/apacheagent-myco/target/debug/deps/apacheagentmyco.apacheagentmyco0.rcgu.o" ...<tons of .o files> "-Wl,-exported_symbols_list,/var/folders/6h/qx6jssj16q95_h_kqjd6qt_00000gn/T/rustc.xMMi8AxcVg62/list" "-Wl,-dead_strip" "-nodefaultlibs" "-L" <tons of rlibs> "-l" "onig" "-framework" "Security" "-framework" "CoreFoundation" "-l" "System" "-l" "resolv" "-l" "pthread" "-l" "c" "-l" "m" "-dynamiclib" "-Wl,-dylib" "-lapr-1" "-laprutil-1"
here are the errors:
note: Undefined symbols for architecture x86_64:
"_ap_is_initial_req", referenced from:
apache2::httpd::_$LT$impl$u20$apache2..wrapper..Wrapper$LT$apache2..ffi..request_rec$GT$$GT$::is_initial_req::h078b0dbdc2d2d488 in libapache2-850bd4b18832aac1.rlib(apache2-850bd4b18832aac1.apache20.rcgu.o)
"_ap_hook_handler", referenced from:
apacheagentmyco::apache_agent_myco_hooks::h3461197a43567639 in apacheagentmyco.apacheagentmyco7.rcgu.o
"_ap_server_root", referenced from:
apacheagentmyco::myco_child_init::h52c8c1513f7742ef in apacheagentmyco.apacheagentmyco7.rcgu.o
"_ap_get_brigade", referenced from:
apacheagentmyco::myco_apache2::apache2_body::read_body::h41bdc64c0c81a6d6 in apacheagentmyco.apacheagentmyco15.rcgu.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
These symbols are all in /usr/sbin/httpd.
-Wl,-U,_symbol
. That solved it. – marathon