arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation
http://libtorrent.org
Other
5.23k stars 992 forks source link

mingw32 build fails #2396

Closed silverqx closed 7 years ago

silverqx commented 7 years ago

trying to build libtorrent 1.1.4 with msys2 mingw32 on win10 x64, b2 command is invoked from msys2 mingw32 shell:

./b2 -q --without-python --toolset=gcc architecture=x86 address-model=32 variant=debug link=shared runtime-link=shared debug-symbols=on encryption=on crypto=openssl logging=off resolve-countries=off dht=on character-set=unicode boost-link=shared -sBOOST_ROOT="/e/c/qbittorrent_32_mingw_shared/boost_1_64_0" include="/e/c/qbittorrent_32_mingw_shared/install_msvc/base/include" library-path="/e/c/qbittorrent_32_mingw_shared/install_msvc/base/lib" --prefix="/e/c/qbittorrent_32_mingw_shared/install_msvc/base" define=BOOST_ASIO_DISABLE_CONNECTEX --reconfigure -a

Here is console output libtorrent_mingw.txt

It looks like that linker can not link against functions from Dbghelp library? e.g. SymGetModuleBase64 I checked this lib and I have it on linker path C:\msys64\mingw32\i686-w64-mingw32\lib\libdbghelp.a or problem is that is trying link to 64bit version? Absolutely don't know, may be somebody smarter :)

I'm going to try classic autotools build and some other options which I found i commits here for appveyor. https://github.com/arvidn/libtorrent/search?q=mingw&type=Commits&utf8=%E2%9C%93

Thank you for any suggestions

silverqx commented 7 years ago

Result with autotools

used this configure command:

./configure --enable-debug --enable-shared --without-python --with-boost=/e/c/qbittorrent_32_mingw_shared/boost_1_64_0 --libdir=/e/c/qbittorrent_32_mingw_shared/install_msvc/base/lib --includedir=/e/c/qbittorrent_32_mingw_shared/install_msvc/base/include --with-boost-libdir=/e/c/qbittorrent_32_mingw_shared/install_msvc/base/lib --prefix=/e/c/qbittorrent_32_mingw_shared/install_msvc/base --with-boost-system=boost_system-mgw72-mt-d-1_64 --with-boost-chrono=boost_chrono-mgw72-mt-d-1_64 --with-boost-random=boost_random-mgw72-mt-d-1_64

I get this error during make:

make[1]: Entering directory '/e/c/qbittorrent_32_mingw_shared/libtorrent/src'
  CXX      thread.lo
thread.cpp: In constructor 'libtorrent::condition_variable::condition_variable()':
thread.cpp:111:11: error: 'CreateSemaphoreEx' was not declared in this scope
   m_sem = CreateSemaphoreEx(0, 0, INT_MAX, 0, 0, SEMAPHORE_ALL_ACCESS);
           ^~~~~~~~~~~~~~~~~
thread.cpp:111:11: note: suggested alternative: 'CreateSemaphoreA'
   m_sem = CreateSemaphoreEx(0, 0, INT_MAX, 0, 0, SEMAPHORE_ALL_ACCESS);
           ^~~~~~~~~~~~~~~~~
           CreateSemaphoreA
make[1]: *** [Makefile:941: thread.lo] Error 1
make[1]: Leaving directory '/e/c/qbittorrent_32_mingw_shared/libtorrent/src'
make: *** [Makefile:619: all-recursive] Error 1

So I used CreateSemaphore, after that compilation succeed, but I end up with this during linking:

libtool: compile:  g++ -DPACKAGE_NAME=\"libtorrent-rasterbar\" -DPACKAGE_TARNAME=\"libtorrent-rasterbar\" -DPACKAGE_VERSION=\"1.1.4\" "-DPACKAGE_STRING=\"libtorrent-rasterbar 1.1.4\"" -DPACKAGE_BUGREPORT=\"arvid@libtorrent.org\" -DPACKAGE_URL=\"http://www.libtorrent.org\" -DPACKAGE=\"libtorrent-rasterbar\" -DVERSION=\"1.1.4\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_PTHREAD=1 "-DHAVE_BOOST=/**/" "-DHAVE_BOOST_SYSTEM=/**/" "-DHAVE_BOOST_CHRONO=/**/" "-DHAVE_BOOST_RANDOM=/**/" -D_FILE_OFFSET_BITS=64 -DHAVE_CLOCK_GETTIME=1 -DTORRENT_DEBUG=1 -DTORRENT_DISABLE_LOGGING=1 -DTORRENT_USE_OPENSSL=1 -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE=1 -DBOOST_ASIO_ENABLE_CANCELIO=1 -DTORRENT_BUILDING_SHARED=1 -I. -DTORRENT_BUILDING_LIBRARY -I../include -I../ed25519/src -g -IE:/c/qbittorrent_32_mingw_shared/install_msvc/base/include -I/e/c/qbittorrent_32_mingw_shared/boost_1_64_0 -L/e/c/qbittorrent_32_mingw_shared/install_msvc/base/include -ftemplate-depth=120 -fvisibility=hidden -fvisibility-inlines-hidden -MT thread.lo -MD -MP -MF .deps/thread.Tpo -c thread.cpp -o thread.o >/dev/null 2>&1
/bin/sh ../libtool  --tag=CXX   --mode=link g++  -L/e/c/qbittorrent_32_mingw_shared/install_msvc/base/include -ftemplate-depth=120 -fvisibility=hidden -fvisibility-inlines-hidden -version-info 9:0:0 -L/e/c/qbittorrent_32_mingw_shared/install_msvc/base/lib -fvisibility=hidden -fvisibility-inlines-hidden -o libtorrent-rasterbar.la -rpath /e/c/qbittorrent_32_mingw_shared/install_msvc/base/lib web_connection_base.lo alert.lo alert_manager.lo allocator.lo announce_entry.lo assert.lo bandwidth_limit.lo bandwidth_manager.lo bandwidth_queue_entry.lo bdecode.lo bitfield.lo bloom_filter.lo broadcast_socket.lo block_cache.lo bt_peer_connection.lo chained_buffer.lo choker.lo close_reason.lo ConvertUTF.lo cpuid.lo crc32c.lo create_torrent.lo disk_buffer_holder.lo disk_buffer_pool.lo disk_io_job.lo disk_io_thread.lo disk_job_pool.lo entry.lo enum_net.lo error_code.lo escape_string.lo file.lo file_pool.lo file_storage.lo fingerprint.lo gzip.lo hasher.lo hex.lo http_connection.lo http_parser.lo http_seed_connection.lo http_stream.lo http_tracker_connection.lo i2p_stream.lo identify_client.lo instantiate_connection.lo ip_filter.lo ip_voter.lo lazy_bdecode.lo lsd.lo lt_trackers.lo magnet_uri.lo merkle.lo metadata_transfer.lo mpi.lo natpmp.lo parse_url.lo part_file.lo pe_crypto.lo performance_counters.lo peer_connection.lo peer_connection_handle.lo peer_class.lo peer_class_set.lo piece_picker.lo platform_util.lo packet_buffer.lo proxy_base.lo peer_list.lo puff.lo random.lo receive_buffer.lo request_blocks.lo resolve_links.lo resolver.lo rss.lo session.lo session_call.lo session_handle.lo session_impl.lo session_settings.lo proxy_settings.lo settings_pack.lo smart_ban.lo socket_io.lo socket_type.lo socks5_stream.lo stat.lo stat_cache.lo storage.lo session_stats.lo string_util.lo thread.lo torrent.lo torrent_handle.lo torrent_info.lo torrent_peer.lo torrent_peer_allocator.lo torrent_status.lo time.lo timestamp_history.lo tracker_manager.lo udp_socket.lo udp_tracker_connection.lo upnp.lo ut_metadata.lo ut_pex.lo utf8.lo utp_socket_manager.lo utp_stream.lo web_peer_connection.lo xml_parse.lo version.lo file_progress.lo kademlia/dht_storage.lo kademlia/dht_tracker.lo kademlia/find_data.lo kademlia/put_data.lo kademlia/msg.lo kademlia/node.lo kademlia/node_entry.lo kademlia/node_id.lo kademlia/refresh.lo kademlia/routing_table.lo kademlia/rpc_manager.lo kademlia/traversal_algorithm.lo kademlia/dos_blocker.lo kademlia/get_peers.lo kademlia/get_item.lo kademlia/item.lo ../ed25519/src/add_scalar.lo ../ed25519/src/fe.lo ../ed25519/src/ge.lo ../ed25519/src/key_exchange.lo ../ed25519/src/keypair.lo ../ed25519/src/sc.lo ../ed25519/src/seed.lo ../ed25519/src/sha512.lo ../ed25519/src/sign.lo ../ed25519/src/verify.lo  -lboost_system-mgw72-mt-d-1_64 -lssl -lcrypto -lboost_chrono-mgw72-mt-d-1_64 -lboost_random-mgw72-mt-d-1_64
libtool: warning: undefined symbols not allowed in i686-w64-mingw32 shared libraries; building static only
libtool: link: rm -fr  .libs/libtorrent-rasterbar.a .libs/libtorrent-rasterbar.la .libs/libtorrent-rasterbar.lai
...

Any info which undefined symbols, so static lib was generated. Any idea how can I find out which symbols are undefined?

Is it possible to compile with mingw? I'm going to try compile outside of msys2 mingw32 shell, in cmd.exe shell, may be here is the problem.

silverqx commented 7 years ago

this fix it:

export LDFLAGS="-ldbghelp"

but, dbghelp library is missing in jamfile for mingw, i have found this, i think that is the reason:

    # dbghelp doesn't appear to exist in mingw
    if <target-os>windows in $(properties)
        && ! <toolset>gcc in $(properties)
        && ( <variant>debug in $(properties)
            || <asserts>on in $(properties)
            || <asserts>production in $(properties)
            || <pool-allocators>debug in $(properties)
            || <allocator>debug in $(properties)
            || <asio-debugging>on in $(properties) )
    {
        result += <library>dbghelp ;
    } 

This is no longer true, dbghelp exists in mingw.

arvidn commented 7 years ago

I worry that the trivial fix may break appveyor builds.

arvidn commented 7 years ago

testing here: https://github.com/arvidn/libtorrent/pull/2400

silverqx commented 7 years ago

we'll see soon

silverqx commented 7 years ago

How is possible, that build with mingw has 127,8MB and msvc2015 build with the same build parameters has 9,7MB?

Build was successful and everything works well 🔥

arvidn commented 7 years ago

I would imagine the size of the debug info makes the difference. It's possible the msvc linker is better at merging and stripping dead code.