abunchofhacks / Epicinium

A strategy game with simultaneous turns where nature is a finite resource
GNU Affero General Public License v3.0
47 stars 5 forks source link

Build fails #2

Open rapenne-s opened 3 years ago

rapenne-s commented 3 years ago

Hello,

I'm trying to build the project on OpenBSD 6.8 amd64 but clang and gcc find errors at compilation time. I don't know why though. At least it doesn't seem linux-specific code to me (we often hit that when using BSD systems).

clang output:

getconf: LONG_BIT: unknown variable
clang++  -std=c++11 -MT .obj/src/main/.cu-discord.o -MMD -MP -MF .dep/src/main/.cu-discord.Td -I/usr/X11R6/include/ -I ./ -I src/action/ -I src/ai/ -I src/audio/ -I src/build/ -I src/common/ -I src/edit/ -I src/engine/ -I src/essai/ -I src/graphics/ -I src/interface/ -I src/logic/ -I src/main/ -I src/message/ -I src/network/ -I src/shaders/ -I src/user/   -o .obj/src/main/.cu-discord.o -c src/main/.cu-discord.cpp
In file included from src/main/.cu-discord.cpp:1:
In file included from src/main/discordrpc.cpp:25:
In file included from src/common/source.hpp:45:
In file included from ./libs/plog/Log.h:7:
In file included from ./libs/plog/Logger.h:2:
In file included from ./libs/plog/Appenders/IAppender.h:2:
In file included from ./libs/plog/Record.h:4:
./libs/plog/Util.h:134:9: warning: non-void function does not return a value [-Wreturn-type]
        }
        ^
In file included from src/main/.cu-discord.cpp:1:
In file included from src/main/discordrpc.cpp:25:
src/common/source.hpp:204:44: error: use of undeclared identifier '_TRUNCATE'
        count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
                                           ^
src/common/source.hpp:206:17: error: use of undeclared identifier '_vscprintf'
        count = _vscprintf(format, ap);
                ^
1 warning and 2 errors generated.
gmake: *** [Makefile:888 : .obj/src/main/.cu-discord.o] Erreur 1

clang 10.0.1 can't find _TRUNCATE and the function _vcsprintf I tried with gcc 8.4.0 which gives a similar output:

gcc output

getconf: LONG_BIT: unknown variable
eg++  -std=c++11 -MT .obj/src/main/.cu-discord.o -MMD -MP -MF .dep/src/main/.cu-discord.Td -I/usr/X11R6/include/ -I ./ -I src/action/ -I src/ai/ -I src/audio/ -I src/build/ -I src/common/ -I src/edit/ -I src/engine/ -I src/essai/ -I src/graphics/ -I src/interface/ -I src/logic/ -I src/main/ -I src/message/ -I src/network/ -I src/shaders/ -I src/user/   -o .obj/src/main/.cu-discord.o -c src/main/.cu-discord.cpp
In file included from ./libs/plog/Record.h:4,
                 from ./libs/plog/Appenders/IAppender.h:2,
                 from ./libs/plog/Logger.h:2,
                 from ./libs/plog/Log.h:7,
                 from src/common/source.hpp:45,
                 from src/main/discordrpc.cpp:25,
                 from src/main/.cu-discord.cpp:1:
./libs/plog/Util.h: In function 'unsigned int plog::util::gettid()':
./libs/plog/Util.h:134:9: warning: no return statement in function returning non-void [-Wreturn-type]
         }
         ^
In file included from src/main/discordrpc.cpp:25,
                 from src/main/.cu-discord.cpp:1:
src/common/source.hpp: In function 'int c99_vsnprintf(char*, size_t, const char*, __va_list_tag*)':
src/common/source.hpp:204:44: error: '_TRUNCATE' was not declared in this scope
         count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
                                            ^~~~~~~~~
src/common/source.hpp:204:44: note: suggested alternative: 'O_TRUNC'
         count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
                                            ^~~~~~~~~
                                            O_TRUNC
src/common/source.hpp:204:17: error: '_vsnprintf_s' was not declared in this scope
         count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
                 ^~~~~~~~~~~~
src/common/source.hpp:204:17: note: suggested alternative: 'vsnprintf'
         count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
                 ^~~~~~~~~~~~
                 vsnprintf
src/common/source.hpp:206:17: error: '_vscprintf' was not declared in this scope
         count = _vscprintf(format, ap);
                 ^~~~~~~~~~
src/common/source.hpp:206:17: note: suggested alternative: 'vswprintf'
         count = _vscprintf(format, ap);
                 ^~~~~~~~~~
                 vswprintf
gmake: *** [Makefile:888 : .obj/src/main/.cu-discord.o] Erreur 1
SLiV9 commented 3 years ago

Hi, thanks for trying this out on OpenBSD!

That specific function is only used in a Windows-only replacement implementation of a POSIX function, and there's a PLATFORMUNIX def-guard in front of it that should prevent it from being compiled on other operating systems. Looking at the compiler arguments, there are quite a few missing from what I would expect. In particular -DPLATFORMDEBIAN64 is missing, which explains why in turn PLATFORMUNIX is not defined. (The Makefile currently distinguishes between "windows", "osx" and "debian", treating all operating systems that aren't named "Windows_NT" or "Darwin" as the latter. If needed we could add -DPLATFORMBSD64 or something like that, but for now PLATFORMDEBIAN64 should suffice.)

I think something is overriding the CFLAGS variable set by our Makefile, perhaps an environment variable of the same name or a command line override. Are you running make CFLAGS=-I/usr/X11R6/include/ by any chance? If so I think you can achieve what you want by running make IFLAGS_CONFIG="-I/usr/X11R6/include/" instead, or equivalently by adding the line

IFLAGS_CONFIG = -I/usr/X11R6/include/

to a file named .config.make in the same folder as the Makefile.

rapenne-s commented 3 years ago

Hi, thank you for your reply.

I added IFLAGS_CONFIG=-I/usr/X11R6/include/ in .config.make. This let the build continues a bit further but I ultimately get an error on a clang++ invocation without my -I flag, while the previous clang++ call has the correct flags sets.

I run the build with gmake CC=clang CXX=clang++

clang++  -std=c++11 -MT .obj/src/engine/selectorcontext.o -MMD -MP -MF .dep/src/engine/selectorcontext.Td -O3 -s -pedantic -pedantic-errors -Wall -Wextra    -pthread -DPLATFORMDEBIAN64  -DSELF_PATCH_ENABLED=false       -I ./ -I src/action/ -I src/ai/ -I src/audio/ -I src/build/ -I src/common/ -I src/edit/ -I src/engine/ -I src/essai/ -I src/graphics/ -I src/interface/ -I src/logic/ -I src/main/ -I src/message/ -I src/network/ -I src/shaders/ -I src/user/ -I/usr/X11R6/include/  -o .obj/src/engine/selectorcontext.o -c src/engine/selectorcontext.cpp
clang++: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
In file included from src/engine/selectorcontext.cpp:25:
In file included from src/common/source.hpp:45:
In file included from ./libs/plog/Log.h:7:
In file included from ./libs/plog/Logger.h:2:
In file included from ./libs/plog/Appenders/IAppender.h:2:
In file included from ./libs/plog/Record.h:4:
./libs/plog/Util.h:134:9: warning: non-void function does not return a value [-Wreturn-type]
        }
        ^
1 warning generated.
mv -f .dep/src/engine/selectorcontext.Td .dep/src/engine/selectorcontext.d
clang++  -std=c++11 -MT .obj/libs/imgui/imgui_impl_opengl2.o -MMD -MP -MF .dep/libs/imgui/imgui_impl_opengl2.Td -O3 -s  -I ./  -o .obj/libs/imgui/imgui_impl_opengl2.o -c libs/imgui/imgui_impl_opengl2.cpp
clang++: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
libs/imgui/imgui_impl_opengl2.cpp:52:10: fatal error: 'GL/gl.h' file not found
#include <GL/gl.h>
         ^~~~~~~~~
1 error generated.
gmake: *** [Makefile:867 : .obj/libs/imgui/imgui_impl_opengl2.o] Erreur 1
SLiV9 commented 3 years ago

I've adjusted the Makefile so that IFLAGS_CONFIG variable is also used for the source files in libs/. Could you try again with the latest Makefile?

rapenne-s commented 3 years ago

I've been able to go further with your help, I have another issue now that I haven't been to understand.

[...]
1 warning generated.
mv -f .dep/.pic/src/common/version.Td .dep/.pic/src/common/version.d
clang++  -std=c++11 -MT .obj/.o -MMD -MP -MF .dep/.Td -o bin/sanitychecker .obj/src/build/sanitychecker.o .obj/.pic/src/common/.cu-common.o .obj/.pic/src/common/dictator.o .obj/.pic/src/common/version.o .obj/.pic/src/logic/.cu-automaton.o .obj/.pic/src/logic/.cu-logic.o .obj/.pic/src/logic/bible.o .obj/.pic/libs/jsoncpp/jsoncpp.o -Wl,-rpath,'$ORIGIN' -lstdc++    -O3   -lz -lm -pthread
clang++  -std=c++11 -MT .obj/.o -MMD -MP -MF .dep/.Td -o bin/game .obj/src/main/.cu-discord.o .obj/src/main/.cu-menu.o .obj/src/main/.cu-online.o .obj/src/main/main.o .obj/src/main/mainmenu.o .obj/src/main/messageinjector.o .obj/src/main/multiplayermenu.o .obj/src/main/settingsmenu.o .obj/src/main/steam.o .obj/src/common/.cu-common.o .obj/src/common/dictator.o .obj/src/common/version.o .obj/src/logic/.cu-automaton.o .obj/src/logic/.cu-logic.o .obj/src/logic/bible.o .obj/libs/jsoncpp/jsoncpp.o .obj/src/ai/.cu-ai.o .obj/src/ai/aichargingcheetah.o .obj/src/network/.cu-network.o .obj/src/message/.cu-message.o .obj/src/user/.cu-client.o .obj/src/engine/.cu-diegetic.o .obj/src/engine/.cu-engine.o .obj/src/engine/commander.o .obj/src/engine/observer.o .obj/src/engine/ordercontext.o .obj/src/engine/selectorcontext.o .obj/src/graphics/.cu-graphics.o .obj/src/audio/.cu-audio.o .obj/src/action/.cu-action.o .obj/src/action/figure.o .obj/src/action/surface.o .obj/src/interface/.cu-interface.o .obj/libs/SDL2/SDL2_gfxPrimitives.o .obj/libs/SDL2/SDL2_rotozoom.o .obj/libs/imgui/imgui.o .obj/libs/imgui/imgui_demo.o .obj/libs/imgui/imgui_draw.o .obj/libs/imgui/imgui_impl_opengl2.o .obj/libs/imgui/imgui_impl_sdl.o .obj/libs/imgui/imgui_sdl.o .obj/libs/imgui/imgui_stdlib.o .obj/libs/imgui/imgui_widgets.o .obj/libs/tinygettext/dictionary.o .obj/libs/tinygettext/dictionary_manager.o .obj/libs/tinygettext/iconv.o .obj/libs/tinygettext/language.o .obj/libs/tinygettext/log.o .obj/libs/tinygettext/plural_forms.o .obj/libs/tinygettext/po_parser.o .obj/libs/tinygettext/tinygettext.o .obj/libs/tinygettext/unix_file_system.o -Wl,-rpath,'$ORIGIN' -lstdc++   -ldl   -Wl,--no-as-needed bin/libfreetype.so bin/libpng16.so bin/libz.so -Wl,--as-needed bin/libSDL2_image.so bin/libSDL2_net.so bin/libSDL2_ttf.so bin/libSDL2.so  bin/libGLEW.so -lGL bin/libssl.so bin/libcrypto.so bin/libcurl.so  bin/libdiscord-rpc.so -lstdc++fs  -O3   -lz -lm -pthread
clang++: error: no such file or directory: 'bin/libfreetype.so'
clang++: error: no such file or directory: 'bin/libpng16.so'
clang++: error: no such file or directory: 'bin/libz.so'
clang++: error: no such file or directory: 'bin/libSDL2_image.so'
clang++: error: no such file or directory: 'bin/libSDL2_net.so'
clang++: error: no such file or directory: 'bin/libSDL2_ttf.so'
clang++: error: no such file or directory: 'bin/libSDL2.so'
clang++: error: no such file or directory: 'bin/libGLEW.so'
clang++: error: no such file or directory: 'bin/libssl.so'
clang++: error: no such file or directory: 'bin/libcrypto.so'
clang++: error: no such file or directory: 'bin/libcurl.so'
clang++: error: no such file or directory: 'bin/libdiscord-rpc.so'
gmake: *** [Makefile:720 : bin/game] Erreur 1
SLiV9 commented 3 years ago

That's odd. Before compiling anything it should have created the file bin/target (with contents in this case being "debian64") and then copied the bin/ folder from a subdirectory. Maybe this step failed earlier in the process.

Are those files (bin/libfreetype.so, bin/libpng16.so, etcetera) indeed missing from the bin/ folder? In that case you should be able to get those files with cp -RP archive/debian64/. ./ or by copying the contents of archive/debian64/bin/ into bin/ manually. Calling make debian64 will do the same thing but will also cause all object files to be recompiled.

If the files are present, it could be a permission problem if the initial make that made bin/target was done as root.