thimes has asked for the wisdom of the Perl Monks concerning the following question:

Installed Perlbrew on 2019 Macbook Pro (Intel core i9) 32GB RAM. MacOS Sonoma 14.4.1. Tested and works well. Tried to install Tk using cpanm Tk. Recieved ERRORS in build.log configure: error: installation or configuration problem: C compiler cannot create executables.

Writing MYMETA.yml and MYMETA.json Building jpeg/libjpeg.a checking for gcc... cc checking whether the C compiler (cc -fno-common -DPERL_DARWIN -mmacosx +-version-min=14.4 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe - +fstack-protector-strong -I/usr/local/include -fno-common -DPERL_DAR +WIN -mmacosx-version-min=14.4 -DNO_POSIX_2008_LOCALE -fno-strict-alia +sing -pipe -fstack-protector-strong -I/usr/local/include -mmacosx-ve +rsion-min=14.4 -fstack-protector-strong -L/usr/local/lib) works... no configure: error: installation or configuration problem: C compiler ca +nnot create executables. ERROR from evaluation of /Users/terryhimes/.cpanm/work/1716015046.9428 +1/Tk-804.036/JPEG/Makefile.PL: ERROR from evaluation of /Users/terryh +imes/.cpanm/work/1716015046.94281/Tk-804.036/JPEG/jpeg/Makefile.PL: E +rror opening Makefile: No such file or directory at ./Makefile.PL lin +e 41. at ./Makefile.PL line 41. require ./Makefile.PL called at /Users/terryhimes/perl5/perlbrew/p +erls/perl-5.38.2/lib/5.38.2/ExtUtils/ line 258 ExtUtils::MakeMaker::eval_in_x(PACK021=HASH(0x7fe6d883bef0), "/Use +rs/terryhimes/.cpanm/work/1716015046.94281/Tk-804.036/JPE"...) called + at /Users/terryhimes/perl5/perlbrew/perls/perl-5.38.2/lib/5.38.2/Ext +Utils/ line 245 eval {...} called at /Users/terryhimes/perl5/perlbrew/perls/perl-5 +.38.2/lib/5.38.2/ExtUtils/ line 245 ExtUtils::MakeMaker::eval_in_subdirs(PACK021=HASH(0x7fe6d883bef0)) + called at /Users/terryhimes/perl5/perlbrew/perls/perl-5.38.2/lib/5.3 +8.2/ExtUtils/ line 823 ExtUtils::MakeMaker::new("MM", PACK021=HASH(0x7fe6d883bef0)) calle +d at /Users/terryhimes/perl5/perlbrew/perls/perl-5.38.2/lib/5.38.2/Ex +tUtils/ line 78 ExtUtils::MakeMaker::WriteMakefile("VERSION", 804.036, "XS_VERSION +", 804.036, "DEFINE", "", "INC", "-I.. -Ijpeg -I/usr/X11R6/include -I +/opt/X11/include/freetype2", ...)
I have installed Perlbrew on a new 2023 Macbook Pro, then Tk with no problems, works great. I followed the same instructions in both cases. Any ideas?

Replies are listed 'Best First'.
Re: cpanm Tk build errors
by cavac (Parson) on May 22, 2024 at 02:54 UTC

    C compiler cannot create executables

    Uhm, that's a new one i haven't seen before. I doubt that your compiler is borked (i doubt even Apple would be so bold as to break the compiler just to keep up their walled garden), but just to make sure, write a file "hello.c":

    #include <stdio.h> int main() { printf("Hello, World!\n"); return 0; }

    Then compile it with mininal arguments and execute it:

    $ cc -o hello hello.c $ ./hello Hello, World!

    If that works, you could try with the whole kaboodle of flags that the compile script thinks it should use:

    $ cc -fno-common -DPERL_DARWIN -mmacosx-version-min=14.4 -DNO_POSIX_20 +08_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/ +local/include -fno-common -DPERL_DARWIN -mmacosx-version-min=14.4 - +DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-st +rong -I/usr/local/include -mmacosx-version-min=14.4 -fstack-protecto +r-strong -L/usr/local/lib -o hello hello.c $ ./hello

    Does this also work or do you get any errors?

    PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
      All built with no errors. Executed perfectly.
Re: cpanm Tk build errors
by syphilis (Archbishop) on May 22, 2024 at 03:33 UTC
    I have installed Perlbrew on a new 2023 Macbook Pro, then Tk with no problems, works great. I followed the same instructions in both cases. Any ideas?

    I wonder:
    1) Is it the same version of Tk in both cases ?
    2) Did the build of Tk that worked also have have to build libjpeg ? ... or did it locate and use a suitable previously installed version of libjpeg ?
    3) Is it appropriate that all of those perl compiler flags be specified for the building of libjpeg ? As cavac has subtly hinted, maybe one or more of those flags has rendered "cc" unusable for that task.
    If those flags are actually specified in $Config{cc}, then I think that's wrong. What is the output of perl -V:cc ?

    But I don't think that I really have much in the way of ideas ;-)

      terryhimes@Users-MacBook-Pro perltk % perl -V:cc cc='cc'; Also compiled and ran hello.c and it worked perfectly. I will investigate your other suggestions comparing the successful build next.
Re: cpanm Tk build errors
by afoken (Chancellor) on May 22, 2024 at 12:59 UTC
    configure: error: installation or configuration problem: C compiler cannot create executables.

    The test compiles a hello-world-style program and tries to run it. If that fails, you get this error message. One reason is compiling for a different platform or set of libraries. That's a typical problem when cross-compiling. Another problems I can imagine is a filesystem mounted with the noexec option.


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      I've built hello_world.c and ran it with no issues. Also, Removed Perl Downloaded latest version of Xcode v16 Beta Used Perlbrew to reinstall Perl perlbrew install perl-5.38.2 perlbrew switch perl-5.38.2 All installed and tested Ok. Tried installing Tk again. FAIL cpanm Tk Same errors. Grrrr.

        Try cpanm --look Tk . This will take you to the Tk build dir. If you are versed with autotools edit ./configure to find the position where it fails. It should be creating a C test program to compile and saving it to a tmp dir. And also there should be the compilation command line (which is also printed on the console). Halt it there and add lines to tell you where that test C program is AND what is the path of cc with which cc.

        Also run ./configure with explicitly specifying the fullpath to the compiler: ./confgure CC=/x/y/z/cc (or something like this)

        The possible reasons for the errors you get are: 1) test C program includes files which are not found, 2) the compiler executable is not what you think it is (note that it does not use the fullpath to the compiler), 3) compiler flags are wrong (note that you may already have ENV vars in your shell which specify CFLAGS, LDFLAGS, CC etc. 4) the compilation fails at the linking stage because LIBRARIES are not found or wrong ones are used. This is/was controlled with LD_LIBRARY_PATH and apple-specific DYLD_LIBRARY_PATH. Do you have those set in your ENV? Their use is frowned upon but sometimes is the last resort.

        Far fetched but: check what user the compilation is run under (whoami) and whether it has in its path the specific compiler and uses that compiler with no extra CFLAGS, library paths etc. from login settings e.g. in bashrc