logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in  RSS Apache Lounge  


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.


Post new topic   Forum Index -> Building & Member Downloads View previous topic :: View next topic
Reply to topic   Topic: Failed linking C shared library mod_md.so
Author
tanquang



Joined: 21 Mar 2020
Posts: 43
Location: Vietnam

PostPosted: Mon 09 May '22 13:32    Post subject: Failed linking C shared library mod_md.so Reply with quote

This bug comes from at least version 2.4.48, but to the current version is still not fixed.
Before compiling Apache httpd-2, I have successfully compiled (also compile order) before using VS 2013 with Update 5 (Ultimate) + CMAKE v3.23.1 (x86_64): zlib v1.2.12, PCRE v8.45, Expat v2.4.8, OpenSSL v1.1.1o, libxml2 v2.9.14, jansson v2.14, Brotli v1.0.9, Lua v5.4.4, APR v1.7.0, APR-Util v1.6.1, Nghttp2 v1.47.0, cURL v7.83.0. All are the latest version!
With cURL, I compiled both dynamic libraries (before) and static libraries (after).
But when comes to Apache httpd-2 compile:
Code:
--
-- Summary of feature detection:
--
-- LIBXML2_FOUND ............ : TRUE
-- LUA51_FOUND .............. : TRUE
-- NGHTTP2_FOUND ............ : TRUE
-- OPENSSL_FOUND ............ : TRUE
-- ZLIB_FOUND ............... : TRUE
-- BROTLI_FOUND ............. : TRUE
-- CURL_FOUND ............... : TRUE
-- JANSSON_FOUND ............ : TRUE
-- APR_HAS_LDAP ............. : TRUE
-- APR_HAS_XLATE ............ : FALSE
-- APU_HAVE_CRYPTO .......... : TRUE
--
...
--
--
-- Apache httpd configuration summary:
--
--   Build type ...................... : Release
--   Install .pdb (if available)...... : OFF
--   Install manual .................. : ON
--   Install prefix .................. : /phpStudy/Apache
--   C compiler ...................... : C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
--   APR include directory ........... : /phpStudy/Apache/include
--   APR libraries ................... : /phpStudy/Apache/lib/libapr-1.lib;/phpStudy/Apache/lib/libaprutil-1.lib;/phpStudy/Apache/lib/apr_ldap1.lib
--   OpenSSL include directory ....... : /phpStudy/Apache/include
--   OpenSSL libraries ............... : /phpStudy/Apache/lib/libssl.lib;/phpStudy/Apache/lib/libcrypto.lib
--   PCRE include directory .......... : /phpStudy/Apache/include
--   PCRE libraries .................. : /phpStudy/Apache/lib/pcre.lib
--   libxml2 iconv prereq include dir. :
--   libxml2 iconv prereq libraries .. :
--   Brotli include directory......... : /phpStudy/Apache/include
--   Brotli libraries ................ : /phpStudy/Apache/lib/brotlienc.lib;/phpStudy/Apache/lib/brotlicommon.lib
--   Curl include directory........... :
--   Jansson libraries ............... : /phpStudy/Apache/lib/jansson.lib
--   Extra include directories ....... :
--   Extra compile flags ............. :
--   Extra libraries ................. :

Then I use nmake:

...
[ 40%] Building C object CMakeFiles/mod_md.dir/modules/md/mod_md_ocsp.c.obj
mod_md_ocsp.c
[ 40%] Building RC object CMakeFiles/mod_md.dir/build/win32/httpd.rc.res
Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17336
Copyright (C) Microsoft Corporation.  All rights reserved.

[ 40%] Linking C shared library mod_md.so
LINK: command "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe /nologo @CMakeFiles\mod_md.dir\objects1.rsp /out:mod_md.so /implib:mod_md.lib /pdb:C:\httpd\bin\mod_md.pdb /dll /version:0.0 /base:@C:/httpd/bin/BaseAddr.ref,mod_md.so /machine:X86 /INCREMENTAL:NO \phpStudy\Apache\lib\libssl.lib \phpStudy\Apache\lib\libcrypto.lib \phpStudy\Apache\lib\jansson.lib mod_watchdog.lib libhttpd.lib \phpStudy\Apache\lib\libapr-1.lib \phpStudy\Apache\lib\libaprutil-1.lib \phpStudy\Apache\lib\apr_ldap-1.lib ws2_32.lib mswsock.lib \phpStudy\Apache\lib\pcre.lib ws2_32.lib mswsock.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:mod_md.so.manifest" failed (exit code 1120) with the following output:
   Creating library mod_md.lib and object mod_md.exp
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_global_init referenced in function _md_curl_init
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_slist_append referenced in function _curlify_headers
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_slist_free_all referenced in function _md_curl_req_cleanup
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_strerror referenced in function _md_curl_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_initreferenced in function _internals_setup
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function _internals_setup
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function _md_curl_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function _md_curl_req_cleanup
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_easy_getinfo referenced in function _md_curl_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_init referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_add_handle referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_remove_handle referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_wait referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_perform referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_cleanup referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_info_read referenced in function _md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol __imp__curl_multi_strerror referenced in function _md_curl_multi_perform
mod_md.so : fatal error LNK1120: 17 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

P/s: The error code above I copied from my previous error report on ASF Bugzilla – Bug 65602. The latest version is still the same.
During the HTTPD compilation, the compiler (apparently) didn't find cURL.
Previously, I have asked questions on StackOverflow about this error. No one has a solid solution, but they have come up with a "pretty good" solution: Compile again cURL during HTTPD compilation (i.e. cURL will be compiled a total of 3 times).
All relevant information will probably be on the report on ASF Bugzilla, I will add more information if missing. So I posted this topic in the hope that everyone could help me solve this error!
Quote:
I don't understand the syntax of CMakeLists.txt (latest - v2.4.53), it seems to variable CURL_INCLUDE_DIR that exists but not SET.
Because JANSSON_INCLUDE_DIR variable, it appears 3 times, the first SET in the 97 line before being put into the SET in line 499.
Although I'm not sure, but CURL_INCLUDE_DIR has been created but has not been "assigned" so it couldn't find curl library...
Back to top
nono303



Joined: 20 Dec 2016
Posts: 159
Location: Lille, FR, EU

PostPosted: Mon 09 May '22 15:27    Post subject: Reply with quote

Hi @tanquang,
What is your httpd cmake cmd line ?$

On my side:
Code:
cmake  -G "Ninja" ^
-DCMAKE_INSTALL_PREFIX=C:\sdk\release\vs17_x64-avx ^
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DINSTALL_PDB=ON ^
-DINSTALL_MANUAL=OFF ^
-DENABLE_MODULES=A ^
-DLUA_LIBRARIES=C:/sdk/release/vs17_x64-avx/lib/liblua.lib ^
-DLUA_INCLUDE_DIR=C:/sdk/release/vs17_x64-avx/include ^
-DLIBXML2_ICONV_INCLUDE_DIR=C:/sdk/release/vs17_x64-avx/include ^
-DLIBXML2_ICONV_LIBRARIES=C:/sdk/release/vs17_x64-avx/lib/libiconv.lib ^
-DZLIB_LIBRARIES=C:/sdk/release/vs17_x64-avx/lib/zlib.lib ^
-DJANSSON_INCLUDE_DIR=C:/sdk/release/vs17_x64-avx/include ^
-DJANSSON_LIBRARIES=C:/sdk/release/vs17_x64-avx/lib/jansson.lib ^
-DMAXMIND_LIBRARIES=C:\sdk\release\vs17_x64-avx/lib/maxminddb.lib ^
-DOPENSSL_ROOT_DIR=C:/sdk/release/vs17_x64-avx ^
-DCURL_LIBRARY=C:/sdk/release/vs17_x64-avx/lib/libcurl.lib ^
-DCURL_INCLUDE_DIR=C:/sdk/release/vs17_x64-avx/include ^
-DEXTRA_INCLUDES=C:/sdk/src/openssl ^
C:\sdk\src\httpd

result:
Code:
--
--
-- Apache httpd configuration summary:
--
--   Build type ...................... : RelWithDebInfo
--   Install .pdb (if available)...... : ON
--   Install manual .................. : OFF
--   Install prefix .................. : C:/sdk/release/vs17_x64-avx
--   C compiler ...................... : C:/sdk/softs/vs22/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe
--   APR include directory ........... : C:/sdk/release/vs17_x64-avx/include
--   APR libraries ................... : C:/sdk/release/vs17_x64-avx/lib/libapr-1.lib;C:/sdk/release/vs17_x64-avx/lib/libaprutil-1.lib;C:/sdk/release/vs17_x64-avx/lib/apr_ldap-1.lib
--   OpenSSL include directory ....... : C:/sdk/release/vs17_x64-avx/include
--   OpenSSL libraries ............... : C:/sdk/release/vs17_x64-avx/lib/libssl.lib;C:/sdk/release/vs17_x64-avx/lib/libcrypto.lib
--   PCRE include directory .......... : C:/sdk/release/vs17_x64-avx/include
--   PCRE libraries .................. : C:/sdk/release/vs17_x64-avx/lib/pcre2-8.lib
--   libxml2 iconv prereq include dir. : C:/sdk/release/vs17_x64-avx/include
--   libxml2 iconv prereq libraries .. : C:/sdk/release/vs17_x64-avx/lib/libiconv.lib
--   Brotli include directory......... : C:/sdk/release/vs17_x64-avx/include
--   Brotli libraries ................ : C:/sdk/release/vs17_x64-avx/lib/brotlienc.lib;C:/sdk/release/vs17_x64-avx/lib/brotlicommon.lib
--   Curl include directory........... : C:/sdk/release/vs17_x64-avx/include
--   Jansson libraries ............... : C:/sdk/release/vs17_x64-avx/lib/jansson.lib
--   Extra include directories ....... : C:/sdk/src/openssl
--   Extra compile flags ............. :
--   Extra libraries ................. :

with Curl include directory set and compile working
Code:
...
-- Installing: C:/sdk/release/vs16_x86/modules/mod_md.so
...
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 43
Location: Vietnam

PostPosted: Mon 09 May '22 22:28    Post subject: Reply with quote

nono303 wrote:
Hi @tanquang,
What is your httpd cmake cmd line ?$
...

The CMAKE command line when compiling HTTPD is:
Code:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DENABLE_MODULES=i -DINSTALL_PDB=OFF ..

Looking at your command line, it seems that you had to manually assign the entire path to the relevant folders and libraries?
Exactly is CMake was unable to automatically find the directory and the library of cURL? This is a bug of CMake, or of the CMakeLists.txt file of HTTPD?
I used
Code:
-DENABLE_MODULES=i
because I skipped compiling APR-ICONV because I didn't know how to compile it using the CMake command line. So some modules like mod_charset_lite.so were not created.
P/s: Here are all my compiled command lines, can you take a look at it?!
Back to top
nono303



Joined: 20 Dec 2016
Posts: 159
Location: Lille, FR, EU

PostPosted: Tue 10 May '22 8:30    Post subject: Reply with quote

Looking on FindCURL.cmake:
Code:
# Look for the header file.
find_path(CURL_INCLUDE_DIR

find_package_handle_standard_args(CURL
                                  REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR

So, you MUST set CURL_LIBRARY & CURL_INCLUDE_DIR to have cmake be able to link it to httpd
Path might be relative or absolute
You ca have a look on my build files here: https://github.com/nono303/win-build-scripts/tree/master/modules
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 43
Location: Vietnam

PostPosted: Tue 10 May '22 14:57    Post subject: Reply with quote

Hello, I "guessed" the right problem.
First, I don't know the syntax used in CMake, so I will use the syntax in Java to explain.
The cause of the error is due to the CURL_INCLUDE_DIR and CURL_LIBRARIES variables which are declared but not have been initialized. That is why CMake has not been able to find the directory and library file of cURL.
I tried to change a bit, namely the value SET for CURL_INCLUDE_DIR and CURL_LIBRARIES variables inside the CMakeLists.txt file (please see the difference between the default version and the version I changed here). And praiseworthy, it found cURL and conducted normal compilation!
Anyway, I really hope they will update this change in the next version.
Back to top
nono303



Joined: 20 Dec 2016
Posts: 159
Location: Lille, FR, EU

PostPosted: Thu 12 May '22 18:44    Post subject: Reply with quote

Hi @tanquang,
I Clearly don’t understand what you mean with Java syntax or want to do patching CMakeLists.txt but… just simply change your cmd line from
Code:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DENABLE_MODULES=i -DINSTALL_PDB=OFF ...

to
Code:
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DENABLE_MODULES=i -DINSTALL_PDB=OFF -DCURL_LIBRARY=**YOUR_LIB_PATH**/libcurl.lib -DCURL_INCLUDE_DIR=**YOUR_INCLUDE_PATH**/ ...

It might (must) works Wink
Back to top
tanquang



Joined: 21 Mar 2020
Posts: 43
Location: Vietnam

PostPosted: Fri 13 May '22 18:52    Post subject: Reply with quote

Yes. In fact both of you and I can help compile successfully. But I like something "more automatically". In my way, CMake can automatically find cURL that you don't need to manually specify the path to cURL.
Back to top


Reply to topic   Topic: Failed linking C shared library mod_md.so View previous topic :: View next topic
Post new topic   Forum Index -> Building & Member Downloads