We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

GCC Error

I am trying to install this on OSX mavericks, and am receiving the error: error: C compiler cannot create executables

I have updated the XCODE developer tools and can successfully build a hello world c program using gcc.

Here is the relevant section from config.log:

## ----------- ##
## Core tests. ##
## ----------- ##

configure:2339: checking for grep that handles long lines and -e
configure:2397: result: /usr/bin/grep
configure:2402: checking for egrep
configure:2464: result: /usr/bin/grep -E
configure:2469: checking for a sed that does not truncate output
configure:2523: result: /usr/bin/sed
configure:2713: checking for C compiler version
configure:2722: gcc --version >&5
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
configure:2733: $? = 0
configure:2722: gcc -v >&5
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
configure:2733: $? = 0
configure:2722: gcc -V >&5
clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:2733: $? = 1
configure:2722: gcc -qversion >&5
clang: error: unknown argument: '-qversion' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
clang: error: no input files
configure:2733: $? = 1
configure:2753: checking whether the C compiler works
configure:2775: gcc -O2 -fno-delete-null-pointer-checks   conftest.c  >&5
clang: error: unknown argument: '-fno-delete-null-pointer-checks' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
configure:2779: $? = 1
configure:2817: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:2822: error: in `/Applications/AMPPS/phalcon/cphalcon/build/64bits':
configure:2824: error: C compiler cannot create executables
See `config.log' for more details

Not being too well versed in compiler errors im a bit lost as to what is going on, but I think the gcc compilation test program has a syntax error:

| int
| main ()
| {
| 
|   ;
|   return 0;
| }

Can anyone help me get this sucker installed so I can write some kick-ass PHP?

Cheers
Ben

edited Mar '14

I'm running into the exact same problem. I have a MacBook Pro, retina, 15-inch, early 2013 with OSX Mavericks and the latest xcode command line tools (Mar 10, 2014) installed. My config.log shows the same error entries as the log file from Ben. Any suggestions would be greatly appreciated.

Update: While still having issues to compile the phalcon.so myself, i solved the problem by using "brew" and the fantastic homebrew php repository ( https://github.com/josegonzalez/homebrew-php ):

brew install josegonzalez/php/php54-phalcon

There are formulae available for the following php versions: 5.3, 5.4, 5.5 and 5.6. After installing phalcon via brew, i found a valid phalcon.so binary ready to use under the following location:

/usr/local/Cellar/php54-phalcon/1.2.6/phalcon.so

Greetz, John

edited Mar '14

I don't know if this has anything todo with your problem ( I never had this issue and I don't know exactly what it means), but to compile Phalcon you need to install autoconf and automake. Both can be easily installed with Homebrew. Also ( I think they didn't changed it in the past half year, since I dont use it anymore ) you have to compile the 32bit version of Phalcon if your using AMPPS.



98.9k

Try with Phalcon 1.3.0:

git clone https://github.com/phalcon/cphalcon
cd cphalcon/build
git checkout 1.3.0
sudo ./install
edited Mar '14

Update: Compilation with the 1.3.0 branch works fine for me :-) Anyway, the following may be of interest for the 1.2.6 branch or older.

The following steps made me do a successful compilation of a phalcon.so binary on my mac osx mavericks system.

I do have a MAMP system with php5.4.25 running. As MAMP does not ship with the php sources, i downloaded a copy from https://php.net/downloads.php which matches the php version im running in MAMP (in this case php 5.4.25).

https://www.php.net/get/php-5.4.25.tar.gz/from/a/mirror

I extracted the downloaded tarball and copied the files into the corresponding php folder inside the MAMP installation (This procedure is partly described at Install phalcon with MAMP):

cd ~/Downloads
tar xzf php-5.4.25.tar.gz
mkdir /Applications/MAMP/bin/php/php5.4.25/include
mv ./php-5.4.25 /Applications/MAMP/bin/php/php5.4.25/include/php
cd /Applications/MAMP/bin/php/php5.4.25/include/php
./configure

Next i followed the steps to compile phalcon as described here:

cd ~/Downloads
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build/64bits
phpize
./configure --with-php-config=/Applications/MAMP/bin/php/php5.4.25/bin/php-config
make
make install

After successful compilation the phalcon.so was placed under

/Applications/MAMP/bin/php/php5.4.25/lib/php/extensions/no-debug-non-zts-20100525/

One thing left to do: Adding the phalcon extension to the /Applications/MAMP/bin/php/php5.4.25/conf/php.ini file:

extension=phalcon.so

Finally i restarted MAMP to make the changes take effect. <?php echo phpinfo(); ?> verified, that phalcon was enabled and of version 1.2.6.



2.5k

Ok, so I am able to build phalcon.so using jdifool's suggestions, or brew and get it to compile successfully (or reported to) but on loading into php.ini I get the following PHP error.

Warning: PHP Startup: Unable to load dynamic library '/Applications/AMPPS/php-5.4/lib/extensions/no-debug-non-zts-20100525/phalcon.so' - dlopen(/Applications/AMPPS/php-5.4/lib/extensions/no-debug-non-zts-20100525/phalcon.so, 9): no suitable image found. Did find: /Applications/AMPPS/php-5.4/lib/extensions/no-debug-non-zts-20100525/phalcon.so: mach-o, but wrong architecture in Unknown on line 0

That is reporting the wrong architecture, but I have tried both 32 and 64 bits builds witht he exact same error. Is the compilation still failing ?

Cheers
Ben

I had the same issue. Phalcon forces to install 64 bits version even i went to 32 bits directory. This solved my problem to compile Phalcon for AMPPS.

cd cphalcon/build/32bits
export CFLAGS="-O2 -fno-delete-null-pointer-checks -finline-functions -fomit-frame-pointer -march=core2 -m32"
sudo make clean
sudo phpize --clean phpize ./configure --enable-phalcon
sudo make
sudo make install

with the lipo function in terminal, you can check if the phalcon.so was build in 32 bit.



47.7k
edited Mar '14

I am using osx mavericks and command line PHP 5.4.24.

I had the same issue. Unfortunately I still don't know what was causing it but by doing the following I was able to succesfully install:

  • Uninstalled xcode and developer tools including deleting /Library/Developer/<command line tools dir>
  • Reinstalled xcode and developer tools.
  • Installed as per instructions afresh.