Cannot statically link with protobuf from windows+vcpkg

645 views
Skip to first unread message

Teo Tyrov

unread,
Sep 26, 2023, 5:39:56 PM9/26/23
to Protocol Buffers
Hello, I am trying to link my library (ppc2cpp_core.lib) with protobuf, and then create the executable ppc2cpp.exe. I want link everything statically, so that downstream users do not require installing protobuf themselves

I am successfully building the library and executable on a github workflow, but when I try to run it locally, I get "libprotobuf.dll missing". I've tried using `set(Protobuf_USE_STATIC_LIBS ON)` but it still doesn't work.


Michael Ngarimu

unread,
Sep 27, 2023, 5:24:14 PM9/27/23
to Protocol Buffers
I haven’t looked at all of your specific details but it looks like issue(s) might be how you’re using vcpkg and not related to protobuf. I don’t how list admins feel about whether this is OT or not.

If this discussion needs to move then probably vcpkg github or somewhere might be good to start.

From your description it sounds like vcpkg is building the dynamic library variant of protobuf. I’ve usually used the vcpkg.json manifest for selecting which variant to build. I don’t know if vcpkg uses CMake variables when building the vcpkg port itself.

I do know that vcpkg uses a very specific build environment that the vcpkg.exe executable curates when ports are built so that they are always built in an identical environment, meaning it may not be the same as the environment in your CMake invocation. 

What I don’t see in your CMakefile is the CMAKE_TOOLCHAIN_FILE pointing to your install of vcpkg.cmake. Is that no longer needed?

Teo Tyrov

unread,
Sep 28, 2023, 4:50:30 AM9/28/23
to Protocol Buffers
I checked the installed protobuf distribution in vcpkg's directory and indeed it seems that it only supports dynamic libraries...

I would gladly move this discussion to somewhere more related to the vcpkg package, but when I search the package on the website (https://vcpkg.io/en/packages), it does not show any info at all (maintainer, contact, any flags to control static/dynamic builds). Is vcpkg completely centralized (because you suggested opening an issue to vcpkg itself)?

I do specify the toolchain file in my cmake invocation, in my github build pipeline file https://github.com/em-eight/ppc2cpp/blob/651231349e7e5745d64f5ef6294fb76704351b07/.github/workflows/windows.yml#L30

At any case, it would be very convenient if protobuf's maintainers added a windows binary distribution to the release files. I think a regular static build covers 99% of the use cases.

Michael Ngarimu

unread,
Sep 28, 2023, 10:34:37 AM9/28/23
to Teo Tyrov, Protocol Buffers
I’m not 100% sure who maintains the protobuf vcpkg port but  

GitHub.com/microsoft/vcpkg  

is always a good place to start for vcpkg related anything. 



Regards,

-- 
Michael "Kiwi" Ngarimu


On Sep 28, 2023, at 01:50, Teo Tyrov <teot...@gmail.com> wrote:


--
You received this message because you are subscribed to a topic in the Google Groups "Protocol Buffers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/protobuf/F1sBHcWzdQk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/e2a12ccf-c00f-4b18-bcf0-c99d7ac242d1n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages