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

Building Protobuf on Windows #29

Open
caucycaucy opened this issue May 1, 2016 · 9 comments
Open

Building Protobuf on Windows #29

caucycaucy opened this issue May 1, 2016 · 9 comments

Comments

@caucycaucy
Copy link

Hi Guys,

I am using the tutorial "Installing Protobuf on Windows C++" to build Protobuf using MinGW. But in Step "$ ./configure", I find "stdint.h" and "inttypes.h" are not found. At the next step "$ mingw32-make", it reports error: "./google/protobuf/stubs/port.h:44:20: stdint.h: No such file or directory."
Does anybody have the similar problem? (I am new to MinGW, should I copy and cover C:\MinGW\include to C:\MinGW\C:\MinGW\msys\1.0\include ?)
My protobuf locates at C:\MinGW\msys\1.0\local\protobuf-master.
Thanks in advance.

Ding

@Ghostkeeper
Copy link
Contributor

For some reason, Protobuf's repository recommends building Protobuf in the msys environment. I don't find that necessary (any more). They have a perfectly functional CMake script.

I suggest downloading CMake (cmake.org), opening up the cmake-gui, then navigating it to /cmake/ for the source directory (choose any build directory you like). You can select native MinGW bindings. Then click configure and generate. Next, navigate a terminal (just a normal one, not an msys terminal) to your build directory,the one you entered in CMake, and type mingw32-make. It should build itself.

@awhiemstra
Copy link
Contributor

Yeah, on Windows you definitely want to use protobuf's cmake build system as it work way better. We use the CMake scripts for building as part of cura-build and I have not had any issues with it so far.

@sedwards2009
Copy link
Contributor

Steps on Windows look roughly like this:

  • Download and carefully unzip it somewhere else and add a "-mingw" suffix to the directory name. https://github.com/google/protobuf/archive/v3.0.0-beta-2.tar.gz
  • mkdir install_dir
  • mkdir cmake_build
  • cd cmake_build
  • cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DCMAKE_INSTALL_LIBDIR=lib -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_CXX_FLAGS="-std=c++11" -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" ../cmake
  • mingw32-make
  • mingw32-make install

@caucycaucy
Copy link
Author

Hi Ghostkeeper, awhiemstra and sedwards2009,

Really appreciation for your reply. I have tried Ghostkeeper and awhiemstra's methods, but it doesn't work for me. Sorry for my stupid.
So I tried sedwards2009's method, but in step

  • cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DCMAKE_INSTALL_LIBDIR=lib -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_CXX_FLAGS="-std=c++11" -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" ../cmake

    I got some message:
    C:\SlicerSoftware\Cura\protobuf-master\cmake_build>cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DCMAKE_INSTALL_LIBDIR=lib -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_CXX_FLAGS="-std=c++11" -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" ../cmake
    CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/CMakeMinGWFindMake.cmake:22 (message):
    sh.exe was found in your PATH, here:
    C:/MinGW/msys/1.0/bin/sh.exe
    For MinGW make to work correctly sh.exe must NOT be in your path.
    Run cmake from a shell that does not have sh.exe in your PATH.
    If you want to use a UNIX shell, then use MSYS Makefiles.
    Call Stack (most recent call first):
    CMakeLists.txt:5 (project)
    CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
    CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
    -- Configuring incomplete, errors occurred!

I really don't know what that mean, so I tried that step again, and this time it produce message:

-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Could NOT find ZLIB (missing: ZLIB_INCLUDE_DIR)
-- Configuring done
-- Generating done
-- Build files have been written to: C:/SlicerSoftware/Cura/protobuf-master/cmake_build

So I tried the next step "mingw32-make", but I got an error message:
c:\mingw\include\math.h: In function 'float hypotf(float, float)':
c:\mingw\include\math.h:635:30: error: '_hypot' was not declared in this scope
{ return (float)(_hypot (x, y)); }

People said it's a bug of MinGW. I am really confused about that. Can you guys give me further information?
Thanks.

Ding

@sedwards2009
Copy link
Contributor

I used the compiler version from http://mingw-w64.org/doku.php/download/mingw-builds, the version more mingw and less msys2.

@caucycaucy
Copy link
Author

Thanks all.
Sorry, I've relied on MS VisualStudio tools too much.
Today, I used CMake ui to build protobuf again. I choose the compiler as Visual Studio 2010 in CMake and take reference of README.md (in dir C:\SlicerSoftware\Cura\protobuf-master\cmake). After several steps, I've built the protobuf. The building ouput is in C:\SlicerSoftware\Cura\install, and the "install" contain sub dirs "bin", "include" and "lib". It looks good.
Since protobuf can be built by CMake, so I tried to build libArcus using CMake too. The libArcs is in
"C:\SlicerSoftware\Cura\libArcus-master". But using the CMake ui, and define
the source code as "C:/SlicerSoftware/Cura/libArcus-master",
define the binaries as "C:/SlicerSoftware/Cura/libArcus-master/build",
and choose MS VS2010,
after clicking "Configure", I got error message in CMake ui:

CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find Protobuf (missing: PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR)
(Required is at least version "3.0.0")
Call Stack (most recent call first):
C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindProtobuf.cmake:308 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:13 (find_package)

How to fix it?
Thanks in advance.

Ding

@Ghostkeeper
Copy link
Contributor

You've built Protobuf somewhere on your computer, but when building libArcus, it doesn't know where to find the Protobuf binaries and headers for some reason.

In the CMake GUI there should be two variables which it indicates are missing (you might have to activate advanced mode): PROTOBUF_LIBRARY and PROTOBUF_INCLUDE_DIR.

For PROTOBUF_LIBRARY, look in the "lib" folder of C:\SlicerSoftware\Cura\install. That should contain either a .dll or .a file of Protobuf (also Protobuf-lite and possibly a Debug variant, but ignore those).

For PROTOBUF_INCLUDE_DIR, point it to that "include" folder in your install directory. It should contain a folder marked "google", which has a subfolder marked "protobuf".

@caucycaucy
Copy link
Author

Hi Ghostkeeper,

Thanks for your information. I've reinstalled MSYS2, MinGW-64, and some other libs. Finally I've built the protobuf, the protobuf's libs and includes showed in "C:\msys32\usr\local". Then, I try to built libArcs, but when I use command "cmake ..", I got the following error information.

$ cmake ..
-- Could NOT find PROTOBUF (missing: PROTOBUF_LIBRARY)
Traceback (most recent call last):
File "C:/msys32/local/libArcus-master/cmake/FindSIP.py", line 8, in import sipconfig
ImportError: No module named 'sipconfig'
CMake Error at cmake/FindSIP.cmake:58 (MESSAGE):
Could not find SIP Call Stack (most recent call first):
CMakeLists.txt:22 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/msys32/local/libArcus-master/build/CMakeFiles/CMakeOutput.log".

I've searched your another thread about "sip.h". Your suggestion is to install sip package. But when I tried to use command "pacman -S sip-dev", I get nothing. I also tried
"pacman -S python-sipconfig",
"pacman -S python-sip-dev",
but nothing works for me.

I am new to CMake and MinGW.
Any suggestion is welcome.
Thanks in advance.

Ding

@Ghostkeeper
Copy link
Contributor

What I meant is this:
Advanced button
Libraries and Include

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

4 participants