Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protobuf compiler version 22.3 doesn't match library version 4.22.3 in cmake #12539

Closed
sunflower-knight opened this issue Apr 24, 2023 · 8 comments
Assignees

Comments

@sunflower-knight
Copy link

What version of protobuf and what language are you using?
Version: release v22.3
Language: C++

What operating system (Linux, Windows, ...) and version?
Ubuntu22.04

What runtime / compiler are you using (e.g., python version or gcc version)
gcc

What did you do?
Steps to reproduce the behavior:

  1. Go to 'protobuf and compile it from source and install '
  2. Click on 'cmake FindProtobuf '
  3. See error

What did you expect to see
cmake FindProtobuf work well.
maybe protoc --version is 4.22.3 is great.
What did you see instead?
When I use protoc --verision , answer is 22.3
but the version in common.h that cmake will use is 4.22.3

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

@sunflower-knight sunflower-knight added the untriaged auto added to all issues by default when created. label Apr 24, 2023
@zhangskz
Copy link
Member

The protoc and cmake version numbers should be WAI. See https://protobuf.dev/news/2022-05-06/#versioning -- I believe protoc only has the shared minor version (22.3) but CMake uses the C major version number (4.22.3)

Are you encountering an actual error when using FindProtobuf? If so, what is the error?

@zhangskz zhangskz added cmake and removed untriaged auto added to all issues by default when created. labels Apr 24, 2023
@zhangskz zhangskz added the 22.x label Apr 24, 2023
@sunflower-knight
Copy link
Author

Findprotobuf Here

When I use cmake findprotobuf, I get the version 4.22.3 from 402203 in header filer common.h
exe version and lib version not match here
protoc --version is 22.3
but cmake find protobuf version from common.h in /google/protobuf/stubs/common.h is 4.22.3

version dont match

@deannagarcia
Copy link
Member

That tool is not owned by us and did not get updated when we made our versioning change. Versions "4.22.3" and "22.3" should match in a tool like this. I recommend filing a bug there.

@jin-111
Copy link

jin-111 commented May 8, 2023

I meet the issue too with the version 4.22.3. I switch to protoc(3.21.12), and this issue does not arises. It's nessary to check why this issue arises。
My cmake version is 3.26.3, witch is on windows 10。 When I built the protoc 4.22.3 with gcc in mingw64, I notice that the version of protoc show by was 22.3。 And I built it successful。As I used find_package to get protobuf, cmake raised issues witch are "Protobuf compiler version 22.3 doesn't match library version 0.22.3" and "Found Protobuf: C:/Program Files (x86)/protobuf/lib/libprotobuf.a (found version "4.22.3") ".

@weston-wang
Copy link

weston-wang commented Sep 14, 2023

I'm still running into this with Protobuf 4.24.3, i.e. "Protobuf compiler version 24.3 doesn't match library version 4.24.3" in CLIon, which uses CMake 3.26.4. Is there a workaround or do I have to wait for 3.27? protoc --version shows libprotoc 24.3

@msherman13
Copy link

also seeing this issue when importing into cmake after a fresh build from source of v26.1. I am also not able to specify find_package(Protobuf 26.1 REQUIRED) in cmake now because it says it is only finding 5.26.1.

build steps:

    cmake \
        -DCMAKE_BUILD_TYPE=Release \\\
        -Dprotobuf_BUILD_TESTS=OFF \
        -Dprotobuf_BUILD_PROTOBUF_BINARIES=ON \
        -Dprotobuf_BUILD_PROTOC_BINARIES=ON \
        -DBUILD_SHARED_LIBS=OFF ..
    make
    make install

cmake command to import:

set(Protobuf_USE_STATIC_LIBS ON)
find_package(Protobuf REQUIRED)

warning when running cmake:

CMake Warning at /usr/share/cmake-3.26/Modules/FindProtobuf.cmake:524 (message):
  Protobuf compiler version 26.1 doesn't match library version 5.26.1

@XR-stb
Copy link

XR-stb commented Apr 7, 2024

also seeing this issue when importing into cmake after a fresh build from source of v26.1. I am also not able to specify find_package(Protobuf 26.1 REQUIRED) in cmake now because it says it is only finding 5.26.1.

build steps:

    cmake \
        -DCMAKE_BUILD_TYPE=Release \\\
        -Dprotobuf_BUILD_TESTS=OFF \
        -Dprotobuf_BUILD_PROTOBUF_BINARIES=ON \
        -Dprotobuf_BUILD_PROTOC_BINARIES=ON \
        -DBUILD_SHARED_LIBS=OFF ..
    make
    make install

cmake command to import:

set(Protobuf_USE_STATIC_LIBS ON)
find_package(Protobuf REQUIRED)

warning when running cmake:

CMake Warning at /usr/share/cmake-3.26/Modules/FindProtobuf.cmake:524 (message):
  Protobuf compiler version 26.1 doesn't match library version 5.26.1

Have you solved this problem?

@msherman13
Copy link

also seeing this issue when importing into cmake after a fresh build from source of v26.1. I am also not able to specify find_package(Protobuf 26.1 REQUIRED) in cmake now because it says it is only finding 5.26.1.
build steps:

    cmake \
        -DCMAKE_BUILD_TYPE=Release \\\
        -Dprotobuf_BUILD_TESTS=OFF \
        -Dprotobuf_BUILD_PROTOBUF_BINARIES=ON \
        -Dprotobuf_BUILD_PROTOC_BINARIES=ON \
        -DBUILD_SHARED_LIBS=OFF ..
    make
    make install

cmake command to import:

set(Protobuf_USE_STATIC_LIBS ON)
find_package(Protobuf REQUIRED)

warning when running cmake:

CMake Warning at /usr/share/cmake-3.26/Modules/FindProtobuf.cmake:524 (message):
  Protobuf compiler version 26.1 doesn't match library version 5.26.1

Have you solved this problem?

Yes changing the find package line to the below solves the issue for me:

find_package(Protobuf CONFIG REQUIRED)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants