wateret/mengde

Build failure in Mac OS : Mojave

sjsinju opened this issue · 12 comments

I've faced build failure after updated Mac OS to Mojave.

Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:94:15: fatal error: 'stdlib.h' file not found
#include_next <stdlib.h>
              ^~~~~~~~~~
In file included from /Users/sujinkim/works/mengde/game/src/core/lua_api.cc:1:
In file included from /Users/sujinkim/works/mengde/game/src/core/./lua_api.h:8:
In file included fIn file included from /Users/sujinkim/works/mengde/game/src/core/cmd.cc:1:
In file included from /Users/sujinkim/works/mengde/game/src/core/./cmd.h:4:
In file included from /usr/local/include/boost/optional.hpp:15:
In file included from /usr/local/include/boost/optional/optional.hpp:20:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/new:91:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/exception:82:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdlib:86:
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:94:15: fatal error: 'stdlib.h' file not found
#include_next <stdlib.h>
              ^~~~~~~~~~
rom /usr/local/include/lua/lauxlib.h:13:
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found
#include_next <stdio.h>
              ^~~~~~~~~
In file included from /Users/sujinkim/works/mengde/game/src/core/scenario.cc:1:
In file included from /Users/sujinkim/works/mengde/game/src/core/./scenario.h:4:
In file included from /Users/sujinkim/works/mengde/game/src/core/./resource_manager.h:4:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/unordered_map:369:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/__hash_table:16:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/memory:653:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/typeinfo:61:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/exception:82:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdlib:86:
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:94:15: fatal error: 'stdlib.h' file not found
#include_next <stdlib.h>
              ^~~~~~~~~~
In file included from /Users/sujinkim/works/mengde/game/src/core/lua_callbacks.cc:1:
In file included from /Users/sujinkim/works/mengde/game/src/core/./lua_callbacks.h:4:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/unordered_map:369:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/__hash_table:16:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/memory:653:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/typeinfo:61:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/exception:82:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdlib:86:
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:94:15: fatal error: 'stdlib.h' file not found
#include_next <stdlib.h>
              ^~~~~~~~~~
In file included from /Users/sujinkim/works/mengde/game/src/core/stage.cc:1:
In file included from /Users/sujinkim/works/mengde/game/src/core/./stage.h:4:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/functional:485:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/typeinfo:61:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/exception:82:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdlib:86:
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:94:15: fatal error: 'stdlib.h' file not found
#include_next <stdlib.h>
              ^~~~~~~~~~
In file included from /Users/sujinkim/works/mengde/game/src/core/user_interface.cc:1:
In file included from /Users/sujinkim/works/mengde/game/src/core/./user_interface.h:6:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/utility:202:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstring:61:
/Library/Developer/CommandLineTools/usr/include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found

And then, I've removed build directory after faced above messages to resolve this situation first.
But I met another error message about lua.
I don't understand why this was occurred.

I attached log file in this comment, @wateret Can you see it??
log.txt

Hmm... I suspect #include "lua/lua.h" looks up the one in the lua library, not the wrapper class which is in the our repo.

Could you please try with verbose option and attach the log again?

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fb42b54..1ee0d74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,7 +18,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
 # selecting the build mode in their IDE

 if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -pedantic")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -pedantic -v")
     set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -g -DDEBUG")
     set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O2")
 elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")

This will show the include directory search order, so it may help.

From the above comment "the one in the lua library" means this file. https://github.com/lua/lua/blob/master/lua.h

And please let me know clang++ --version result on your console.

Mine is(High Sierra):

Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

And let me know Xcode version as well please.

clang++ --version
Apple LLVM version 10.0.0 (clang-1000.10.44.2)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

xcode version : Version 10.0 (10A255)

Log file with verbose : log_verbose.txt

Thanks your help :)

@sjsinju It looks like my guess is right. In the log file:

 266 #include "..." search starts here:
 267 #include <...> search starts here:
 268  /usr/local/include
 269  /usr/local/include/SDL2
 270  /usr/local/include/lua
 271  /Users/sujinkim/works/mengde/game/src
 272  /Users/sujinkim/works/mengde/game/src/util/.```

Line 268 is the first directory the compiler searches, So lua/lua.h is resolved to /usr/local/include/lua/lua.h. However it was supposed to be /Users/sujinkim/works/mengde/game/src/lua/lua.h.

In my environment the search path is different. We should find a way to fix it.

@wateret You're right! It looks like to see common library path first likes you said.

#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/SDL2
 /Users/hanjoung/ws/proj/mengde/game/src
 /Users/hanjoung/ws/proj/mengde/game/src/lua/.
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.1.0/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)

This is from my environment, note that /usr/local/include after the project directory.

@sjsinju I am not sure but could you try this please?

diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt
index 58570e9..ed8056e 100644
--- a/game/CMakeLists.txt
+++ b/game/CMakeLists.txt
@@ -11,7 +11,7 @@ endif()

 file(GLOB SOURCES src/main.cc)

-include_directories(src)
+include_directories(BEFORE SYSTEM src)

 add_subdirectory(src/lua)
 add_subdirectory(src/util)

Unfortunately, it does not work still. :(

I met the black screen after launched the game as I commented in #109, it seems current sdl bug in mojave https://discourse.libsdl.org/t/macos-10-14-mojave-issues/25060.
I should have to investigate this.

Resolved