Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-27-2012, 07:30 PM   #1
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,064
Blog Entries: 1

Rep: Reputation: 90
phc is generating incomplete code?


I just compiled phc against php 5.2. Now, when I call phc to compile a simple php file, I get a 256 error from g++.

$ /usr/local/phc/bin/phc -c Hello.php -o hello
Error: gcc exited with error 256 (executed via 'gcc -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -L/usr/local/php/lib -Wl,-R/usr/local/php/lib -lphp5 -xc - -ggdb3 -O0 -ohello ')
So, I asked phc to generate C code and saved it into a file. When I tried to compile it, no surprises, it fails.... when I se the generated code, I find that main is incomplete.

File ends up like this:

main (int argc, char* argv[])
   int phc_exit_status;
   signal(SIGABRT, sighandler);
   signal(SIGSEGV, sighandler);

   php_embed_init (argc, argv PTSRMLS_CC);

      // load the compiled extension
      zend_startup_module (&app_module_entry);

      zval main_name;
      ZVAL_STRING (&main_name, "__MAIN__", NULL);

      zval retval;
Just like that. What's going on?
Old 05-27-2012, 10:06 PM   #2
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,064
Blog Entries: 1

Original Poster
Rep: Reputation: 90
Well..... this is very weird. I think the problem is in the parameters that g++ is getting when being called from phc (which, by the way, is the same problem that the compilation of phc was about).

If you recall ( I had to manually pass the linker some -L and -l parameters with -Wl (was there a change in the way g++ passes this parameters since the days of the last phc release?).

So..... I was able to make phc compile my php program by passing this additional parameters:

-C "-Wl\,-L/usr/local/php/lib" -C "-Wl\,-L/usr/local/boost/lib" -C "-Wl\,-lphp5" -C "-Wl\,-lboost_regex"


compilation, failure, gcc, phc

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Generating Code from DSLs LXer Syndicated Linux News 0 09-27-2011 11:20 PM
Code for generating a Pop-Up window in C lbdgwgt Programming 2 08-04-2010 08:16 AM
writing C code for generating load variations expeliarmus Programming 5 07-26-2007 08:45 AM
C++ Generating code balgaltz Programming 3 12-28-2006 10:21 PM
code for generating random samples! aru_04 Programming 2 07-21-2005 08:35 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:59 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration