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

Error while making moongl #9

Open
Yaumama opened this issue Mar 6, 2022 · 15 comments
Open

Error while making moongl #9

Yaumama opened this issue Mar 6, 2022 · 15 comments

Comments

@Yaumama
Copy link

Yaumama commented Mar 6, 2022

While building moongl I get this error:

mingw32-make[1]: Entering directory 'D:/CodeProjects/test/moongl/src'
process_begin: CreateProcess(NULL, lua -e "print(string.match(_VERSION, \"%d+%.%d+\") or \"5.3\")", ...) failed.
Makefile:15: pipe: Bad file descriptor
cc -O2 -Wall -Wextra -Wpedantic -DCOMPAT53_PREFIX=moongl_compat_ -std=gnu99 -DLUAVER=5.3 -fpic -DLINUX -I/usr/include -I/usr/include/lua5.3 -I/usr/local/include/lua5.3   -c -o bitfield.o bitfield.c
In file included from internal.h:35,
                 from bitfield.c:26:
moongl.h:33:10: fatal error: lua.h: No such file or directory
   33 | #include <lua.h>
      |          ^~~~~~~
compilation terminated.
mingw32-make[1]: *** [<builtin>: bitfield.o] Error 1
mingw32-make[1]: Leaving directory 'D:/CodeProjects/test/moongl/src'
mingw32-make: *** [Makefile:5: build] Error 2

Can anyone help?

@stetre
Copy link
Owner

stetre commented Mar 7, 2022

You are compiling for Lua 5.3, but it is either not installed, or it is not in a standard location (the error says that it cannot find the Lua headers, lua.h & C).

@Yaumama
Copy link
Author

Yaumama commented Mar 9, 2022

Thank you, how can I install the header files?

@stetre
Copy link
Owner

stetre commented Mar 10, 2022

Install Lua 5.3. This also installs the header files.

As an aside, it may be that you have already installed Lua version 5.4, which is the current version. If this is the case, and you want to use this version, you have to compile with the LUAVER=5.4 flag (see here).

@Yaumama
Copy link
Author

Yaumama commented Mar 10, 2022

I installed the Lua 5.3 binaries, but it didn't install the header files. I will try to find a way to install Lua 5.3.

@stetre
Copy link
Owner

stetre commented Mar 11, 2022

If you are using MSYS2, just follow these instructions. This will install the latest packaged version, which currently is Lua 5.4.

If you really need to use 5.3, though, you should be able to install it from the sources which you can find at www.lua.org. Download the package for the version you are interested in (e.g. lua-5.3.6.tar.gz) , and run these commands from a mingw shell:

$ tar -zxvf lua-5.3.6.tar.gz 
$ cd lua-5.3.6 
$ make mingw
$ make install

@Yaumama
Copy link
Author

Yaumama commented Mar 13, 2022

Now I am getting this error:

D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lGLEW
collect2.exe: error: ld returned 1 exit status
make[1]: [Makefile:163: moongl] Error 1 (ignored)

make[1]: Leaving directory '/d/CodeProjects/MoonGL/moongl/src'

@stetre
Copy link
Owner

stetre commented Mar 13, 2022

First of all, I heartily suggest you to follow the installation instructions, step by step. By just following them, you wouldn't get any of these errors. They are written specifically for this purpose.

That said, this last error tells you that the GLEW library (libglew) is missing from your system. The solution is to install libglew, which (as stated in the above instructions) is a required dependency for moongl.

@Yaumama
Copy link
Author

Yaumama commented Mar 14, 2022

I installed glew with msys2 however it still isn't working, I also followed the installation instructions.

@stetre
Copy link
Owner

stetre commented Mar 14, 2022

It seems that your system isn't recognized as MINGW, but regarded as LINUX instead.

The makefile (src/Makefile) detects that the system is MINGW by checking the MINGW_PREFIX environment variable, which should be predefined. This suggests that the MINGW_PREFIX variable is not defined in the shell you are compiling in.

To check it, run echo $MINGW_PREFIX. This should echo something like \mingw64, if I recall correctly (unfortunately I don't have a windows system at hand to try it out myself). If it echoes nothing, then the variable is not defined and this is the source of the problem. The workaround is to properly define the variable, for example by executing export MINGW_PREFIX=\mingw64 in the shell.

@Yaumama
Copy link
Author

Yaumama commented Mar 18, 2022

echo $MINGW_PREFIX just echoed exactly that "$MINGW_PREFIX". And where should I execute export MINGW_PREFIX=\mingw64?

@stetre
Copy link
Owner

stetre commented Mar 18, 2022

Are you working in a plain mingw shell? Try echo ${MINGW_PREFIX} instead.

However, you should execute the export command in the shell that you are using to compile the library, like the one you used to install other programs with pacman as per the instructions. The instructions also tell you the shell launcher you should use to execute the shell.

MSYS2 pre-defines a few environment variables, like MINGW_PACKAGE_PREFIX and MINGW_PREFIX. The former is useful to detect if the system is 32 or 64 bit, and thus to select the appropriate package when installing something with pacman. The latter (MINGW_PREFIX) contains the base path for the mingw directory tree. The makefiles for my libraries rely on this variable both to detect that the system is mingw (instead of linux, or macos) and adjust the build commands accordingly, and to decide where to install them when you run make install. I didn't noticed it at first (my bad), but in the first post of this thread you have a -DLINUX passed to the gcc command, which means that the system detection failed and that the makefile 'thinks' it is compiling for a linux system (hence the error, and possibly the other errors you got previously).

@Yaumama
Copy link
Author

Yaumama commented Mar 20, 2022

Oh thanks, it echoed /mingw64! Upon reinstalling gcc and lua, nothing changed.

@stetre
Copy link
Owner

stetre commented Mar 20, 2022

Do you mean that you still get the -DLINUX flag? That would be very strange.

By the way, another strange thing I noticed in your logs is that Entering directory 'D:/CodeProjects/test/moongl/src' thing. Are you really following the instructions?

@Yaumama
Copy link
Author

Yaumama commented Mar 20, 2022

I'm not getting the -DLINUX flag, I am getting the same glew error. And yes, I am following the instructions

@stetre
Copy link
Owner

stetre commented Mar 21, 2022

Are you sure about the flag? If the error you get is still cannot find -lGLEW, it likely means that you are still getting the -DLINUX flag. Otherwise, with the correct -DMINGW flag (which is set when MINGW_PREFIX is detected) you wouldn't have -lGLEW in the gcc command (see your first post), but you would have -lglew32 instead, and the error should be resolved.

I really don't know what's going on on your system, but we can try a workaround. Edit src/Makefile, and enter this line at the very top: MINGW_PREFIX=/mingw64 (above the line ifdef MINGW_PREFIX). Then compile again, and let me know the outcome.

EDIT:
Another thing that may have caused the problem is the failure of the LUAVER automatic detection, notified by this error:
process_begin: CreateProcess(NULL, lua -e "print(string.match(_VERSION, \"%d+%.%d+\") or \"5.3\")", ...) failed. Makefile:15: pipe: Bad file descriptor.

If this is actually the culprit, the problem should be solved by just commenting out line 14 in src/Makefile, i.e. by just adding a leading '#' like so:
#LUAVER?=$(shell lua -e 'print(string.match(_VERSION, "%d+%.%d+") or "5.3")'),
and possibly passing the LUAVER at command line if you use a version other than the default 5.3.

Again, let me know if this works. In case, I'll have to fix the makefile in the main branch (and also the makefiles of the other libraries...). Thank you

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

No branches or pull requests

2 participants