Skip to content

Build failure on MacOS #5

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

Closed
mohawk2 opened this issue May 10, 2022 · 52 comments
Closed

Build failure on MacOS #5

mohawk2 opened this issue May 10, 2022 · 52 comments

Comments

@mohawk2
Copy link
Contributor

mohawk2 commented May 10, 2022

https://gist.githubusercontent.com/oalders/bf99678279926568fdd02d574705489d/raw/bb556d5652585558f89e53c0c03bbf20971b60c1/gistfile1.txt shows:

In file included from GLUT.xs:550:
In file included from ./gl_util.h:27:
./glext_procs.h:9886:9: warning: 'GL_TRIANGLE_STRIP_ADJACENCY_EXT' macro redefined [-Wmacro-redefined]
#define GL_TRIANGLE_STRIP_ADJACENCY_EXT   0x000D
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/glext.h:1120:9: note: previous definition is here
#define GL_TRIANGLE_STRIP_ADJACENCY_EXT                      0xD
        ^
In file included from GLUT.xs:550:
In file included from ./gl_util.h:27:
./glext_procs.h:10915:21: error: conflicting types for 'glTexParameterIivEXT'
GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params);
                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/glext.h:3227:13: note: previous declaration is here
extern void glTexParameterIivEXT( GLenum target, GLenum pname, GLint *params );
            ^
In file included from GLUT.xs:550:
In file included from ./gl_util.h:27:
./glext_procs.h:10916:21: error: conflicting types for 'glTexParameterIuivEXT'
GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params);
                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/glext.h:3228:13: note: previous declaration is here
extern void glTexParameterIuivEXT( GLenum target, GLenum pname, GLuint *params );
            ^
@oalders
Copy link

oalders commented May 10, 2022

Summary of my perl5 (revision 5 version 34 subversion 1) configuration:
   
  Platform:
    osname=darwin
    osvers=21.4.0
    archname=darwin-2level
    uname='darwin imac.local 21.4.0 darwin kernel version 21.4.0: mon feb 21 20:34:37 pst 2022; root:xnu-8020.101.4~2release_x86_64 x86_64 '
    config_args='-Dprefix=/Users/olaf/.plenv/versions/5.34.1 -de -Dversiononly -A'eval:scriptdir=/Users/olaf/.plenv/versions/5.34.1/bin''
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-fno-common -DPERL_DARWIN -mmacosx-version-min=12.3 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -DPERL_USE_SAFE_PUTENV'
    optimize='-O3'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=12.3 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='Apple LLVM 13.1.6 (clang-1316.0.21.2)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -mmacosx-version-min=12.3 -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/lib /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/lib /Library/Developer/CommandLineTools/usr/lib /usr/lib
    libs=-lgdbm -ldb
    perllibs=
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=12.3 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under darwin
  Compiled at Mar 21 2022 15:39:00
  @INC:
    /Users/olaf/.plenv/versions/5.34.1/lib/perl5/site_perl/5.34.1/darwin-2level
    /Users/olaf/.plenv/versions/5.34.1/lib/perl5/site_perl/5.34.1
    /Users/olaf/.plenv/versions/5.34.1/lib/perl5/5.34.1/darwin-2level
    /Users/olaf/.plenv/versions/5.34.1/lib/perl5/5.34.1

@mohawk2
Copy link
Contributor Author

mohawk2 commented May 11, 2022

The key difference between your setup and mine is that OpenGL::GLUT's Makefile.PL on mine finds "FREEGLUT", while yours finds AGL (near the top of the gist). That's Homebrew (I think Free)GLUT, which also pulls in a dependency on XQuartz. Since it's too much to ask for you to install Homebrew, FreeGLUT, and XQuartz, it looks to me like I need to get it working on AGL (the Apple-supplied OpenGL and GLUT), which really ought to work anyway. I'm actually a little baffled that's even really a "thing", but the Perl OpenGL stuff last got worked on about 10 years ago, and I suspect the MacOS world has improved its availability of OpenGL/GLUT since.

@d-lamb
Copy link

d-lamb commented Sep 11, 2024

When I build PDL 2.090 (and prior versions as well) on my Mac, during the Makefile.PL stage I get warnings:

Warning (mostly harmless): No library found for -lAGL.framework
Warning (mostly harmless): No library found for -lOpenGL.framework

I think it comes from OpenGL-GLUT's Makefile.PL. In addition to the "improved availability" mentioned above, it's likely that the frameworks have moved around substantially on MacOS since that Makefile.PL was written. See for example the question, answer, and updated answers to this Stack Overflow question (which is about the headers, not the libraries). I'm not using the OpenGL or PDL::Graphics::TriD so this is not too important to me, but since I did the digging I figured I'd post the links here so that they are easily found later.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Sep 11, 2024

Thank you for making the effort! I haven't forgotten about this issue.

@goosh-gh
Copy link

I fail to compile OpenGL::GLUT.
My environment FYI: Mac mini 2023, Apple M2 Pro, MacOSX Sequoia 15.2, Macport 2.10.5, Xcode 16.2
Complete log while compile is attached. I hope this helps this module more used for more users...
make.log.plain.txt

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 10, 2025

@oalders @d-lamb @goosh-gh I've just released 0.7201, which incorporates the fix in Perl-GPU/OpenGL-GLUT#11 and I think should fix this for all of you. Could you please try it, and say here whether it did in fact work for you?

@goosh-gh
Copy link

Sorry for a long reply, hoping this helps you!!

  1. On a machine with macOS14.3.1(24D70, Sequoia), Xcode16.2, MacPorts2.10.5, perl5.34 (yes, still with Macports ...) :
    Make finishes after many warnings (as usual, including -Wcompound-token-split-by-macro)
    Using interface: FREEGLUT (if assign AGL, perl Makefile.PL ends up with "OS unsupported")
    make test is stuck without returning to the prompt as following:
    bash-5.2# make test
    "/opt/local/bin/perl5.34" -MExtUtils::Command::MM -e 'cp_nonempty' -- GLUT.bs blib/arch/auto/OpenGL/GLUT/GLUT.bs 644
    PERL_DL_NONLAZY=1 "/opt/local/bin/perl5.34" "-Iblib/lib" "-Iblib/arch" test.pl
    Name "OpenGL::Config" used only once: possible typo at test.pl line 1528.
    • stuck here
  1. On a machine with macOS13.7.4(Ventura), Xcode14.3.1(14E300c), MacPorts2.10.5, perl5.34
    Make process is totally same as above.
    bash-5.2# make test
    "/opt/local/bin/perl5.34" -MExtUtils::Command::MM -e 'cp_nonempty' -- GLUT.bs blib/arch/auto/OpenGL/GLUT/GLUT.bs 644
    PERL_DL_NONLAZY=1 "/opt/local/bin/perl5.34" "-Iblib/lib" "-Iblib/arch" test.pl
    Name "OpenGL::Config" used only once: possible typo at test.pl line 1528.
    Use of uninitialized value in pattern match (m//) at test.pl line 1528.

OpenGL Test App (using hires timer)

Using POGL v0.70
OpenGL installation: 4.5 (Compatibility Profile) Mesa 24.3.4
Mesa
llvmpipe (LLVM 19.1.7, 128 bits)

Installed extensions (* implemented in the module):
GL_3DFX_texture_compression_FXT1
GL_AMD_conservative_depth
GL_AMD_draw_buffers_blend
GL_AMD_multi_draw_indirect
GL_AMD_pinned_memory
GL_AMD_query_buffer_object
GL_AMD_seamless_cubemap_per_texture
GL_AMD_shader_stencil_export
GL_AMD_shader_trinary_minmax
GL_AMD_texture_texture4
GL_AMD_vertex_shader_layer
GL_AMD_vertex_shader_viewport_index
GL_ANGLE_texture_compression_dxt3
GL_ANGLE_texture_compression_dxt5
GL_APPLE_packed_pixels
GL_ARB_ES2_compatibility
GL_ARB_ES3_1_compatibility
GL_ARB_ES3_2_compatibility
GL_ARB_ES3_compatibility
GL_ARB_arrays_of_arrays
GL_ARB_base_instance
GL_ARB_blend_func_extended
GL_ARB_buffer_storage
GL_ARB_clear_buffer_object
GL_ARB_clear_texture
GL_ARB_clip_control

  • GL_ARB_color_buffer_float
    GL_ARB_compatibility
    GL_ARB_compressed_texture_pixel_storage
    GL_ARB_compute_shader
    GL_ARB_conditional_render_inverted
    GL_ARB_conservative_depth
    GL_ARB_copy_buffer
    GL_ARB_copy_image
    GL_ARB_cull_distance
    GL_ARB_debug_output
    GL_ARB_depth_buffer_float
    GL_ARB_depth_clamp
  • GL_ARB_depth_texture
    GL_ARB_derivative_control
    GL_ARB_direct_state_access
  • GL_ARB_draw_buffers
    GL_ARB_draw_buffers_blend
    GL_ARB_draw_elements_base_vertex
    GL_ARB_draw_indirect
    GL_ARB_draw_instanced
    GL_ARB_enhanced_layouts
    GL_ARB_explicit_attrib_location
    GL_ARB_explicit_uniform_location
    GL_ARB_fragment_coord_conventions
    GL_ARB_fragment_layer_viewport
  • GL_ARB_fragment_program
  • GL_ARB_fragment_program_shadow
  • GL_ARB_fragment_shader
    GL_ARB_framebuffer_no_attachments
    GL_ARB_framebuffer_object
    GL_ARB_framebuffer_sRGB
    GL_ARB_get_program_binary
    GL_ARB_get_texture_sub_image
    GL_ARB_gl_spirv
    GL_ARB_gpu_shader5
    GL_ARB_gpu_shader_fp64
    GL_ARB_gpu_shader_int64
  • GL_ARB_half_float_pixel
    GL_ARB_half_float_vertex
    GL_ARB_indirect_parameters
    GL_ARB_instanced_arrays
    GL_ARB_internalformat_query
    GL_ARB_internalformat_query2
    GL_ARB_invalidate_subdata
    GL_ARB_map_buffer_alignment
    GL_ARB_map_buffer_range
    GL_ARB_multi_bind
    GL_ARB_multi_draw_indirect
  • GL_ARB_multisample
  • GL_ARB_multitexture
    GL_ARB_occlusion_query
    GL_ARB_occlusion_query2
    GL_ARB_parallel_shader_compile
    GL_ARB_pipeline_statistics_query
  • GL_ARB_pixel_buffer_object
  • GL_ARB_point_parameters
  • GL_ARB_point_sprite
    GL_ARB_polygon_offset_clamp
    GL_ARB_post_depth_coverage
    GL_ARB_program_interface_query
    GL_ARB_provoking_vertex
    GL_ARB_query_buffer_object
    GL_ARB_robust_buffer_access_behavior
    GL_ARB_robustness
    GL_ARB_sample_shading
    GL_ARB_sampler_objects
    GL_ARB_seamless_cube_map
    GL_ARB_seamless_cubemap_per_texture
    GL_ARB_separate_shader_objects
    GL_ARB_shader_atomic_counter_ops
    GL_ARB_shader_atomic_counters
    GL_ARB_shader_ballot
    GL_ARB_shader_bit_encoding
    GL_ARB_shader_clock
    GL_ARB_shader_draw_parameters
    GL_ARB_shader_group_vote
    GL_ARB_shader_image_load_store
    GL_ARB_shader_image_size
  • GL_ARB_shader_objects
    GL_ARB_shader_precision
    GL_ARB_shader_stencil_export
    GL_ARB_shader_storage_buffer_object
    GL_ARB_shader_subroutine
    GL_ARB_shader_texture_image_samples
    GL_ARB_shader_texture_lod
    GL_ARB_shader_viewport_layer_array
  • GL_ARB_shading_language_100
    GL_ARB_shading_language_420pack
    GL_ARB_shading_language_include
    GL_ARB_shading_language_packing
  • GL_ARB_shadow
    GL_ARB_spirv_extensions
    GL_ARB_stencil_texturing
    GL_ARB_sync
    GL_ARB_tessellation_shader
    GL_ARB_texture_barrier
  • GL_ARB_texture_border_clamp
    GL_ARB_texture_buffer_object
    GL_ARB_texture_buffer_object_rgb32
    GL_ARB_texture_buffer_range
    GL_ARB_texture_compression
    GL_ARB_texture_compression_bptc
    GL_ARB_texture_compression_rgtc
  • GL_ARB_texture_cube_map
    GL_ARB_texture_cube_map_array
  • GL_ARB_texture_env_add
  • GL_ARB_texture_env_combine
    GL_ARB_texture_env_crossbar
  • GL_ARB_texture_env_dot3
    GL_ARB_texture_filter_anisotropic
    GL_ARB_texture_filter_minmax
  • GL_ARB_texture_float
    GL_ARB_texture_gather
    GL_ARB_texture_mirror_clamp_to_edge
  • GL_ARB_texture_mirrored_repeat
    GL_ARB_texture_multisample
  • GL_ARB_texture_non_power_of_two
    GL_ARB_texture_query_levels
    GL_ARB_texture_query_lod
  • GL_ARB_texture_rectangle
    GL_ARB_texture_rg
    GL_ARB_texture_rgb10_a2ui
    GL_ARB_texture_stencil8
    GL_ARB_texture_storage
    GL_ARB_texture_storage_multisample
    GL_ARB_texture_swizzle
    GL_ARB_texture_view
    GL_ARB_timer_query
    GL_ARB_transform_feedback2
    GL_ARB_transform_feedback3
    GL_ARB_transform_feedback_instanced
    GL_ARB_transform_feedback_overflow_query
    GL_ARB_transpose_matrix
    GL_ARB_uniform_buffer_object
    GL_ARB_vertex_array_bgra
    GL_ARB_vertex_array_object
    GL_ARB_vertex_attrib_64bit
    GL_ARB_vertex_attrib_binding
  • GL_ARB_vertex_buffer_object
  • GL_ARB_vertex_program
  • GL_ARB_vertex_shader
    GL_ARB_vertex_type_10f_11f_11f_rev
    GL_ARB_vertex_type_2_10_10_10_rev
    GL_ARB_viewport_array
    GL_ARB_window_pos
    GL_ARM_shader_framebuffer_fetch_depth_stencil
    GL_ATI_blend_equation_separate
    GL_ATI_draw_buffers
    GL_ATI_fragment_shader
    GL_ATI_meminfo
    GL_ATI_separate_stencil
    GL_ATI_texture_compression_3dc
    GL_ATI_texture_env_combine3
  • GL_ATI_texture_float
  • GL_ATI_texture_mirror_once
    GL_EXT_EGL_image_storage
    GL_EXT_EGL_image_storage_compression
    GL_EXT_EGL_sync
  • GL_EXT_abgr
  • GL_EXT_bgra
  • GL_EXT_blend_color
    GL_EXT_blend_equation_separate
    GL_EXT_blend_func_separate
    GL_EXT_blend_minmax
  • GL_EXT_blend_subtract
    GL_EXT_compiled_vertex_array
  • GL_EXT_copy_texture
    GL_EXT_debug_label
    GL_EXT_direct_state_access
    GL_EXT_draw_buffers2
    GL_EXT_draw_instanced
    GL_EXT_draw_range_elements
    GL_EXT_fog_coord
    GL_EXT_framebuffer_blit
    GL_EXT_framebuffer_multisample
    GL_EXT_framebuffer_multisample_blit_scaled
  • GL_EXT_framebuffer_object
    GL_EXT_framebuffer_sRGB
    GL_EXT_gpu_program_parameters
    GL_EXT_gpu_shader4
    GL_EXT_memory_object
    GL_EXT_memory_object_fd
    GL_EXT_multi_draw_arrays
    GL_EXT_packed_depth_stencil
    GL_EXT_packed_float
  • GL_EXT_packed_pixels
  • GL_EXT_pixel_buffer_object
    GL_EXT_point_parameters
    GL_EXT_polygon_offset_clamp
    GL_EXT_provoking_vertex
  • GL_EXT_rescale_normal
    GL_EXT_secondary_color
  • GL_EXT_separate_specular_color
    GL_EXT_shader_framebuffer_fetch
    GL_EXT_shader_framebuffer_fetch_non_coherent
    GL_EXT_shader_image_load_formatted
    GL_EXT_shader_integer_mix
  • GL_EXT_shadow_funcs
    GL_EXT_stencil_two_side
  • GL_EXT_stencil_wrap
  • GL_EXT_subtexture
  • GL_EXT_texture
  • GL_EXT_texture3D
    GL_EXT_texture_array
    GL_EXT_texture_buffer_object
    GL_EXT_texture_compression_dxt1
    GL_EXT_texture_compression_latc
    GL_EXT_texture_compression_rgtc
    GL_EXT_texture_compression_s3tc
  • GL_EXT_texture_cube_map
    GL_EXT_texture_edge_clamp
    GL_EXT_texture_env_add
  • GL_EXT_texture_env_combine
  • GL_EXT_texture_env_dot3
  • GL_EXT_texture_filter_anisotropic
    GL_EXT_texture_filter_minmax
    GL_EXT_texture_integer
  • GL_EXT_texture_lod_bias
  • GL_EXT_texture_mirror_clamp
    GL_EXT_texture_object
    GL_EXT_texture_rectangle
    GL_EXT_texture_sRGB
    GL_EXT_texture_sRGB_R8
    GL_EXT_texture_sRGB_RG8
    GL_EXT_texture_sRGB_decode
    GL_EXT_texture_shadow_lod
    GL_EXT_texture_shared_exponent
    GL_EXT_texture_snorm
    GL_EXT_texture_storage
    GL_EXT_texture_swizzle
    GL_EXT_timer_query
    GL_EXT_transform_feedback
  • GL_EXT_vertex_array
    GL_EXT_vertex_array_bgra
    GL_EXT_vertex_attrib_64bit
    GL_IBM_multimode_draw_arrays
  • GL_IBM_rasterpos_clip
    GL_IBM_texture_mirrored_repeat
    GL_INGR_blend_func_separate
    GL_INTEL_shader_atomic_float_minmax
    GL_KHR_blend_equation_advanced
    GL_KHR_blend_equation_advanced_coherent
    GL_KHR_context_flush_control
    GL_KHR_debug
    GL_KHR_no_error
    GL_KHR_parallel_shader_compile
    GL_KHR_robust_buffer_access_behavior
    GL_KHR_robustness
    GL_KHR_texture_compression_astc_ldr
    GL_KHR_texture_compression_astc_sliced_3d
    GL_MESA_framebuffer_flip_y
    GL_MESA_pack_invert
    GL_MESA_shader_integer_functions
    GL_MESA_texture_signed_rgba
    GL_MESA_window_pos
    GL_MESA_ycbcr_texture
    GL_NVX_gpu_memory_info
    GL_NV_ES1_1_compatibility
    GL_NV_alpha_to_coverage_dither_control
  • GL_NV_blend_square
    GL_NV_conditional_render
  • GL_NV_copy_depth_to_color
    GL_NV_copy_image
  • GL_NV_depth_clamp
  • GL_NV_fog_distance
    GL_NV_half_float
  • GL_NV_light_max_exponent
  • GL_NV_packed_depth_stencil
    GL_NV_primitive_restart
    GL_NV_shader_atomic_float
  • GL_NV_texgen_reflection
    GL_NV_texture_barrier
    GL_NV_texture_env_combine4
  • GL_NV_texture_rectangle
    GL_OES_EGL_image
    GL_OES_read_format
    GL_OVR_multiview
    GL_OVR_multiview2
  • GL_S3_s3tc
  • GL_SGIS_generate_mipmap
    GL_SGIS_texture_border_clamp
    GL_SGIS_texture_edge_clamp
  • GL_SGIS_texture_lod
    GL_SUN_multi_draw_arrays

Using POGL v0.7
Using Mipmap
Mesa: error: GL_INVALID_ENUM in glTexParameter(param=GL_NEAREST_MIPMAP_LINEAR)
make: *** [test_dynamic] Segmentation fault: 11

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 10, 2025

@goosh-gh If it's possible to upgrade to Perl 5.40, that should show far fewer warnings, which might let us see warnings which actually matter, since whatever's going wrong here is probably something simple the compiler knows about.

Separately from that, the second case is actually quite good because we should be able to see exactly where it's crashing. Could you look at Perl-GPU/OpenGL-GLUT#8 to see instructions for how to build with -g and run under gdb to get a backtrace? Obviously I want to fix whatever this is. Although quite possibly that Mesa error is the answer.

@goosh-gh
Copy link

goosh-gh commented Mar 10, 2025

Unfortunately, perl5.40.1 using perlbrew does not reduce warning with my environment (e.g. more than 5000 lines with "Wcompound-token-split-by-macro" while make), sorry I do not know the reason.

I tried -d option with the test.pl as follows:
$ PERL_DL_NONLAZY=1 "/Users/my_home/perl5/perlbrew/perls/perl-5.40.1/bin/perl" -d "-Iblib/lib" "-Iblib/arch" test.pl

Loading DB routines from perl5db.pl version 1.80
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main::(test.pl:4): my $stat = perl -v;
DB<1> c 344

OpenGL Test App (using hires timer)

Using POGL v0.7002
OpenGL installation: 4.5 (Compatibility Profile) Mesa 24.3.4
Mesa
llvmpipe (LLVM 19.1.7, 128 bits)

Installed extensions (* implemented in the module):
GL_3DFX_texture_compression_FXT1
. . . . skipped

  • GL_SGIS_texture_lod
    GL_SUN_multi_draw_arrays

Using POGL v0.7002
Using Mipmap
Mesa: error: GL_INVALID_ENUM in glTexParameter(param=GL_NEAREST_MIPMAP_LINEAR)
Signal SEGV at test.pl line 420.
main::ourInit(300, 300) called at test.pl line 1658
Abort trap: 6

. . . Anything else I can do? If we need gdb enabled perl5.40.1, I will newly install it!

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 11, 2025

. . . Anything else I can do? If we need gdb enabled perl5.40.1, I will newly install it!

Yes. The Perl version doesn't matter, don't worry. I'm still asking you to do the steps in the first comment (mine) on Perl-GPU/OpenGL-GLUT#8, and say here what the backtrace is. I requested that in my last comment here. It is still what I am asking.

@goosh-gh
Copy link

After make is finished, with the machine "the second case" above,
$ ggdb perl -ex 'run -Mblib t/01_use.t' ### (well, macports installs gdb as 'ggdb') returned: 
GNU gdb (GDB) 15.1
          several lines skipped here

Reading symbols from perl...


Fatal signal: Floating point exception: 8
----- Backtrace -----
---------------------
A fatal error internal to GDB has been detected, further
debugging is not possible.  GDB will now terminate.

This is a bug, please report it.  For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.

Floating point exception: 8
$ 

(with the "first case", stucked while make test)
$ ggdb perl -ex 'run -Mblib t/01_use.t'

Reading symbols from perl...
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module op.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module perl.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module universal.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module av.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module builtin.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module caretx.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module class.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module deb.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module doio.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module doop.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module dquote.o]
DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module dump.o]


Fatal signal: Floating point exception: 8
----- Backtrace -----
---------------------
A fatal error internal to GDB has been detected, further
debugging is not possible.  GDB will now terminate.

This is a bug, please report it.  For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.

Floating point exception: 8
$

Please tell me how we can proceed/need something else. 
(oops, do I find another thing to be reported?  Please forget/forgive me about it)

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 11, 2025

Apologies, I forgot that MacOS is much better with lldb than with gdb. On that, please do:

lldb perl -o 'run -Mblib test.pl'

Regarding ggdb crashing, that's one to report to MacPorts.

@goosh-gh
Copy link

goosh-gh commented Mar 11, 2025

(using lldb-19 with "the second case")
 ---  skip many lines
Using Mipmap
Mesa: error: GL_INVALID_ENUM in glTexParameter(param=GL_NEAREST_MIPMAP_LINEAR)
Process 63969 stopped
* thread Perl-GPU/OpenGL-GLUT#1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x348)
    frame #0: 0x00000001eff1d164 libGLU.dylib`closestFit(_CGLContextObject*, unsigned int, int, int, int, unsigned int, unsigned int, int*, int*) + 176
libGLU.dylib`closestFit:
->  0x1eff1d164 <+176>: ldr    x8, [x25, #0x348]
    0x1eff1d168 <+180>: ldr    x0, [x25]
    0x1eff1d16c <+184>: add    x2, sp, #0x38
    0x1eff1d170 <+188>: mov    w1, #0xd33
Target 0: (perl) stopped.
Process 63969 launched: '/Users/my_home/perl5/perlbrew/perls/5.40.1-debug/bin/perl' (arm64)
(lldb) bt
* thread Perl-GPU/OpenGL-GLUT#1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x348)
  * frame #0: 0x00000001eff1d164 libGLU.dylib`closestFit(_CGLContextObject*, unsigned int, int, int, int, unsigned int, unsigned int, int*, int*) + 176
    frame Perl-GPU/OpenGL-GLUT#1: 0x00000001eff24214 libGLU.dylib`gluBuild2DMipmapsCTX + 156
    frame Perl-GPU/OpenGL-GLUT#2: 0x0000000103374d94 OpenGL.bundle`XS_OpenGL_gluBuild2DMipmaps_c(cv=<unavailable>) at pogl_glu.xs:470:10 [opt]
    frame Perl-GPU/OpenGL-GLUT#3: 0x00000001000f44a4 perl`Perl_pp_entersub [inlined] Perl_rpp_invoke_xs(cv=0x0000000118076ad0) at inline.h:1193:9 [opt]
    frame Perl-GPU/OpenGL-GLUT#4: 0x00000001000f449c perl`Perl_pp_entersub at pp_hot.c:6495:9 [opt]
    frame Perl-GPU/OpenGL-GLUT#5: 0x000000010005b588 perl`Perl_runops_debug at dump.c:2866:23 [opt]
    frame Perl-GPU/OpenGL-GLUT#6: 0x000000010002dc20 perl`S_run_body(oldscope=1) at perl.c:0 [opt]
    frame Perl-GPU/OpenGL-GLUT#7: 0x000000010002d8d8 perl`perl_run(my_perl=<unavailable>) at perl.c:2780:9 [opt]
    frame Perl-GPU/OpenGL-GLUT#8: 0x0000000100003048 perl`main(argc=<unavailable>, argv=<unavailable>, env=0x000000016fdfea70) at perlmain.c:127:9 [opt]
    frame Perl-GPU/pogl#5: 0x000000018a30bfd8 dyld`start + 2412
(lldb) 

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 13, 2025

As noted in the above-linked commit, all this time glTexParameteri has been getting called with incorrect parameters (see https://registry.khronos.org/OpenGL-Refpages/gl4/html/glTexParameter.xhtml). The commit fixes that.

@goosh-gh
Copy link

I re-downloaded the pogl-master today, and tried using lldb (provided by Apple at /usr/bin/lldb, instead of /opt/local/bin/lldb-19, provided by MacPorts and I used above) with the "second case" machine. The results including back trace follow (looks like basically the same?).

$ lldb --version
lldb-1403.0.17.67
Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)

$ lldb perl -o 'run -Mblib test.pl'
    --- skipped many lines
Using POGL v0.7002
Using Mipmap
Mesa: error: GL_INVALID_ENUM in glTexParameter(param=GL_NEAREST_MIPMAP_LINEAR)
Process 82966 stopped
* thread Perl-GPU/OpenGL-GLUT#1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x348)
    frame #0: 0x00000001eff1d164 libGLU.dylib`closestFit(_CGLContextObject*, unsigned int, int, int, int, unsigned int, unsigned int, int*, int*) + 176
libGLU.dylib`closestFit:
->  0x1eff1d164 <+176>: ldr    x8, [x25, #0x348]
    0x1eff1d168 <+180>: ldr    x0, [x25]
    0x1eff1d16c <+184>: add    x2, sp, #0x38
    0x1eff1d170 <+188>: mov    w1, #0xd33
Target 0: (perl) stopped.
Process 82966 launched: '/Users/my_home/perl5/perlbrew/perls/5.40.1-NoUsrLocal-debug/bin/perl' (arm64)
(lldb) bt
* thread Perl-GPU/OpenGL-GLUT#1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x348)
  * frame #0: 0x00000001eff1d164 libGLU.dylib`closestFit(_CGLContextObject*, unsigned int, int, int, int, unsigned int, unsigned int, int*, int*) + 176
    frame Perl-GPU/OpenGL-GLUT#1: 0x00000001eff24214 libGLU.dylib`gluBuild2DMipmapsCTX + 156
    frame Perl-GPU/OpenGL-GLUT#2: 0x0000000101820d94 OpenGL.bundle`XS_OpenGL_gluBuild2DMipmaps_c(cv=<unavailable>) at pogl_glu.xs:470:10 [opt]
    frame Perl-GPU/OpenGL-GLUT#3: 0x00000001000f4478 perl`Perl_pp_entersub [inlined] Perl_rpp_invoke_xs(cv=0x000000010135a0e8) at inline.h:1193:9 [opt]
    frame Perl-GPU/OpenGL-GLUT#4: 0x00000001000f4470 perl`Perl_pp_entersub at pp_hot.c:6495:9 [opt]
    frame Perl-GPU/OpenGL-GLUT#5: 0x000000010005b55c perl`Perl_runops_debug at dump.c:2866:23 [opt]
    frame Perl-GPU/OpenGL-GLUT#6: 0x000000010002dbf4 perl`S_run_body(oldscope=1) at perl.c:0 [opt]
    frame Perl-GPU/OpenGL-GLUT#7: 0x000000010002d8ac perl`perl_run(my_perl=<unavailable>) at perl.c:2780:9 [opt]
    frame Perl-GPU/OpenGL-GLUT#8: 0x000000010000301c perl`main(argc=<unavailable>, argv=<unavailable>, env=0x000000016fdfe7e8) at perlmain.c:127:9 [opt]
    frame Perl-GPU/pogl#5: 0x000000018a30bfd8 dyld`start + 2412
(lldb) 

Is there anything else I can do to clarify the situation?

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 13, 2025

I re-downloaded the pogl-master today, and tried using lldb (provided by Apple at /usr/bin/lldb, instead of /opt/local/bin/lldb-19, provided by MacPorts and I used above) with the "second case" machine. The results including back trace follow (looks like basically the same?).
[...]
Is there anything else I can do to clarify the situation?

You'll notice you're referring to pogl, a different repo. Its test.pl is similar to the one here, but not identical. I have now copied across the change referred to into the pogl repo, so its master should now pass the tests and install. Then this repo (OpenGL-GLUT) should also. Could I ask you to try both of those and report results? Also, it would help if you can say if it opened a window and showed a spinning cube?

You may think it's confusing and/or redundant to have two similar but not identical things. I do too, and will soon be reunifying them; but I want to get them both working properly first, which involves finding and fixing various bugs. This has included adding error-checking (which you'd think was important in a test program), which caught the wrong enum being passed, since about 2008.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 13, 2025

Another thing I intend to do on MacOS is to get it finding the "frameworks" as Derek highlighted; this is because the current Makefile.PL treats all of the things returned by its lib-finding function should be prefixed with -l, which is wrong, and they should come out prefixed with either -l or -framework as appropriate.

@oalders
Copy link

oalders commented Mar 13, 2025

I think I'm different hardware now, so I tested this on a newer and older iMac and both of them installed cleanly. Both are running 5.40.0

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 19, 2025

Transferring this to pogl, where this module and functionality now live.

@mohawk2 mohawk2 transferred this issue from Perl-GPU/OpenGL-GLUT Mar 19, 2025
@goosh-gh
Copy link

(OpenGL::GLUT master now needs the OpenGL module to be installed, so the following is my try about OpenGL module)

$ pwd
/Users/my_home/.cpan/build/OpenGL-0.7004
$ perl Makefile.PL

run as `perl Makefile.PL help` to show user options
$verbose set to 0 - enable by running as `perl Makefile.PL verbose`

2025-03-22 09:38:11.039 glversion[31392:927762] GLUT Warning: invalid glutGet parameter: 508
This looks like OpenGL Version: 2.1 Metal - 83.1
Found GLUT - Version: 5

Using interface: FREEGLUT

Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for OpenGL
Writing MYMETA.yml and MYMETA.json


$ make; make test;
PERL_DL_NONLAZY=1 "/Users/my_home/perl5/perlbrew/perls/5.40.1-debug/bin/perl" "-Iblib/lib" "-Iblib/arch" test.pl
OpenGL Test App (using hires timer)
make: *** [test_dynamic] Segmentation fault: 11

$ lldb perl -o 'run -Mblib test.pl'
(lldb) target create "perl"
Current executable set to 'perl' (arm64).
(lldb) run -Mblib test.pl

OpenGL Test App (using hires timer)

Process 32807 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3b0)
    frame #0: 0x0000000207d10540 libGL.dylib`glGetString + 12
libGL.dylib`glGetString:
->  0x207d10540 <+12>: ldr    x2, [x8, #0x3b0]
    0x207d10544 <+16>: ldr    x0, [x8]
    0x207d10548 <+20>: braaz  x2

libGL.dylib`glGetTexEnvfv:
    0x207d1054c <+0>:  mov    x3, x2
Target 0: (perl) stopped.
Process 32807 launched: '/Users/my_home/perl5/perlbrew/perls/5.40.1-debug/bin/perl' (arm64)
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3b0)
  * frame #0: 0x0000000207d10540 libGL.dylib`glGetString + 12
    frame #1: 0x0000000100cffa84 V1.bundle`XS_OpenGL_glGetString(cv=<unavailable>) at V1.xs:1617:21 [opt]
    frame #2: 0x00000001000f44a4 perl`Perl_pp_entersub [inlined] Perl_rpp_invoke_xs(cv=0x000000010191f248) at inline.h:1193:9 [opt]
    frame #3: 0x00000001000f449c perl`Perl_pp_entersub at pp_hot.c:6495:9 [opt]
    frame #4: 0x000000010005b588 perl`Perl_runops_debug at dump.c:2866:23 [opt]
    frame #5: 0x000000010002dc20 perl`S_run_body(oldscope=1) at perl.c:0 [opt]
    frame #6: 0x000000010002d8d8 perl`perl_run(my_perl=<unavailable>) at perl.c:2780:9 [opt]
    frame #7: 0x0000000100003048 perl`main(argc=<unavailable>, argv=<unavailable>, env=0x000000016fdff070) at perlmain.c:127:9 [opt]
    frame #8: 0x00000001a1f67fd8 dyld`start + 2412
(lldb) 

While the lldb session, I can see a separate window titled "OpenGL Test App" is successfully opened but it shows nothing

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 27, 2025

@goosh-gh Thank you for sticking with this! I didn't fully spell it out, but will here: OpenGL::GLUT is now just part of this repo, which should simplify things a bit.

The above stacktrace says to me that what's now crashing is nothing to do with GLUT, and is just glGetString crashing. The test.pl calls it:

pogl/test.pl

Line 1624 in ed2bcc3

my $version = glGetString(GL_VERSION);

My latest ask is: can you please run perl -Mblib -MOpenGL=:all -e 'printf "%x\n", GL_VERSION' so we know what value is being passed to glGetString? On many platforms including MacOS it's 0x1F02 (which is 7938 in decimal - EDIT previously I said 498 but this was from some bizarrely inaccurate googling). NOTE the next step only works sensibly if you edit the Makefile to change OPTIMIZE to only -g - higher optimisation makes it hard to print values.

Then, doing lldb as above, could you do after the bt, frame select 1 then p name which should show the same value as the GL_VERSION above. When I see that, I should have a better idea what's going on.

@goosh-gh
Copy link

PBdbg) pwd
/Users/my_home/.cpan/build/OpenGL-0.7004-2
PBdbg) perl Makefile.PL

run as `perl Makefile.PL help` to show user options
$verbose set to 0 - enable by running as `perl Makefile.PL verbose`

2025-03-28 01:00:14.161 glversion[36738:697134] GLUT Warning: invalid glutGet parameter: 508
This looks like OpenGL Version: 2.1 Metal - 83.1
Found GLUT - Version: 5

Using interface: FREEGLUT

Generating a Unix-style Makefile
Writing Makefile for OpenGL
Writing MYMETA.yml and MYMETA.json
PBdbg) vi Makefile
# OPTIMIZE = -O3 -g
 OPTIMIZE = -g
PBdbg) make; make test
 - - - skipped many lines  - - -
PERL_DL_NONLAZY=1 "/Users/my_home/perl5/perlbrew/perls/5.40.1-debug/bin/perl" "-Iblib/lib" "-Iblib/arch" test.pl

OpenGL Test App (using hires timer)

make: *** [test_dynamic] Segmentation fault: 11
PBdbg) lldb perl -o 'run -Mblib test.pl'
(lldb) target create "perl"
Current executable set to 'perl' (arm64).
(lldb) run -Mblib test.pl

OpenGL Test App (using hires timer)

Process 37913 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3b0)
    frame #0: 0x00000001fe49c540 libGL.dylib`glGetString + 12
libGL.dylib`glGetString:
->  0x1fe49c540 <+12>: ldr    x2, [x8, #0x3b0]
    0x1fe49c544 <+16>: ldr    x0, [x8]
    0x1fe49c548 <+20>: braaz  x2

libGL.dylib`glGetTexEnvfv:
    0x1fe49c54c <+0>:  mov    x3, x2
Target 0: (perl) stopped.
Process 37913 launched: '/Users/my_home/perl5/perlbrew/perls/5.40.1-debug/bin/perl' (arm64)
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3b0)
  * frame #0: 0x00000001fe49c540 libGL.dylib`glGetString + 12
    frame #1: 0x0000000100b10880 V1.bundle`XS_OpenGL_glGetString(cv=0x000000010191f248) at V1.xs:1617:21
    frame #2: 0x00000001000f44a4 perl`Perl_pp_entersub [inlined] Perl_rpp_invoke_xs(cv=0x000000010191f248) at inline.h:1193:9 [opt]
    frame #3: 0x00000001000f449c perl`Perl_pp_entersub at pp_hot.c:6495:9 [opt]
    frame #4: 0x000000010005b588 perl`Perl_runops_debug at dump.c:2866:23 [opt]
    frame #5: 0x000000010002dc20 perl`S_run_body(oldscope=1) at perl.c:0 [opt]
    frame #6: 0x000000010002d8d8 perl`perl_run(my_perl=<unavailable>) at perl.c:2780:9 [opt]
    frame #7: 0x0000000100003048 perl`main(argc=<unavailable>, argv=<unavailable>, env=0x000000016fdff070) at perlmain.c:127:9 [opt]
    frame #8: 0x00000001986f3fd8 dyld`start + 2412
(lldb) frame select 1
frame #1: 0x0000000100b10880 V1.bundle`XS_OpenGL_glGetString(cv=0x000000010191f248) at V1.xs:1617:21
   1614		GLenum	name
   1615		CODE:
   1616		{
-> 1617			char * c = (char*)glGetString(name);
   1618			if (c)
   1619				RETVAL = newSVpv(c, 0);
   1620			else
(lldb) p name
(GLenum) $0 = 7938
(lldb) ^D

PBdbg) perl -Mblib -MOpenGL=:all -e 'printf "%x\n", GL_VERSION'
1f02

I am not sure the above process is what you really want. FYI,
$ perl Makefile.PL interface=AGL
fails to detect AGL and default to select freeglut. Even editing the Makefile as follows (which I believe the correct way to use the system frameworks...) does not save me:
LDFLAGS = -mmacosx-version-min=13.7 -fstack-protector-strong -L/usr/local/lib -L/opt/local/lib -F/System/Library/Frameworks -framework AGL -framework OpenGL -framework GLUT

Anything else I can do?

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 27, 2025

@goosh-gh The error you're getting resembles that in https://www.reddit.com/r/opengl/comments/gimkve/comment/fqha41s/ especially the address (0x3b0). That implies that a glewInit-like activity of actually loading values into the function pointers such as glGetString isn't happening.

I note you're using MacPorts, which as discussed elsewhere isn't fantastic at keeping up with the latest versions of things. Are you able to switch to Homebrew, which to my mind is far superior? If not, please can you say what versions you have of:

  • Perl
  • FreeGLUT
  • MacOS
  • XQuartz
  • Mesa

The last one is especially important because I think with FreeGLUT as it currently is (though there's movement to actually support Cocoa, i.e. native MacOS) it uses Mesa, which uses XQuartz and this might be a bug in older Mesa that's now fixed.

But first could you please start over but having installed the latest ExtUtils::MakeMaker? That has fixes for LIBS=-framework ....

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 27, 2025

MacPorts latest is 24.3.4 (https://ports.macports.org/port/mesa/details/).
Homebrew to my surprise is earlier with 24.2.8 (https://formulae.brew.sh/formula/mesa).
Latest Mesa is 25.0.2 (https://www.mesa3d.org/).

Let's see what version we're dealing with on @goosh-gh's system!

@goosh-gh
Copy link

MacPorts base version 2.10.5 installed
MacOS Ventura 13.7.4

$ port info mesa
mesa @24.3.4 (x11, graphics)

$ port info freeglut
freeglut @3.6.0 (x11, graphics)

$ port info xorg-server
xorg-server @1.20.11_1

$ port info p5.34-extutils-makemaker
p5.34-extutils-makemaker @7.720.0 (perl)

$) grep LIBS  Makefile | grep framework
$)  . . . . . nothing returned 

This machine has some old setup, as described above as the "second case".
XQuartz was installed at /opt/X11 via XQuartz-2.8.5.pkg
I tried to compile mesa 25.0.2 by myself but failed currently, may need some more time to get it work.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 27, 2025

That's quite an old version of MacOS - I have 15.3 here. Is it possible at all to try all this code on a newer MacOS version? Or at least, with Homebrew versions of these programs rather than the MacPorts versions?

EDIT And to be clear, you're still getting the same results with the latest EUMM?

@goosh-gh
Copy link

goosh-gh commented Mar 27, 2025

On the "first case" above;

MacOS 15.3.2
MacPorts base version 2.10.5 installed
$ port info mesa
mesa @24.3.4 (x11, graphics)
$ port info freeglut
freeglut @3.6.0 (x11, graphics)
$ port info xorg-server
xorg-server @1.20.11_1 (x11, devel)
$ port info p5.34-extutils-makemaker
p5.34-extutils-makemaker @7.720.0 (perl)
$ pwd
/Users/my_home/.cpan/build/OpenGL-0.7004-0
$ perl Makefile.PL

run as `perl Makefile.PL help` to show user options
$verbose set to 0 - enable by running as `perl Makefile.PL verbose`

2025-03-28 08:44:25.557 glversion[5227:34415] GLUT Warning: invalid glutGet parameter: 508
This looks like OpenGL Version: 2.1 Metal - 89.3
Found GLUT - Version: 5

Using interface: FREEGLUT

Generating a Unix-style Makefile
Writing Makefile for OpenGL
Writing MYMETA.yml and MYMETA.json
$ make test
 - - - skip several lines - - -
PERL_DL_NONLAZY=1 "/Users/my_home/perl5/perlbrew/perls/5.40.1-debug/bin/perl" "-Iblib/lib" "-Iblib/arch" test.pl

stucks here and does not return to the command prompt, so I cannot try lldb here as reported above. But I can examine GL_VERSION after make finished;

$ perl -Mblib -MOpenGL=:all -e 'printf "%x\n", GL_VERSION'
1f02

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 30, 2025

@goosh-gh Could I ask you to try installing OpenGL::Modern on your two machine? That uses GLEW-like semantics and may avoid this problem.

That's partly motivated because PDL is about to switch to using GLFW and OpenGL::Modern, and I aim to switch this distro over to using OpenGL::Modern "under the hood" also, so this will give me early warning of whether these problems will exist in that scenario too.

@goosh-gh
Copy link

Installation of OpenGL::Modern module did not change the situation in both cases.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Mar 31, 2025

Installation of OpenGL::Modern module did not change the situation in both cases.

I don't know what situation you mean. Did OGL:M install OK? Its presence won't (currently) affect how "pogl" (this module) works.

Could I also ask you to see if OpenGL::GLFW installs OK?

@goosh-gh
Copy link

goosh-gh commented Apr 1, 2025

Both OpenGL::Modern and OpenGL::GLFW were successfully installed for both machines (after installing glfw3.3.8 via macports). 'Make test' for OpenGL::GLFW showed an opengl window with a rotating triangle of rainbow color.
Returning to the OpenGL module after these two installs,
the 1st machine (newer OS) stops while 'make test', without returning to the command prompt,
the 2nd machine (old OS, Makefile modified; OPTIMIZE= -g) ends up with segmentation fault 11 after 'make test'.
The lldb session (after make) of the 2nd machine:

PBdbg) lldb perl -o 'run -Mblib test.pl'
(lldb) target create "perl"
Current executable set to 'perl' (arm64).
(lldb) run -Mblib test.pl
OpenGL Test App (using hires timer)   ### I see a new window named "OpenGL Test App"
Process 48006 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3b0)
    frame #0: 0x00000001eed60540 libGL.dylib`glGetString + 12
libGL.dylib`glGetString:
->  0x1eed60540 <+12>: ldr    x2, [x8, #0x3b0]
    0x1eed60544 <+16>: ldr    x0, [x8]
    0x1eed60548 <+20>: braaz  x2

libGL.dylib`glGetTexEnvfv:
    0x1eed6054c <+0>:  mov    x3, x2
Target 0: (perl) stopped.
Process 48006 launched: '/Users/my_home/perl5/perlbrew/perls/5.40.1-debug/bin/perl' (arm64)
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x3b0)
  * frame #0: 0x00000001eed60540 libGL.dylib`glGetString + 12
    frame #1: 0x0000000100c10880 V1.bundle`XS_OpenGL_glGetString(cv=0x0000000102080cf0) at V1.xs:1617:21
    frame #2: 0x00000001000f44a4 perl`Perl_pp_entersub [inlined] Perl_rpp_invoke_xs(cv=0x0000000102080cf0) at inline.h:1193:9 [opt]
    frame #3: 0x00000001000f449c perl`Perl_pp_entersub at pp_hot.c:6495:9 [opt]
    frame #4: 0x000000010005b588 perl`Perl_runops_debug at dump.c:2866:23 [opt]
    frame #5: 0x000000010002dc20 perl`S_run_body(oldscope=1) at perl.c:0 [opt]
    frame #6: 0x000000010002d8d8 perl`perl_run(my_perl=<unavailable>) at perl.c:2780:9 [opt]
    frame #7: 0x0000000100003048 perl`main(argc=<unavailable>, argv=<unavailable>, env=0x000000016fdfed98) at perlmain.c:127:9 [opt]
    frame #8: 0x0000000188fb7fd8 dyld`start + 2412
(lldb) frame select 1
frame #1: 0x0000000100c10880 V1.bundle`XS_OpenGL_glGetString(cv=0x0000000102080cf0) at V1.xs:1617:21
   1614		GLenum	name
   1615		CODE:
   1616		{
-> 1617			char * c = (char*)glGetString(name);
   1618			if (c)
   1619				RETVAL = newSVpv(c, 0);
   1620			else
(lldb) p name
(GLenum) $0 = 7938
(lldb) ^D

PBdbg) perl -Mblib -MOpenGL=:all -e 'printf "%x\n", GL_VERSION'
1f02

FWI, mesa was upgraded to 25.0.2 via macports, and above examinations were done after this upgrade.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Apr 3, 2025

@goosh-gh @HaraldJoerg @shawnlaffan Could I ask you all to try the latest master commit? On my system some misbehaviour seems to have now stopped (MacOS, FreeGLUT using Mesa), and I'd like to see if MacPorts and Linux with NVidia systems work now.

If not, I have a backup plan to drop FreeGLUT's teapot and use a tetrahedron, but let's see if that drastic step is needed.

@HaraldJoerg
Copy link

Sorry, still no luck. pogl 313d08a + freeglut 3.6, both compiled with -g:

(gdb) bt
#0  0x00000000400b0ed4 in ?? ()
#1  0x00007ffff248eabb in ?? () from /lib/x86_64-linux-gnu/libnvidia-glcore.so.535.183.01
#2  0x00007ffff24951fd in ?? () from /lib/x86_64-linux-gnu/libnvidia-glcore.so.535.183.01
#3  0x00007ffff20f4c96 in ?? () from /lib/x86_64-linux-gnu/libnvidia-glcore.so.535.183.01
#4  0x00007ffff6d5bb6f in fghDrawGeometryWire11 (vertices=0x7ffff6dbdf40 <vertsTeapotW>, 
    normals=0x7ffff6db4940 <normsTeapotW>, vertIdxs=0x7ffff6db1740 <vertIdxsTeapotW>, numParts=640, numVertPerPart=10, 
    vertexMode=3, vertIdxs2=0x0, numParts2=0, numVertPerPart2=0)
    at /home/haj/devel/c/freeglut-3.6.0/src/fg_geometry.c:350
#5  0x00007ffff6d5b941 in fghDrawGeometryWire (vertices=0x7ffff6dbdf40 <vertsTeapotW>, 
    normals=0x7ffff6db4940 <normsTeapotW>, numVertices=3200, vertIdxs=0x7ffff6db1740 <vertIdxsTeapotW>, numParts=640, 
    numVertPerPart=10, vertexMode=3, vertIdxs2=0x0, numParts2=0, numVertPerPart2=0)
    at /home/haj/devel/c/freeglut-3.6.0/src/fg_geometry.c:155
#6  0x00007ffff6d6798e in fghTeaset (scale=0.25, useWireMode=1 '\001', cpdata=0x7ffff6d99840 <cpdata_teapot>, 
    patchdata=0x7ffff6d995c0 <patchdata_teapot>, vertIdxs=0x7ffff6db1740 <vertIdxsTeapotW>, 
    verts=0x7ffff6dbdf40 <vertsTeapotW>, norms=0x7ffff6db4940 <normsTeapotW>, texcs=0x0, 
    lastScale=0x7ffff6dc7540 <lastScaleTeapotW>, inited=0x7ffff6dc7544 <initedTeapotW> "\001", needNormalFix=1 '\001', 
    rotFlip=1 '\001', zOffset=1.57500005, nVerts=3200, nInputPatches=10, nPatches=32, nTriangles=0)
    at /home/haj/devel/c/freeglut-3.6.0/src/fg_teapot.c:470
#7  0x00007ffff6d67a97 in glutWireTeapot (size=0.25) at /home/haj/devel/c/freeglut-3.6.0/src/fg_teapot.c:484
#8  0x00007ffff712f232 in XS_OpenGL__GLUT_glutWireTeapot (my_perl=0x55555592f2a0, cv=0x555555c76fc8)
    at lib/OpenGL/GLUT.c:2717
#9  0x00005555556901aa in ?? ()
#10 0x00005555556856de in Perl_runops_standard ()
#11 0x00005555556e0cf4 in ?? ()
#12 0x00005555556856de in Perl_runops_standard ()
#13 0x00005555555c48ea in Perl_call_sv ()
#14 0x00007ffff711a949 in generic_glut_Display_handler () at lib/OpenGL/GLUT.xs:262
#15 0x00007ffff6d583f5 in fghDisplayFuncCallback (userData=0x7ffff711a6e7 <generic_glut_Display_handler>)
    at /home/haj/devel/c/freeglut-3.6.0/src/fg_callbacks.c:166
#16 0x00007ffff6d63033 in fghRedrawWindow (window=0x5555563e20b0) at /home/haj/devel/c/freeglut-3.6.0/src/fg_main.c:133
#17 0x00007ffff6d6392e in fgProcessWork (window=0x5555563e20b0) at /home/haj/devel/c/freeglut-3.6.0/src/fg_main.c:435
#18 0x00007ffff6d630bc in fghcbProcessWork (window=0x5555563e20b0, enumerator=0x7fffffffd7b0)
    at /home/haj/devel/c/freeglut-3.6.0/src/fg_main.c:157
#19 0x00007ffff6d65594 in fgEnumWindows (enumCallback=0x7ffff6d63091 <fghcbProcessWork>, enumerator=0x7fffffffd7b0)
    at /home/haj/devel/c/freeglut-3.6.0/src/fg_structure.c:406
#20 0x00007ffff6d63116 in fghProcessWork () at /home/haj/devel/c/freeglut-3.6.0/src/fg_main.c:172
#21 0x00007ffff6d6396e in glutMainLoopEvent () at /home/haj/devel/c/freeglut-3.6.0/src/fg_main.c:457
#22 0x00007ffff6d63a16 in glutMainLoop () at /home/haj/devel/c/freeglut-3.6.0/src/fg_main.c:489
#23 0x00007ffff7122610 in XS_OpenGL__GLUT_glutMainLoop (my_perl=0x55555592f2a0, cv=0x555555c6c530)
    at lib/OpenGL/GLUT.c:879
#24 0x00005555556901aa in ?? ()
#25 0x00005555556856de in Perl_runops_standard ()
#26 0x00005555555c41db in perl_run ()
#27 0x000055555559963a in main ()
(gdb) 

@goosh-gh
Copy link

goosh-gh commented Apr 3, 2025

I do not have Nvidia/Intel machines.
In 4 cases: 2 OS (Ventura13.7.4 and Sequoia15.3.2) x 2 Perl versions(5.34 and 5.40.1), I got same results:

$ perl ./Makefile.PL
glversion.c:8:10: fatal error: 'GL/freeglut.h' file not found
#include <GL/freeglut.h>
         ^~~~~~~~~~~~~~~
1 error generated.
make: *** [glversion.o] Error 1
get_extensions: could not open utils/glversion.txt: No such file or directory

OS unsupported

$ find /opt/local/ -name freeglut.h 
/opt/local//include/GL/freeglut.h
If I edit utils/glversion.c,
  #include "/opt/local/include/GL/freeglut.h", 
"perl Makefile.PL" ends up with the following message (well, as expected).

ld: library not found for -lglut
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [glversion] Error 1
get_extensions: could not open utils/glversion.txt: No such file or directory

OS unsupported

I think this version presents a good progress,
because in 2 vertual machines (Ubuntu24.10, Debian12.4) via Parallels Desktop,
'make test' showed a rotating half-transparent teapot, well, I am very glad because it is after a pretty long time!
With the latest source of the OpenGL module on the cpan, these two machines report "All tests succeessful" after 'make test', but I cannot see the rotating teapot ("OpenGL Test app" window shows FPS text, though).
These 2 virtual machines successfully installed the module OpenGL::GLFW as well as OpenGL::Modern, FYI.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Apr 3, 2025

Thank you, the tetrahedron it will be then!

@mohawk2
Copy link
Contributor Author

mohawk2 commented Apr 6, 2025

After further recent developments, the latest code apparently started working at least on Linux/NVidia, still with the teapot. I unfortunately discovered those changes had broken things on Windows, but that's now all fixed. The Linux situation required an increase of the test timeout to 8 seconds.

@HaraldJoerg Could you confirm master now works on your system?

@shawnlaffan Could you try the latest, and see if this has fixed things yet?

@goosh-gh I need to fix the build to find your FreeGLUT, but please could you let me know how we're doing across your range of environments?

@HaraldJoerg
Copy link

I can confirm: Master 8ed3e18 works for me. Tests pass, and test.pl shows the animated teapot!

@shawnlaffan
Copy link

Also works on Strawberry Perl 5.40.0.1 and 5.38.0.1.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Apr 6, 2025

Folks, thank you for your rapid feedback! Above all, I'm glad it works.

@goosh-gh I've added the path stuff so your setups should at least get to the failures we saw with gl* functions (particularly the 3b0 stuff). Is that what you now see?

@goosh-gh
Copy link

goosh-gh commented Apr 7, 2025

With the latest master, I cannot reach to make, because 'perl Makefile.PL' fails to write a Makefile on both 2 real (not virtual) machines (the Case1: Sequoia15.4, the Case2: Ventura13.7.4). I tried 2 versions of Perl (perl5.34 via macports and perl5.40.1 via perlbrew) on both cases, the results were the same.

$ perl Makefile.PL

Using interface: FREEGLUT

ld: library not found for -lglut
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [glversion] Error 1
get_extensions: could not open utils/glversion.txt: No such file or directory

OS unsupported
$ perl Makefile.PL interface=AGL

AGL interface requires GLUT.framework
ERROR: no supported interfaces found.

OS unsupported

FYI, I tried to get glversion.txt,

  1. the Case2
$ cd utils; make
cc glversion.o -L/usr/lib -L/usr/X11R6/lib -L/usr/local/lib -L/usr/openwin/lib -L/usr/lib/xorg/modules -L/usr/X11R6/lib/modules -L/usr/lib/xorg/modules/extensions -L/usr/X11R6/lib/modules/extensions -lGL -lglut -lGLU -lXi -lXmu -lXext -lX11 -lm -o glversion
ld: warning: directory not found for option '-L/usr/openwin/lib'
ld: warning: directory not found for option '-L/usr/lib/xorg/modules'
ld: warning: directory not found for option '-L/usr/X11R6/lib/modules'
ld: warning: directory not found for option '-L/usr/lib/xorg/modules/extensions'
ld: warning: directory not found for option '-L/usr/X11R6/lib/modules/extensions'
chmod u+x glversion
./glversion > glversion.txt
$ more glversion.txt
FREEGLUT=30400
GLUT=4
VERSION=2.1 Metal - 83.1
VENDOR=Apple
RENDERER=Apple M2 Max
EXTENSIONS=GL_ARB_color_buffer_float GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_draw_elements_base_vertex GL_ARB_draw_instanced GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_object GL_ARB_framebuffer_sRGB GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_imaging GL_ARB_instanced_arrays GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_provoking_vertex GL_ARB_seamless_cube_map GL_ARB_shader_objects GL_ARB_shader_texture_lod GL_ARB_shading_language_100 GL_ARB_shadow GL_ARB_shadow_ambient GL_ARB_sync GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_compression_rgtc GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_transpose_matrix GL_ARB_vertex_array_bgra GL_ARB_vertex_blend GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_EXT_abgr GL_EXT_bgra GL_EXT_bindable_uniform GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_clip_volume_hint GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_draw_buffers2 GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_multisample_blit_scaled GL_EXT_framebuffer_object GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_provoking_vertex GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture_array GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc GL_EXT_texture_env_add GL_EXT_texture_filter_anisotropic GL_EXT_texture_integer GL_EXT_texture_lod_bias GL_EXT_texture_rectangle GL_EXT_texture_shared_exponent GL_EXT_texture_sRGB GL_EXT_texture_sRGB_decode GL_EXT_timer_query GL_EXT_transform_feedback GL_EXT_vertex_array_bgra GL_APPLE_aux_depth_stencil GL_APPLE_client_storage GL_APPLE_element_array GL_APPLE_fence GL_APPLE_float_pixels GL_APPLE_flush_buffer_range GL_APPLE_flush_render GL_APPLE_packed_pixels GL_APPLE_pixel_buffer GL_APPLE_rgb_422 GL_APPLE_row_bytes GL_APPLE_specular_vector GL_APPLE_texture_range GL_APPLE_transform_hint GL_APPLE_vertex_array_object GL_APPLE_vertex_point_size GL_APPLE_vertex_program_evaluators GL_APPLE_ycbcr_422 GL_ATI_separate_stencil GL_ATI_texture_env_combine3 GL_ATI_texture_float GL_IBM_rasterpos_clip GL_NV_blend_square GL_NV_conditional_render GL_NV_depth_clamp GL_NV_fog_distance GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_light_max_exponent GL_NV_texgen_reflection GL_NV_texture_barrier GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_SGI_color_matrix GL_SGIS_generate_mipmap GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod 

$ make -f Makefile.macosx
cc -framework OpenGL  -o glversion glversion.o
Undefined symbols for architecture arm64:
  "_glutCreateWindow", referenced from:
      _main in glversion.o
  "_glutDestroyWindow", referenced from:
      _main in glversion.o
  "_glutGet", referenced from:
      _main in glversion.o
  "_glutHideWindow", referenced from:
      _main in glversion.o
  "_glutInit", referenced from:
      _main in glversion.o
  "_glutInitDisplayMode", referenced from:
      _main in glversion.o
  "_glutInitWindowSize", referenced from:
      _main in glversion.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [glversion] Error 1
  1. the Case1
    'cd utils; make' stops after './glversion > glversion.txt' and does not return to the prompt. After CTRL-C, glversion.txt does not exist. 'make -f Makefile.macosx' showed the same results.

There are OpenGL.framework, GLUT.framework, AGL.framework folders, under /System/Library/Frameworks/, but not under /opt/local/Library/Frameworks/, on both machines.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Apr 8, 2025

@goosh-gh Thank you for the detailed reporting. You're not supposed to run those sub-Makefiles yourself, as the updated files hopefully make a bit clearer.

Could you try the latest master? I've added the MacPorts directories, and reworked the glversion building a bit. If it doesn't work, please share the results of perl Makefile.PL verbose (and maybe run that anyway just so you can see what it's doing a bit more).

EDIT: I've also added the ability on MacOS to select AGL even if there's FreeGLUT present - which you'd think would have been possible before, but no.

@goosh-gh
Copy link

goosh-gh commented Apr 8, 2025

・On the machine with Sequoia15.4, Xcode16.3(16E140), MacPorts2.10.5, freeglut3.6.0 via MacPorts;

$ perl Makefile.PL verbose

run as 'perl Makefile.PL help' to show user options
$verbose set to 1

found libs:
FREEGLUT = '-lglut'
GL = '-framework OpenGL'
GLU = '-framework AGL'
GLUT = '-framework GLUT'

Using interface: FREEGLUT

resulting libs:
FREEGLUT = '-lglut'
GL = '-framework OpenGL'
GLU = '-framework AGL'

Testing for OpenGL Extensions
Testing GLUT version
glversion: cd utils;make -f Makefile LIB='-L/usr/X11R6/lib -L/opt/X11/lib -L/usr/local/lib -L/opt/local/lib -L/usr/lib -framework AGL -framework OpenGL -lglut -lm' INC='-I/usr/X11R6/include -I/opt/X11/include -I/usr/local/include -I/opt/local/include' DEF='-DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY' clean;make -f Makefile LIB='-L/usr/X11R6/lib -L/opt/X11/lib -L/usr/local/lib -L/opt/local/lib -L/usr/lib -framework AGL -framework OpenGL -lglut -lm' INC='-I/usr/X11R6/include -I/opt/X11/include -I/usr/local/include -I/opt/local/include' DEF='-DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY'

... it stops here and does not return to the command prompt for at least 20min.

If I skip the directory adding section (ll240 ~ ll245), it succeeds to make; make test; and I saw the rotating teapot for both perl5.34 via MacPorts and perl5.40.1 via Perlbrew, congrats! It detected "AGL" finally without my explicit assignment.
$ perl Makefile.PL
Using interface: AGL
This looks like OpenGL Version: 2.1 Metal - 89.4
for MacOS X, overriding to version 4.1
Found GLUT - Version: 5

$ cat utils/glversion.txt | grep EXT | sed -e 's/ /\n/g' | nl | tail -3
It looks like we have 133 lines, which are the same for both configurations with and without "-lglut"

・On the machine with Ventura13.7.4, Xcode14.3.1(14E300c), MacPorts2.10.5;
Success, without assigning AGL. While make test the rotating teapot appeared, with both perl5.34 via MacPorts and perl5.40.1 via Perlbrew, congrats!

@mohawk2
Copy link
Contributor Author

mohawk2 commented Apr 8, 2025

@goosh-gh Great to hear there is some success, thank you. Let's figure out this last little bit.

I'm baffled by you saying you skipped the "directory adding" section, since lines 240-245 add libraries on Win32. Please could you check exactly what you did, and paste in here the output of git diff which will tell me exactly? Also, please can you paste here the output of perl Makefile.PL verbose with the change, and if you haven't already, the output without the change?

@goosh-gh
Copy link

goosh-gh commented Apr 9, 2025

Sorry about the wrong line number. 'perl Makefile.2.PL; make; make test` works fine showing the rotating teapot on the Sequoia machine.

$ diff Makefile.PL Makefile.2.PL
273,278c273,278
<     for (@$ldirs) {
<       (my $dir = $_) =~ s/^-L//;
<       next if !-e "$dir/libglut.3.dylib";
<       $found->{FREEGLUT} = '-lglut';
<       last;
<     }
---
> #    for (@$ldirs) {
> #      (my $dir = $_) =~ s/^-L//;
> #      next if !-e "$dir/libglut.3.dylib";
> #      $found->{FREEGLUT} = '-lglut';
> #      last;
> #    }

Before change:

$ perl Makefile.PL verbose ### using the original Makefile.PL

found libs:
    FREEGLUT = '-lglut'
    GL = '-framework OpenGL'
    GLU = '-framework AGL'
    GLUT = '-framework GLUT'

Using interface: FREEGLUT

resulting libs:
    FREEGLUT = '-lglut'
    GL = '-framework OpenGL'
    GLU = '-framework AGL'

Testing for OpenGL Extensions
Testing GLUT version
glversion: cd utils;make -f Makefile  LIB='-L/usr/X11R6/lib -L/opt/X11/lib -L/usr/local/lib -L/opt/local/lib -L/usr/lib  -framework AGL -framework OpenGL -lglut -lm' INC='-I/usr/X11R6/include -I/opt/X11/include -I/usr/local/include -I/opt/local/include' DEF='-DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY' clean;make -f Makefile  LIB='-L/usr/X11R6/lib -L/opt/X11/lib -L/usr/local/lib -L/opt/local/lib -L/usr/lib  -framework AGL -framework OpenGL -lglut -lm' INC='-I/usr/X11R6/include -I/opt/X11/include -I/usr/local/include -I/opt/local/include' DEF='-DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY'

It stops here and does not return to the command prompt.
After change:

$ perl Makefile.2.PL verbose  ###  modified to skip the directory search for $found->{FREEGLUT}

found libs:
    GL = '-framework OpenGL'
    GLU = '-framework AGL'
    GLUT = '-framework GLUT'

Using interface: AGL

resulting libs:
    GL = '-framework OpenGL'
    GLU = '-framework AGL'
    GLUT = '-framework GLUT'

Testing for OpenGL Extensions
Testing GLUT version
glversion: cd utils;make -f Makefile  LIB='-framework OpenGL -framework GLUT -lm' INC='' DEF='-DHAVE_VER -DHAVE_GL -DHAVE_GLU -DHAVE_GLUT -DHAVE_AGL_GLUT -Wno-deprecated-declarations' clean;make -f Makefile  LIB='-framework OpenGL -framework GLUT -lm' INC='' DEF='-DHAVE_VER -DHAVE_GL -DHAVE_GLU -DHAVE_GLUT -DHAVE_AGL_GLUT -Wno-deprecated-declarations'

rm -f glversion.txt glversion glversion.o
cc  -DHAVE_VER -DHAVE_GL -DHAVE_GLU -DHAVE_GLUT -DHAVE_AGL_GLUT -Wno-deprecated-declarations -c glversion.c
cc glversion.o -framework OpenGL -framework GLUT -lm -o glversion
chmod u+x glversion
./glversion > glversion.txt


This looks like OpenGL Version: 2.1 Metal - 89.4
  for MacOS X, overriding to version 4.1
Found GLUT - Version: 5
MakeMaker configuration:
 DEFINE=-DHAVE_VER -DHAVE_GL -DHAVE_GLU -DHAVE_GLUT -DHAVE_AGL_GLUT -Wno-deprecated-declarations
 INC=
 LIBS=-framework OpenGL -framework GLUT -lm

Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for OpenGL
Writing MYMETA.yml and MYMETA.json

Although 'make test' works fine, I am not quite sure if it is good or bad to skip -lglut.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Apr 9, 2025

The alternative way that's now possible to skip FreeGLUT is to specify interface=AGL, but as you say that's not very satisfactory.

You could see what's happening with that command that's hanging, by copy-pasting what it says it's trying. As you can see, it needs to run in the utils directory. So you could try the full line (with brackets so it runs in a subshell, leaving the main one's directory unchanged):

(cd utils;make -f Makefile  LIB='-L/usr/X11R6/lib -L/opt/X11/lib -L/usr/local/lib -L/opt/local/lib -L/usr/lib  -framework AGL -framework OpenGL -lglut -lm' INC='-I/usr/X11R6/include -I/opt/X11/include -I/usr/local/include -I/opt/local/include' DEF='-DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY' clean;make -f Makefile  LIB='-L/usr/X11R6/lib -L/opt/X11/lib -L/usr/local/lib -L/opt/local/lib -L/usr/lib  -framework AGL -framework OpenGL -lglut -lm' INC='-I/usr/X11R6/include -I/opt/X11/include -I/usr/local/include -I/opt/local/include' DEF='-DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY')

I note that's quite a long line, so I'd ask you to try that as one line first, then try as two separate commands (the ; is obviously the separator) and see if that's a contributing factor. EDIT May I ask what command shell you're using? I use bash which doesn't have a limitation. I just used Windows Notepad to see the above is actually 776 characters, which is quite a lot.

@goosh-gh
Copy link

goosh-gh commented Apr 9, 2025

I copied into a shell script 00_test.sh and ran it. I use bash 3.2, via macports

$ bash ./00_test.sh 
rm -f glversion.txt glversion glversion.o
cc -I/usr/X11R6/include -I/opt/X11/include -I/usr/local/include -I/opt/local/include -DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY -c glversion.c
cc glversion.o -L/usr/X11R6/lib -L/opt/X11/lib -L/usr/local/lib -L/opt/local/lib -L/usr/lib  -framework AGL -framework OpenGL -lglut -lm -o glversion
chmod u+x glversion
./glversion > glversion.txt

This is what it says (where it stops).
I re-unzip and it is fresh, I mean I have not touched anything in this directory, FYI.

@goosh-gh
Copy link

goosh-gh commented Apr 9, 2025

I copied 00_test.sh to 01_test.sh and edited 01_test.sh as not having -lgut

$ bash 01_test.sh 
rm -f glversion.txt glversion glversion.o
cc -I/usr/X11R6/include -I/opt/X11/include -I/usr/local/include -I/opt/local/include -DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY -c glversion.c
cc glversion.o -L/usr/X11R6/lib -L/opt/X11/lib -L/usr/local/lib -L/opt/local/lib -L/usr/lib  -framework AGL -framework OpenGL -lm -o glversion
Undefined symbols for architecture arm64:
  "_glutCreateWindow", referenced from:
      _main in glversion.o
  "_glutDestroyWindow", referenced from:
      _main in glversion.o
  "_glutGet", referenced from:
      _main in glversion.o
  "_glutHideWindow", referenced from:
      _main in glversion.o
  "_glutInit", referenced from:
      _main in glversion.o
  "_glutInitDisplayMode", referenced from:
      _main in glversion.o
  "_glutInitWindowSize", referenced from:
      _main in glversion.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [glversion] Error 1

It returns quickly to the prompt, but fails at some functions while compiling (, probably due to missing -lglut?)

@mohawk2
Copy link
Contributor Author

mohawk2 commented Apr 9, 2025

OK, glad we've ruled out the shell as a problem. Could I ask you to try again but running the ./glversion without the redirecting > glversion.txt? I'd like to see if it makes any output at all.

Having just checked the code, it probably won't. Therefore, I'd ask you to edit glversion.c and insert before each of the lines with either a glut* or gl* function call (on the same line, to make it simple):

printf("reached line %d\n", __LINE__);

and then please put the results here, together with the git diff in case of line-number confusion. My suspicion is that your installation of FreeGLUT is broken there, but this will give us a lot more information.

@goosh-gh
Copy link

goosh-gh commented Apr 10, 2025

Without redirecting only './glversion' generated from the original glversion.c hangs and does not show anything.

$ git diff glversion.original.c glversion.c
diff --git a/glversion.original.c b/glversion.c
index ba8c8a9..9821378 100644
--- a/glversion.original.c
+++ b/glversion.c
@@ -34,14 +34,14 @@ int main(int argc, char **argv)
   char *vendor = NULL;
   char *renderer = NULL;
   char *extensions = NULL;
-  GLuint idWindow = 0;
-  int  freeglutVersion;
-
-  glutInit(&argc, argv);
-  glutInitWindowSize(1,1);
-  glutInitDisplayMode(GLUT_RGBA);
-  idWindow = glutCreateWindow(PROGRAM);
-  glutHideWindow();
+  GLuint idWindow = 0; printf("reached line %d\n", __LINE__);
+  int  freeglutVersion; printf("reached line %d\n", __LINE__);
+
+  glutInit(&argc, argv); printf("reached line %d\n", __LINE__);
+  glutInitWindowSize(1,1); printf("reached line %d\n", __LINE__);
+  glutInitDisplayMode(GLUT_RGBA); printf("reached line %d\n", __LINE__);
+  idWindow = glutCreateWindow(PROGRAM); printf("reached line %d\n", __LINE__);
+  glutHideWindow(); printf("reached line %d\n", __LINE__);

   version =     (char*)glGetString(GL_VERSION);
   vendor =      (char*)glGetString(GL_VENDOR);


$ bash ./00_test.sh
rm -f glversion.txt glversion glversion.o
cc -I/usr/X11R6/include -I/opt/X11/include -I/usr/local/include -I/opt/local/include -DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY -c glversion.c
cc glversion.o -L/usr/X11R6/lib -L/opt/X11/lib -L/usr/local/lib -L/opt/local/lib -L/usr/lib  -framework AGL -framework OpenGL -lglut -lm -o glversion
chmod u+x glversion
./glversion > glversion.txt

it hangs here, so CTRL-C, then I got:

^Cmake: *** Deleting file `glversion.txt'
make: *** [glversion.txt] Interrupt: 2

After the prompt came back, I tried:

$ ./glversion
reached line 37
reached line 38

I tried to uninstall and reinstall of 'freeglut' via macports, but no change.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Apr 10, 2025

Thank you. Just a note on the diff; my expectation was that you'd have done git clone https://github.com/Perl-GPU/pogl.git (or the SSH version, and/or of your fork of it if you were to make a pull request - see PDL FAQ for tips), then you could freely modify the files and then do git diff without needing the old, painful way of having to manually copy files to .orig then manually diff them. Please try that, it's much nicer for you. You'd then be able to git stash and git pull to check for updates, etc.

That said, we've reach the point where POGL is successfully establishing the build environment for a simple C program to compile and link against FreeGLUT. That C program is then hanging when it calls glutInit. That is no longer a Perl OpenGL problem, but a FreeGLUT / MacPorts one.

Before we conclude that, let's check one thing: please could you run otool -L utils/glversion (or if that doesn't work, ldd utils/glversion) and report results? I want to confirm which libglut it's linking against:

  • if it's under /opt/local, it's the MacPorts one, in which case you'd need to just report this as a bug to MacPorts and there's nothing I can do; you'd want to remove the port, and/or manually tell POGL to use the AGL interface
  • if it's from somewhere else:
    • remove that location as a -L, and recompile and rerun glversion
    • if that works, then you have a bad version of FreeGLUT installed and you'd probably want to remove it from there. Then retry the whole build process

Please note that PDL::Graphics::TriD currently relies on having FreeGLUT available, so the AGL interface here won't really help with that. However, I've just yesterday got P:G:TriD working with GLFW. As soon as I've got text rendering working (which OpenGL doesn't have natively, it's in GLX and GLUT, not GLFW), I'll be releasing that and the need for FreeGLUT will go away. After that, I'll be finishing OpenGL::Modern (which doesn't have/need GLUT support at all) and making P:G:TriD use that.

@goosh-gh
Copy link

Thank you for your instruction about how to use git. And It is really a very good news about the progress of P::G::TriD.
I tried a modified glversion,

$ bash 02_test.sh 
rm -f glversion.txt glversion glversion.o
cc -I/opt/local/include -DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY -c glversion.c
cc glversion.o -L/opt/local/lib -L/usr/lib  -framework AGL -framework OpenGL -lglut -lm -o glversion
chmod u+x glversion
./glversion > glversion.txt

stops here and CTRL-C

^Cmake: *** Deleting file `glversion.txt'
make: *** [glversion.txt] Interrupt: 2

Linking of this glvresion:

$ otool -L utils/glversion
utils/glversion:
	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	/opt/local/lib/libglut.3.dylib (compatibility version 3.0.0, current version 3.12.1)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)

I aimed "pure macport" glversion, removing /opt/X11 and /usr/local for both -I and -L components:

$ bash 03_test.sh 
rm -f glversion.txt glversion glversion.o
cc -I/opt/local/include -DHAVE_VER -DHAVE_FREEGLUT -DHAVE_GL -DHAVE_GLU -Wno-deprecated-declarations -DHAVE_GLX -DHAVE_FREEGLUT -DHAVE_FREEGLUT_H -DGL_GLEXT_LEGACY -c glversion.c
cc glversion.o -L/opt/local/lib -L/usr/lib  -framework AGL -framework OpenGL -framework GLUT -lglut -lm -o glversion
chmod u+x glversion
./glversion > glversion.txt
2025-04-11 18:04:02.572 glversion[20787:1308871] GLUT Warning: invalid glutGet parameter: 508

It returned to the command prompt immediately. Linking by the last one:

$ otool -L utils/glversion
utils/glversion:
	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/GLUT.framework/Versions/A/GLUT (compatibility version 1.0.0, current version 1.0.0)
	/opt/local/lib/libglut.3.dylib (compatibility version 3.0.0, current version 3.12.1)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)

Is the last one the same as interface=AGL? I got the utils/glversion.txt. If you need, I can paste it here, which is not short.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Apr 11, 2025

Your 03_test.sh is almost the same as interface=AGL, in that it has -framework GLUT, but it also has a -lglut, so it's linking to both - I assume you added both in, but it's not clear to me why. Because Apple's GLUT is first, that will be the source of all the symbols glversion uses, so the -lglut will have no effect.

The above extremely thorough investigation leads me to conclude that your installation of FreeGLUT, from MacPorts, is broken in some way, and you should definitely report that to MacPorts. There is nothing plausible that Perl OpenGL to fix that. The workaround for you would be to either manually install this library with interface=AGL, or delete your FreeGLUT, which will have the same effect.

However, PDL::Graphics::TriD with GLFW support has now been released to CPAN. You'll need GLFW installed (MacPorts has it, called glfw). If you have any problems with that, please open an issue on the OpenGL::GLFW repo. I am closing this.

@mohawk2 mohawk2 closed this as completed Apr 11, 2025
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

6 participants