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

MSYS2 make fails #325

Open
imfatant opened this issue Sep 25, 2021 · 31 comments
Open

MSYS2 make fails #325

imfatant opened this issue Sep 25, 2021 · 31 comments

Comments

@imfatant
Copy link

I'm trying to build GLEW using mingw64 in MSYS2. I'm simply typing make in the base GLEW directory:

Anthony@DESKTOP-AJTH7MU MINGW64 ~/git/glew
$ make
mkdir lib
make: *** No rule to make target 'src/glew.c', needed by 'tmp/mingw/default/shared/glew.o'.  Stop.

Any idea what's wrong?

@imfatant
Copy link
Author

imfatant commented Sep 26, 2021

Well, one of the things that's wrong is that ~/git/glew/src/glew.c doesn't exist. The only file in that directory is visualinfo.c. Not sure how that helps me though.

@imfatant
Copy link
Author

imfatant commented Sep 26, 2021

So, my mistake was not to run make in ~/git/glew/auto first. Now, the original make progresses a little further. It builds libglew32.a, but then does this:

C:\msys64\mingw64\bin\ar.exe: creating lib/libglew32.a
strip -x lib/libglew32.a
gcc -fno-builtin -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -fno-builtin -fno-stack-protector  -o tmp/mingw/default/shared/glewinfo.o -c src/glewinfo.c
gcc -fno-builtin -O2 -Wall -W -Iinclude -fno-builtin -fno-stack-protector -o bin/glewinfo.exe tmp/mingw/default/shared/glewinfo.o -Llib  -lglew32 -L/mingw/lib -nostdlib -lopengl32 -lgdi32 -luser32 -lkernel32
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x19): undefined reference to `__mingw_vfprintf'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x86): undefined reference to `strlen'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x13e): undefined reference to `strlen'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x168): undefined reference to `fflush'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x7956): undefined reference to `strlen'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25b80): undefined reference to `__mingw_vsscanf'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25c14): undefined reference to `strcmp'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25c27): undefined reference to `strcmp'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25c4a): undefined reference to `strcmp'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25c7b): undefined reference to `strcmp'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25c9e): undefined reference to `strcmp'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25ccb): more undefined references to `strcmp' follow
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25d10): undefined reference to `strtol'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25d4b): undefined reference to `strcmp'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25d5e): undefined reference to `strcmp'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25d8b): undefined reference to `strcmp'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25ddb): undefined reference to `memset'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x25eb7): undefined reference to `memset'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text+0x79a4): undefined reference to `fflush'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0x14): undefined reference to `__main'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0x87): undefined reference to `fopen'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0x8e): undefined reference to `__imp___acrt_iob_func'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0xddd): undefined reference to `fclose'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0xdf9): undefined reference to `__imp___acrt_iob_func'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0xe25): undefined reference to `__imp___acrt_iob_func'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0xe4e): undefined reference to `__imp___acrt_iob_func'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:181: bin/glewinfo.exe] Error 1

@nigels-com
Copy link
Owner

Try without -nostdlib

@nigels-com
Copy link
Owner

Note to self: Also Issue #242

@nigels-com
Copy link
Owner

nigels-com commented Sep 26, 2021

@imfatant Of interest here - what is the output for you of the following command?

$ ./config/config.guess

Also, based on Issue #223 worth trying:

$ make SYSTEM=msys-win64

@imfatant
Copy link
Author

imfatant commented Sep 26, 2021

@nigels-com I have:

$ ./config/config.guess
x86_64-pc-mingw64

Also:

$ make SYSTEM=msys-win64
gcc -DGLEW_NO_GLU -DGLEW_BUILD -mtune=generic -O2 -Wall -W -Wno-cast-function-type -Iinclude -D_WIN32 -fno-builtin -fno-stack-protector -m64  -o tmp/msys-win64/default/shared/glew.o -c src/glew.c
gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a    -o bin/glew32.dll tmp/msys-win64/default/shared/glew.o -m64 -lopengl32 -lgdi32 -luser32 -lkernel32
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/msys-win64/default/shared/glew.o:glew.c:(.text+0x16af0): multiple definition of `DllMainCRTStartup'; C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/../lib/dllcrt2.o:C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtdll.c:148: first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:123: bin/glew32.dll] Error 1

How can I change the Makefile such that -nostdlib is not used?

@imfatant
Copy link
Author

imfatant commented Sep 26, 2021

OK, removed -nostdlib from ~/git/glew/config/Makefile.mingw. Everything works now. Thanks :)

@imfatant imfatant reopened this Sep 28, 2021
@nigels-com
Copy link
Owner

Intention is to make x86_64-pc-mingw64 work out of the box?

@imfatant
Copy link
Author

Not sure what the intention is. I now get a different error. Perhaps I changed my environment? Or did you change something?

make: *** No rule to make target 'bin', needed by 'glew.lib.shared'. Stop.

@imfatant
Copy link
Author

imfatant commented Sep 28, 2021

Now I'm getting:

make
gcc -fno-builtin -DGLEW_NO_GLU -DGLEW_BUILD -O2 -Wall -W -Iinclude -fno-builtin -fno-stack-protector  -o tmp/mingw/default/shared/glew.o -c src/glew.c
In file included from src/glew.c:55:
include/GL/glxew.h:98:10: fatal error: X11/Xlib.h: No such file or directory
   98 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:138: tmp/mingw/default/shared/glew.o] Error 1

Weird that I'm being asked for X11.

Yes, intention would be to make x86_64-pc-mingw64 work.

make SYSTEM=msys-win64
make: *** No rule to make target 'bin', needed by 'glew.lib.shared'.  Stop.

EDIT: OK, it works again now. I had accidentally modified my environment (I'm currently playing with MSYS2, Cygwin and WinLibs mingw-w64 , and getting mixed up). I see that in glew/Makefile, it's matching with 'mingw' and calling that makefile specifically (which I modify by removing the -nostdlib option) . Not sure whether this is what is intended. It isn't msys-win64, certainly.

@nigels-com
Copy link
Owner

Any suggested refinements to the explanation at:
https://github.com/nigels-com/glew#msys2mingw-w64

?

@Tiffas
Copy link

Tiffas commented Apr 23, 2022

Hi ! I have run into the exact same pipeline of problems ^^ Unfortunately removing -nostdlib from Makefile.mingw did not change the multiple definition of DllMainCRTStartup. I am a little confuse on why modifying Makefile.mingw if the SYSTEM is msys-win64 ?

@Tiffas
Copy link

Tiffas commented Apr 23, 2022

It is becoming funnier, simply made a make clean and try to rerun make SYSTEM=mys-win64 got the exact same

mingw32-make.exe SYSTEM=msys-win64
mkdir lib
mingw32-make: *** No rule to make target 'bin', needed by 'glew.lib.shared'.  Stop.

@imfatant how did you solve this problem ?

@FrostKiwi
Copy link

Wanted to report the same problem.
Statically compiling glew from source with MSYS2+MinGW64 for years now. There are some compile warnings, which kinda annoy me, so I wanted to check if the latest git master solves this.

src/glew.c: In function '_glewStrSame1':
src/glew.c:256:29: warning: the comparison will always evaluate as 'true' for the pointer operand in '*a + (sizetype)i' must not be NULL [-Waddress]
  256 |     while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;

I was surprised to find no glew.c, eglew.h, glew.h, glxew.h and wglew.h existing in this repo, whereas they do exist in the source tar balls linked on the home page and the repo readme. As documented , you have to generate the source files yourself.

But that process fails with the exact same errors as @Tiffas reported.
make -> make: *** No rule to make target 'src/glew.c', needed by 'tmp/mingw/default/shared/glew.o'. Stop.
make SYSTEM=msys-win64 -> make: *** No rule to make target 'bin', needed by 'glew.lib.shared'. Stop.

So I give up and just use the linked source zip.

@nigels-com
Copy link
Owner

So I give up and just use the linked source zip.

There is another option: Perlmint/glew-cmake

@nigels-com
Copy link
Owner

nigels-com commented Sep 8, 2022

If you could file a ticket for the compiler warnings, happy to deal with those if they're straight-forward.
They sound like something possibly resolved recently.

@FrostKiwi
Copy link

There is another option: Perlmint/glew-cmake

Ohh, that's nice. Autogenerated in a repo. That solves it for me :]

If you could file a ticket for the compiler warnings, happy to deal with those if they're straight-forward. They sound like something possibly resolved recently.

will do so

@JFSF
Copy link

JFSF commented Sep 13, 2022

I've exactly the same problem here....

Trying to compile/build GLEW from source. Using MinGW-W64, Windows 11 Pro 64-bits.

It seems to compile everything fine. When it comes to linking it does blew up...

mkdir lib
mkdir bin
gcc -DGLEW_NO_GLU -DGLEW_BUILD -mtune=generic -O2 -Wall -W -Wno-cast-function-type -Iinclude -D_WIN32 -fno-builtin -fno-stack-protector -m64 -o tmp/msys-win64/default/shared/glew.o -c src/glew.c
gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o bin/glew32.dll tmp/msys-win64/default/shared/glew.o -m64 -lopengl32 -lgdi32 -luser32 -lkernel32
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tmp/msys-win64/default/shared/glew.o:glew.c:(.text+0x16a40): multiple definition of `DllMainCRTStartup'; C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/lib/../lib/dllcrt2.o:C:/crossdev/src/mingw-w64-v8-git/mingw-w64-crt/crt/crtdll.c:158: first defined here
collect2.exe: error: ld returned 1 exit status
Makefile:124: recipe for target 'bin/glew32.dll' failed
make: *** [bin/glew32.dll] Error 1

So, if we look at the message we can see that the problem resides with multiple definition of `DllMainCRTStartup'.

Open to sugestions

@JFSF
Copy link

JFSF commented Sep 14, 2022

After revising the whole process i has able to build the files from sourcce using MSYS-MSYS2.

The funniest thing about this is that there's a step missing in the documentation that makes the difference.

After downloading the source file (I always prefer TGZ files), expanded the file I run the command line:

make clean
make SYSTEM=msys-Win64
make install
make install.all

After a while it builds everything from source like a charm. The missing part in the doumentation is that you should run these commands from MSYS2 MSYS shortcut and not MSYS2 MINGW64 like i did before.

Just to be sure that glew32.dll is 64-bits i run a small utility to read the signature of file. It confirms to be PE32+ (x64).

image

So, in my case this situation is closed.

@nigels-com
Copy link
Owner

Ah! Interesting! Thanks!

@FrostKiwi
Copy link

make clean
make SYSTEM=msys-Win64
make install
make install.all

After a while it builds everything from source like a charm. The missing part in the doumentation is that you should run these commands from MSYS2 MSYS shortcut and not MSYS2 MINGW64 like i did before.

Huh, no dice for me.
Tried both the pure MSYS2 environment as well as the MSYS2 MinGW64 environment, with make, SYSTEM=msys-Win64, SYSTEM=msys and all the combinations of those.
Always results in the same: make: *** No rule to make target 'bin', needed by 'glew.lib.shared'. Stop.

@JFSF
Copy link

JFSF commented Sep 15, 2022

After make clean try:

mkdir bin

(The make clean command removes some folders (bin, tmp, lib) and the Makefile does not create the bin folder itself...)

then all the remaining ommands.... I'm sure that it will work

@FrostKiwi
Copy link

(The make clean command removes some folders (bin, tmp, lib) and the Makefile does not create the bin folder itself...)

w... why? The Makefiles should totally create every folder needed :S

This indeed clears the missing bin folder error, however, we are back to square one.
Tired pure MSYS Environement and MinGW64 environemtn with both make SYSTEM=msys-Win64, make SYSTEM=msys after cleaning and mkdir bin.
All result in the same:
make: *** No rule to make target 'src/glew.c', needed by 'tmp/msys/default/shared/glew.o'. Stop.

@JFSF
Copy link

JFSF commented Sep 15, 2022

Well, i'm just writting my experience in order to help the others... In my case i downloaded the source in tgz format, and run the commands in the order above... I'm not very found of makefiles... but my guess is that make clean should not remove the folders itself but it's content.

I'll make some _experiments here and comment the results.

@FrostKiwi
Copy link

In my case i downloaded the source in tgz format

Ohhhhh. I missed that part. I pulled the master branch, which does not contain the source files. The makefiles should generate the source as per doc, after which the actual library should be built.
That source file generation is broken on MSYS. So luckily, it's not a works on my machine situation, but a more underlying issue.

@JFSF
Copy link

JFSF commented Sep 15, 2022

Compiling the snapshoot (glew-2.2.0.tgz) out-of-the box with MSYS2-MINGW64:

image

make clean

image

Like i said, the folders bin, tmp, lib and the file glew.c are removed by the command make clean

make SYSTEM=msys-Win64

image

create the folder bin:

image

make SYSTEM=msys-Win64

image

no dice.... Like i told in the beginning this is MSYS2-MINGW64.... let's try with MSYS2-MSYS

image

It does works....

make install

image

make install.all

image

Everything is fine....
Let's see the content of bin, lib folders...

image
image

Now let's check the PE signature of glew32.dll file....

image

... We got a winner....

@utopic-releases
Copy link

I've just make a little modification to the Makefile in order to create the bin folder for us if we run the make clean command...

Please note that since i'm using Windows you may need to check the syntaxt to find the path.

image

Hope that my experiments can help close this issue...

@FrostKiwi
Copy link

Compiling the snapshoot (glew-2.2.0.tgz) out-of-the-box

(But the same process does not work for the git repo)

same compile steps, pure MSYS2 environemnt, but from the repo

image

@JFSF
Copy link

JFSF commented Sep 16, 2022

You are right.

For that reason I mentioned to download the source files from the TGZ file

@dimitre
Copy link

dimitre commented Feb 13, 2023

same issue here, on macOS

@JFSF
Copy link

JFSF commented Feb 17, 2023

It seems that Nigel didn't look yet at this matter....

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

7 participants