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 with MinGW #76

Closed
Ratstail91 opened this issue Feb 18, 2016 · 20 comments
Closed

Building with MinGW #76

Ratstail91 opened this issue Feb 18, 2016 · 20 comments

Comments

@Ratstail91
Copy link

@Ratstail91 Ratstail91 commented Feb 18, 2016

I feel stupid asking this, but how the hell do you build this with MinGW? make doesn't work, and the makefile doesn't seem to have the answer.

@junyer
Copy link
Member

@junyer junyer commented Feb 18, 2016

CMake supports MinGW and MSYS, I believe, so please try using it to generate the appropriate files for your system.

@Ratstail91
Copy link
Author

@Ratstail91 Ratstail91 commented Feb 18, 2016

I've been struggling all day with this repo, and nothing has come of it. Is a simple Regex parser so much to ask?

@Ratstail91 Ratstail91 closed this Feb 18, 2016
@junyer
Copy link
Member

@junyer junyer commented Feb 18, 2016

Did you try using CMake?

@Ratstail91
Copy link
Author

@Ratstail91 Ratstail91 commented Feb 20, 2016

Yes, and it still didn't work. Edit: This won't work, boost's regex won't work, at this rate I'll be better off writing my own regex engine.

@junyer
Copy link
Member

@junyer junyer commented Feb 21, 2016

Please read How to Report Bugs Effectively by Simon Tatham.

@DThiebaud
Copy link

@DThiebaud DThiebaud commented Feb 22, 2016

Regex2 gets compile errors for me for mingw using the make file generated by Cmake:

E:\src\re2\bin>make
[ 1%] Building CXX object CMakeFiles/benchmark.dir/re2/testing/backtrack.cc.obj
In file included from c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/atomic:38:0,
from E:/src/re2/util/util.h:33,
from E:\src\re2\re2\testing\backtrack.cc:26:
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
In file included from c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/atomic:41:0,
from E:/src/re2/util/util.h:33,
from E:\src\re2\re2\testing\backtrack.cc:26:
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/atomic_base.h:63:3: error: 'constexpr' does not name a type
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/atomic_base.h:63:3: note: C++11 'constexpr' only available with -std=c++11 or -std=gnu++11
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/atomic_base.h:71:41: error: expected initializer before 'noexcept'
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/atomic_base.h:75:41: error: expected initializer before 'noexcept'
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/atomic_base.h:81:30: error: expected initializer before 'noexcept'
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/atomic_base.h:129:25: error: 'char16_t' was not declared in this scope
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/atomic_base.h:129:33: error: template argument 1 is invalid
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/atomic_base.h:129:64: error: invalid type in declaration before ';' token
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/atomic_base.h:132:25: error: 'char32_t' was not declared in this scope
c:\gnat\2013\bin../lib/gcc/i686-pc-mingw32/4.7.4/../../../../include/c++/4.7.4/bits/atomic_base.h:132:33: error: template argument 1 is invalid
c

and on and on for hundreds of errors. Apparently some source files are using c++11 features, but the option for them is not being turned on. If anyone wants the full printfile of the compile I can send it to them. It looks like cmakelists.txt needs somethings added to generate compile option -stdc=c++11 if mingw is being used.

Cmake version: 3.4.0
make version: GNU Make 4.1 Built for x86_64-w64-mingw32
g++.exe version: g++ (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 4.9.2

@DThiebaud
Copy link

@DThiebaud DThiebaud commented Feb 22, 2016

I think it would be worth re-opening this topic.

@junyer
Copy link
Member

@junyer junyer commented Feb 22, 2016

Ahh. Yes, C++11 has been required since cd505f4. Unfortunately, I had not considered MinGW at the time. I will look into tweaking CMakeLists.txt accordingly.

Thank you for investigating!

@junyer junyer reopened this Feb 22, 2016
@gopherbot gopherbot closed this in 11250b3 Feb 22, 2016
@DThiebaud
Copy link

@DThiebaud DThiebaud commented Feb 22, 2016

Further testing shows: in the makefiles generated by Cmake for mingw on windows, and for gcc on linux, the option "-std=c++" is not passed to the compiled, and the compile gets hundreds of errors for this. Note that this happens on gcc on linux as well as mingw on windows.

If I manually add this option to CMAKE_C++_FLAGS in the GUI, then re2 builds cleanly on gcc. mingw gets a compile error in re2test.cc because it can't find include file <include sys/mman.h>. This is a separate issue. I'll check if there's an error in my setup before logging a new issue.

Tomarrow I'm test that re2 still compiles ok on MSVC.

@DThiebaud
Copy link

@DThiebaud DThiebaud commented Feb 22, 2016

Gopherbot's commit does not correct the problem for me--I get the same results as before.

@junyer
Copy link
Member

@junyer junyer commented Feb 22, 2016

Maybe it should use add_compile_options rather than add_definitions even though the latter works for me with CMake 2.8.12.2. I will try that instead.

BTW, if you want to compare, here is an example of what grep(1) turns up with 11250b3:

./CMakeFiles/re2.dir/flags.make:CXX_FLAGS = -I/home/junyer/re2    -std=c++11 -pthread
@junyer
Copy link
Member

@junyer junyer commented Feb 22, 2016

Please try with 366f920 on Linux.

I will try to figure out what the other MinGW issue might be.

@DThiebaud
Copy link

@DThiebaud DThiebaud commented Feb 22, 2016

That didn't seem to work either. I'm tired and could be making errors. I'll retest in the morning.

@junyer
Copy link
Member

@junyer junyer commented Feb 22, 2016

No worries. As always, your assistance is very much appreciated!

I have committed 5e8da74, which should hopefully address the other MinGW issue.

@DThiebaud
Copy link

@DThiebaud DThiebaud commented Feb 22, 2016

In Cmake, WIN32 is true for Mingw. We want to set "-std=c++11" for both gcc in linux and Mingw in Windows, but not for MSVC. The following works for me:

if (NOT MSVC)
add_definitions(-std=c++11)
endif()
if(WIN32)
add_definitions(-DUNICODE -D_UNICODE -DSTRICT -DNOMINMAX)
set(THREADING threadwin)
else()
add_definitions(-pthread)
set(THREADING thread)
list(APPEND EXTRA_TARGET_LINK_LIBRARIES -pthread)
endif()

Also, the fix for not finding sys/mman.h worked for me.

I'll retest everything in the morning.

@junyer
Copy link
Member

@junyer junyer commented Feb 22, 2016

Good catch. WIN32 does indeed mean the target, not the compiler.

@junyer
Copy link
Member

@junyer junyer commented Feb 22, 2016

Okay, 72276a1 looks for GCC/Clang, so that should hopefully cover Cygwin as well as MinGW.

@DThiebaud
Copy link

@DThiebaud DThiebaud commented Feb 22, 2016

With the latest patch, re2 builds correctly for MSVC and mingw on Windows and GCC on Linux using the make files generated by CMake. Thanks to those who contributed on this.

@DThiebaud
Copy link

@DThiebaud DThiebaud commented Feb 23, 2016

CMake does not have an option to create a make file for Cygwin. However, RE2 compile cleanly under Cygwin using the make file in the top directory of re2. (Since the aim of Cygwin is to replicate a Unix environment, this is probably to be expected, but I thought I'd try. It worked.)

@junyer
Copy link
Member

@junyer junyer commented Feb 23, 2016

The cmake(1) manual page seems to suggest that Cygwin is supported, but if it Just Works™ with the RE2 Makefile anyway, then that's even better.

Thank you very much for diagnosing the problems and also for confirming the fixes!

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.