Glut in Cygwin almost works

17 views
Skip to first unread message

Roger Kaufman

unread,
Oct 1, 2024, 2:41:51 PM10/1/24
to anti...@googlegroups.com
Hi Adrian,

I hope all is well.

I had pretty much decimated my Cygwin 64 build but I didn't uninstall
it. I found it useful in Windows because its bash shell can change to
any directory in my system. Where as WSL is confined to local drives
(there may be a way to mount network drives but I'm still research it).

Anyway, while I put the latest antiprism on an up to date Cygwin 64 and
tried to make the static exe files for Cygwin. It all compiles without a
hitch except for of course glut, our familiar problem. I get the error
statements below.

From what I'm reading there, there is someone who has explained whey we
allways get the __imp (2 dashes) problem. If I understand this, it is
when the glut is compiled for Cygwin some microsoft tool adds another
underscore to its library names. He mentions what he think should work
but he never follows up on it. I think our former solution was to
compile our own glut, and I have throws that away. But it seems things
are very close for getting build just to work with built in libraries
for any who wants to do it.

https://stackoverflow.com/questions/18816323/cygwin-opengl-compiling-returns-undefined-references-to-imp-iob

What do you think?

Roger

make[2]: Entering directory '/home/Roger/antiprism_addons/aview'
/bin/sh ../libtool  --tag=CXX   --mode=link x86_64-w64-mingw32-g++ -W
-Wall -Wextra  -static -static-libgcc -static-libstdc++ -Wl,-Bstatic
-lstdc++ -lpthread   -g -O2   -o antiview.exe antiview-antiview.o
antiview-vw_glut.o libantiprism_dispgl.la ../base/libantiprism.la -lglut
-lwinmm -lgdi32 -lglu32 -lopengl32 -lm -lm  -lm -lm  -lm -lm
libtool: link: x86_64-w64-mingw32-g++ -W -Wall -Wextra -static-libgcc
-static-libstdc++ -Wl,-Bstatic -g -O2 -o antiview.exe
antiview-antiview.o antiview-vw_glut.o  -lstdc++ -lpthread
./.libs/libantiprism_dispgl.a ../base/.libs/libantiprism.a -lglut
-lwinmm -lgdi32 -lglu32 -lopengl32
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-antiview.o: in function `glutInit_ATEXIT_HACK':
/usr/x86_64-w64-mingw32/sys-root/mingw/include/GL/freeglut_std.h:620:(.text.startup+0xd1):
undefined reference to `__imp___glutInitWithExit'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-antiview.o: in function `main':
/home/Roger/antiprism_addons/aview/antiview.cc:213:(.text.startup+0xdc):
undefined reference to `__imp_glutInitDisplayMode'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-antiview.o: in function `glutCreateWindow_ATEXIT_HACK':
/usr/x86_64-w64-mingw32/sys-root/mingw/include/GL/freeglut_std.h:622:(.text.startup+0xf4):
undefined reference to `__imp___glutCreateWindowWithExit'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-antiview.o: in function `main':
/home/Roger/antiprism_addons/aview/antiview.cc:216:(.text.startup+0x106):
undefined reference to `__imp_glutInitWindowSize'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/antiview.cc:217:(.text.startup+0x116):
undefined reference to `__imp_glutInitWindowPosition'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/antiview.cc:220:(.text.startup+0x129):
undefined reference to `__imp_glutDisplayFunc'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/antiview.cc:221:(.text.startup+0x136):
undefined reference to `__imp_glutIdleFunc'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/antiview.cc:222:(.text.startup+0x143):
undefined reference to `__imp_glutReshapeFunc'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/antiview.cc:223:(.text.startup+0x150):
undefined reference to `__imp_glutMouseFunc'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/antiview.cc:224:(.text.startup+0x15d):
undefined reference to `__imp_glutKeyboardFunc'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/antiview.cc:225:(.text.startup+0x16a):
undefined reference to `__imp_glutSpecialFunc'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/antiview.cc:226:(.text.startup+0x177):
undefined reference to `__imp_glutMotionFunc'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/antiview.cc:238:(.text.startup+0x4d1):
undefined reference to `__imp_glutMainLoop'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-vw_glut.o: in function `glutCreateMenu_ATEXIT_HACK':
/usr/x86_64-w64-mingw32/sys-root/mingw/include/GL/freeglut_std.h:624:(.text+0x54b):
undefined reference to `__imp___glutCreateMenuWithExit'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-vw_glut.o: in function `glut_state::make_menu()':
/home/Roger/antiprism_addons/aview/vw_glut.cc:43:(.text+0x55a):
undefined reference to `__imp_glutAddMenuEntry'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/vw_glut.cc:61:(.text+0x653):
undefined reference to `__imp_glutAddSubMenu'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
/home/Roger/antiprism_addons/aview/vw_glut.cc:64:(.text+0x685):
undefined reference to `__imp_glutAttachMenu'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-vw_glut.o: in function `glut_idle_cb()':
/home/Roger/antiprism_addons/aview/vw_glut.cc:369:(.text+0x97d):
undefined reference to `__imp_glutPostRedisplay'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-vw_glut.o: in function `display_cb()':
/home/Roger/antiprism_addons/aview/vw_glut.cc:395:(.text+0x9d6):
undefined reference to `__imp_glutSwapBuffers'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-vw_glut.o: in function `reshape_cb(int, int)':
/home/Roger/antiprism_addons/aview/vw_glut.cc:414:(.text+0xabf):
undefined reference to `__imp_glutPostRedisplay'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-vw_glut.o: in function `motion_cb(int, int)':
/home/Roger/antiprism_addons/aview/vw_glut.cc:358:(.text+0xc10):
undefined reference to `__imp_glutPostRedisplay'
/usr/lib/gcc/x86_64-w64-mingw32/12/../../../../x86_64-w64-mingw32/bin/ld:
antiview-vw_glut.o: in function `keyboard_cb(unsigned char, int, int)':
/home/Roger/antiprism_addons/aview/vw_glut.cc:287:(.text+0x1623):
undefined reference to `__imp_glutPostRedisplay'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:511: antiview.exe] Error 1
make[2]: Leaving directory '/home/Roger/antiprism_addons/aview'
make[1]: *** [Makefile:512: all-recursive] Error 1
make[1]: Leaving directory '/home/Roger/antiprism_addons'
make: *** [Makefile:419: all] Error 2

Adrian Rossiter

unread,
Oct 4, 2024, 12:54:50 AM10/4/24
to anti...@googlegroups.com
Hi Roger

On Tue, 1 Oct 2024, Roger Kaufman wrote:
> From what I'm reading there, there is someone who has explained whey we
> allways get the __imp (2 dashes) problem. If I understand this, it is when
> the glut is compiled for Cygwin some microsoft tool adds another underscore
> to its library names. He mentions what he think should work but he never
> follows up on it. I think our former solution was to compile our own glut,
> and I have throws that away. But it seems things are very close for getting
> build just to work with built in libraries for any who wants to do it.
>
> https://stackoverflow.com/questions/18816323/cygwin-opengl-compiling-returns-undefined-references-to-imp-iob
>
> What do you think?

What command line are you using to run 'configure'?

Adrian.
--
Adrian Rossiter - adr...@antiprism.com
http://www.instagram.com/adrian_rossiter
http://antiprism.com/adrian

Roger Kaufman

unread,
Oct 4, 2024, 7:25:04 AM10/4/24
to anti...@googlegroups.com
Hi Adrian,

On 10/4/2024 3:54 AM, Adrian Rossiter wrote:
> What command line are you using to run 'configure'?

I have a script that constructs a configure statement for each platform
and build directory.

In native Ubuntu I have freeglut 3.4.0 libraries crossed compiled.

CXX="x86_64-w64-mingw32-g++ -W -Wall -Wextra
-I/home/roger/freeglut-3.4.0/include
-L/home/roger/freeglut-3.4.0/cross-woe/lib -DFREEGLUT_STATIC -static
-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread"
./configure --host=x86_64-w64-mingw32 --with-freeglut

In Cygwin64 I fixed the problem by specifying  -lglut32.dll in the
compiler statement, nothing more

CXX="x86_64-w64-mingw32-g++ -W -Wall -Wextra -lglut.dll -static
-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread"
./configure --host=x86_64-w64-mingw32

Roger

P.S. Something has happened that affects the cross compile of freeglut.
I discovered it when I was testing 3.6.0, but it affects 3.4.0 as well.

Now with a fresh build of freeglut, antiview won't be compiled because
it fails here...

checking for main in -lfreeglut... no

Fortunately I saved 3.4.0 directory from the previous build and I did a
diff check. Nothing is missing, the only difference is all the binaries.

If there is something I can check for you, I can.



Adrian Rossiter

unread,
Oct 4, 2024, 11:02:38 PM10/4/24
to Antiprism List
Hi Roger

On Fri, 4 Oct 2024, Roger Kaufman wrote:
> On 10/4/2024 3:54 AM, Adrian Rossiter wrote:
>> What command line are you using to run 'configure'?
>
> I have a script that constructs a configure statement for each platform and
> build directory.
>
> In native Ubuntu I have freeglut 3.4.0 libraries crossed compiled.
>
> CXX="x86_64-w64-mingw32-g++ -W -Wall -Wextra
> -I/home/roger/freeglut-3.4.0/include
> -L/home/roger/freeglut-3.4.0/cross-woe/lib -DFREEGLUT_STATIC -static
> -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread"
> ./configure --host=x86_64-w64-mingw32 --with-freeglut
...
> P.S. Something has happened that affects the cross compile of freeglut. I
> discovered it when I was testing 3.6.0, but it affects 3.4.0 as well.
>
> Now with a fresh build of freeglut, antiview won't be compiled because it
> fails here...
>
> checking for main in -lfreeglut... no
>
> Fortunately I saved 3.4.0 directory from the previous build and I did a diff
> check. Nothing is missing, the only difference is all the binaries.

Here is message that summarises a previous discussion about switches

https://groups.google.com/g/antiprism/c/FRiuV5g7Fsk/m/TOMSuiX6EQAJ

In which case, you could try using -D_WIN32, and, after cross-compiling
freeglut, make sure that the static library has been renamed to
libfreeglut.a and is in the library lookup path.

Roger Kaufman

unread,
Oct 7, 2024, 6:38:40 PM10/7/24
to anti...@googlegroups.com
Hi Adrian,

On 10/5/2024 2:02 AM, Adrian Rossiter wrote:
>
> Here is message that summarises a previous discussion about switches
>
> https://groups.google.com/g/antiprism/c/FRiuV5g7Fsk/m/TOMSuiX6EQAJ
>
> In which case, you could try using -D_WIN32, and, after cross-compiling
> freeglut, make sure that the static library has been renamed to
> libfreeglut.a and is in the library lookup path.
>

Thanks for the reminder. It looks like left that discussion dangling.

I have attached the python script I use for this. I've lost the source
page where I found switches that are used for cross compiling, but I
thought I read that this is what cmake generates, so I used these.

What is tackled is what I need to work for builds that include antiview.
Those are

- a cross compile build in Cygwin which generates exe files. It requires
the extra libraries in /usr/local/bin which has been documented.
- a dynamic build in native Ubuntu which only requires the antiprism
libraries. (but the receiving platform must have run time glut libraries
for antiview)
- a cross compile build in native Ubuntu which generates exe files. It
requires no libraries. (but makes larger files)

The builds that won't work or don't produce antiview follow. Getting
them to work is not necessary and is academic (from my standpoint).

Cygwin. The config fails on both dynamic and static. I believe that used
to require cygwin1.dll(?) present. I'm not sure if this is any longer
possible.
Ubuntu dynamic. Copying the dynamic libglut.dll to the required name
doesn't seem to work as it does in the cross-woe lib.
Ubuntu static. This seems to be paradoxical, trying to use g++ but still
have a cross compiled glut. This is combination is most likely wrong.

One further note. In WSL2 I don' t have any graphics oriented things
installed because I want to keep the installation small. So I generate
antiprism as dynamic, but I have a cross compiled standalone
antiview.exe also generated. This all works nicely.

Roger



antimake.zip
Reply all
Reply to author
Forward
0 new messages