zhllxt / asio2

Header only c++ network library, based on asio,support tcp,udp,http,websocket,rpc,ssl,icmp,serial_port,socks5.
Boost Software License 1.0
775 stars 178 forks source link

Failed to build on FreeBSD #72

Open Curculigo opened 1 month ago

Curculigo commented 1 month ago
$ cmake -S . -B build
ASIO2_ROOT_DIR = /work/asio2
-- The C compiler identification is Clang 18.1.5
-- The CXX compiler identification is Clang 18.1.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMAKE_BUILD_TYPE is not set, Set default build to Release.
CMAKE_BUILD_TYPE = Release
ASIO2_LIBS_DIR = 
ASIO2_EXES_DIR = /work/asio2/bin/x64
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Configuring done (7.3s)
-- Generating done (0.2s)
-- Build files have been written to: /work/asio2/build
$ gmake -C build
gmake: Entering directory '/work/asio2/build'
[  1%] Building CXX object example/http/client/CMakeFiles/http_client.dir/http_client.cpp.o
In file included from /work/asio2/example/http/client/http_client.cpp:1:
In file included from /work/asio2/include/asio2/http/http_client.hpp:22:
In file included from /work/asio2/include/asio2/tcp/tcp_client.hpp:20:
In file included from /work/asio2/include/asio2/base/client.hpp:27:
In file included from /work/asio2/include/asio2/base/iopool.hpp:30:
In file included from /work/asio2/include/asio2/base/error.hpp:31:
In file included from /work/asio2/include/asio2/external/asio.hpp:36:
In file included from /work/asio2/3rd/asio.hpp:18:
In file included from /work/asio2/3rd/asio/any_completion_executor.hpp:22:
In file included from /work/asio2/3rd/asio/execution.hpp:22:
In file included from /work/asio2/3rd/asio/execution/blocking_adaptation.hpp:20:
In file included from /work/asio2/3rd/asio/detail/mutex.hpp:25:
/work/asio2/3rd/asio/detail/posix_mutex.hpp:52:3: warning: mutex 'mutex_' is still held at the end of function [-Wthread-safety-analysis]
   52 |   }
      |   ^
/work/asio2/3rd/asio/detail/posix_mutex.hpp:51:11: note: mutex acquired here
   51 |     (void)::pthread_mutex_lock(&mutex_); // Ignore EINVAL.
      |           ^
/work/asio2/3rd/asio/detail/posix_mutex.hpp:57:11: warning: releasing mutex 'mutex_' that was not held [-Wthread-safety-analysis]
   57 |     (void)::pthread_mutex_unlock(&mutex_); // Ignore EINVAL.
      |           ^
In file included from /work/asio2/example/http/client/http_client.cpp:1:
In file included from /work/asio2/include/asio2/http/http_client.hpp:22:
In file included from /work/asio2/include/asio2/tcp/tcp_client.hpp:20:
In file included from /work/asio2/include/asio2/base/client.hpp:27:
In file included from /work/asio2/include/asio2/base/iopool.hpp:30:
In file included from /work/asio2/include/asio2/base/error.hpp:31:
In file included from /work/asio2/include/asio2/external/asio.hpp:36:
In file included from /work/asio2/3rd/asio.hpp:39:
In file included from /work/asio2/3rd/asio/basic_signal_set.hpp:25:
In file included from /work/asio2/3rd/asio/detail/signal_set_service.hpp:289:
In file included from /work/asio2/3rd/asio/detail/impl/signal_set_service.ipp:24:
In file included from /work/asio2/3rd/asio/detail/static_mutex.hpp:25:
/work/asio2/3rd/asio/detail/posix_static_mutex.hpp:44:3: warning: mutex 'mutex_' is still held at the end of function [-Wthread-safety-analysis]
   44 |   }
      |   ^
/work/asio2/3rd/asio/detail/posix_static_mutex.hpp:43:11: note: mutex acquired here
   43 |     (void)::pthread_mutex_lock(&mutex_); // Ignore EINVAL.
      |           ^
/work/asio2/3rd/asio/detail/posix_static_mutex.hpp:49:11: warning: releasing mutex 'mutex_' that was not held [-Wthread-safety-analysis]
   49 |     (void)::pthread_mutex_unlock(&mutex_); // Ignore EINVAL.
      |           ^
In file included from /work/asio2/example/http/client/http_client.cpp:1:
In file included from /work/asio2/include/asio2/http/http_client.hpp:22:
In file included from /work/asio2/include/asio2/tcp/tcp_client.hpp:20:
In file included from /work/asio2/include/asio2/base/client.hpp:27:
In file included from /work/asio2/include/asio2/base/iopool.hpp:30:
In file included from /work/asio2/include/asio2/base/error.hpp:31:
In file included from /work/asio2/include/asio2/external/asio.hpp:36:
In file included from /work/asio2/3rd/asio.hpp:18:
In file included from /work/asio2/3rd/asio/any_completion_executor.hpp:22:
In file included from /work/asio2/3rd/asio/execution.hpp:22:
In file included from /work/asio2/3rd/asio/execution/blocking_adaptation.hpp:19:
In file included from /work/asio2/3rd/asio/detail/event.hpp:25:
/work/asio2/3rd/asio/detail/posix_event.hpp:118:7: warning: calling function 'pthread_cond_wait' requires holding mutex 'lock.mutex().mutex_' exclusively [-Wthread-safety-analysis]
  118 |       ::pthread_cond_wait(&cond_, &lock.mutex().mutex_); // Ignore EINVAL.
      |       ^
/work/asio2/3rd/asio/detail/conditionally_enabled_event.hpp:96:14: note: in instantiation of function template specialization 'asio::detail::posix_event::wait<asio::detail::conditionally_enabled_mutex::scoped_lock>' requested here
   96 |       event_.wait(lock);
      |              ^
In file included from /work/asio2/example/http/client/http_client.cpp:1:
In file included from /work/asio2/include/asio2/http/http_client.hpp:22:
In file included from /work/asio2/include/asio2/tcp/tcp_client.hpp:20:
In file included from /work/asio2/include/asio2/base/client.hpp:27:
In file included from /work/asio2/include/asio2/base/iopool.hpp:30:
In file included from /work/asio2/include/asio2/base/error.hpp:31:
In file included from /work/asio2/include/asio2/external/asio.hpp:36:
In file included from /work/asio2/3rd/asio.hpp:18:
In file included from /work/asio2/3rd/asio/any_completion_executor.hpp:22:
In file included from /work/asio2/3rd/asio/execution.hpp:22:
In file included from /work/asio2/3rd/asio/execution/blocking_adaptation.hpp:19:
In file included from /work/asio2/3rd/asio/detail/event.hpp:25:
/work/asio2/3rd/asio/detail/posix_event.hpp:148:9: warning: calling function 'pthread_cond_timedwait' requires holding mutex 'lock.mutex().mutex_' exclusively [-Wthread-safety-analysis]
  148 |         ::pthread_cond_timedwait(&cond_,
      |         ^
/work/asio2/3rd/asio/detail/conditionally_enabled_event.hpp:106:21: note: in instantiation of function template specialization 'asio::detail::posix_event::wait_for_usec<asio::detail::conditionally_enabled_mutex::scoped_lock>' requested here
  106 |       return event_.wait_for_usec(lock, usec);
      |                     ^
6 warnings generated.
[  1%] Linking CXX executable /work/asio2/bin/x64/http_client
ld: error: unable to find library -lstdc++fs
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [example/http/client/CMakeFiles/http_client.dir/build.make:97: /work/asio2/bin/x64/http_client] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1578: example/http/client/CMakeFiles/http_client.dir/all] Error 2
gmake: *** [Makefile:101: all] Error 2
gmake: Leaving directory '/work/asio2/build'
zhllxt commented 1 month ago

Try remove the "stdc++fs" from CMakeLists.txt

QQ20240810-154740

Curculigo commented 1 month ago

The problem with -lstdc++fs is solved. Other problems arise (related to OpenSSL).

zhllxt commented 1 month ago

You may need to compile openssl under FreeBSD by yourself

Curculigo commented 4 weeks ago

You may need to compile openssl under FreeBSD by yourself

Why can't I use system's OpenSSL? You are using your prebuilt version of OpenSSL included in the repository even on Linux. What's wrong with the system OpenSSL? I think the prebuilt OpenSSL is for Windows users?