Skip to content

Conversation

@Coeur
Copy link
Contributor

@Coeur Coeur commented Nov 4, 2025

Partial revert of eb7bed0

This is a build fix for https://github.com/transmission/transmission/actions/runs/19074269764/job/54485374550?pr=7765#step:6:2528

event.lib(evutil_rand.c.obj) : error LNK2019: unresolved external symbol BCryptGenRandom referenced in function arc4_seed_win32

azat
azat previously approved these changes Nov 16, 2025
Copy link
Member

@azat azat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but blocked by #1819

@azat azat force-pushed the coeur/BCryptGenRandom branch from c9a655c to 6fa8ccc Compare November 17, 2025 08:08
#cmakedefine EVENT__HAVE__GMTIME64 1

/* Define to 1 if you link with `bcrypt.lib'. */
#cmakedefine EVENT__HAVE_BCRYPT_LIB 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, but who will set this define?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know.
How do you link with bcrypt from cmake?

My goal is to solve the build issue referenced in the pull request description. If you know a way, please help. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is done here -

set(LIB_PLATFORM ws2_32 shell32 advapi32 bcrypt iphlpapi)

So it is always linked with bcrypt.lib no need to detect it at configure stage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, somehow that doesn't work for building libevent within Transmission.

The only fix I could find was to revert to the old code. Can we define an option to use bcrypt ON/OFF?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, then I believe that you need to detect presence of the function not the header file, smth like this

$ git di
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9bcb1597..0cd72061 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -529,6 +529,7 @@ if (WIN32)
     list(APPEND SYMBOLS_TO_CHECK
         _gmtime64
         _gmtime64_s
+        BCryptGenRandom
     )
 else()
     list(APPEND SYMBOLS_TO_CHECK
diff --git a/event-config.h.cmake b/event-config.h.cmake
index a6375141..09bfc06f 100644
--- a/event-config.h.cmake
+++ b/event-config.h.cmake
@@ -282,6 +282,9 @@
 /* Define to 1 if you have the `_gmtime64' function. */
 #cmakedefine EVENT__HAVE__GMTIME64 1

+/* Define to 1 if you have the `BCryptGenRandom' function. */
+#cmakedefine EVENT__HAVE__BCRYPTGENRANDOM 1
+
 /* Define to 1 if the system has the type `struct addrinfo'. */
 #cmakedefine EVENT__HAVE_STRUCT_ADDRINFO 1

Not tested, but you get the idea

Copy link
Contributor Author

@Coeur Coeur Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try it and it did not work.
You can see it was my code on November 5: d2393ba

@azat azat dismissed their stale review November 17, 2025 20:44

Have some questions

@Coeur Coeur force-pushed the coeur/BCryptGenRandom branch from 6fa8ccc to 97a86bf Compare November 19, 2025 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants