I am learning how to use SWIG, and I am writing a php wrapper for a C library. The extension successfully compiles, but when I try to call the function I get this error:
php: symbol lookup error: /usr/lib/php5/20090626+lfs/fact.so: undefined symbol: fact
Your problem is probably due to a mismatch in the name of the module (see %module, or passed on the command line) and the name of the .so file you are generating.
PHP, or any system that accepts loadable binary modules, is going to make certain assumptions about the name of the entry point into the library it is trying to load. PHP seems to be assuming that the file name (fact.so) is going to contain a function called "fact".
When you run SWIG, explicitly setting the module name to "fact" will probably solve your problem. If not, posting the generated SWIG source file could help us debug your problem.
Related
In PHP (version 7.1), I am attempting to use a MAP as opposed to a two dimensional array to handle implicit data type conversion across different data type groups. However, I am receiving the following run-time error:
Class 'Ds\Map' not found
The error occurs on this line of code:
protected $hive_data_type_group_map = new \Ds\Map();
I have checked online, but there is little documentation on Ds\Map, even on PHP's website (click here). Does anyone know how to fix this?
Data Structures is not a built-in PHP extension.
It needs to be installed before use. The installation instructions are available on php.net.
For windows
Download compiled-dll file "php_ds.dll" from https://pecl.php.net/package/ds. Place it in your dir wamp\bin\php\[your_php_version_folder]\ext and include it in your ".ini" file.
It worked for me.
the easiest way on ubuntu:
pecl install ds
Reference: https://www.php.net/manual/en/ds-deque.allocate.php
I'm trying Sonar and i've got some issues with it for a php project.
I have to do it multi-module to get at least php and js analysis.
this is my sonar-project.properties:
sonar.projectKey=xxxx
sonar.projectName=xxxx
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=
sonar.language=php
sonar.exclusions=htdocs/libraries/externals/**
sonar.phpCodesniffer.skip=true
sonar.modules=php-module,js-module
# PHP module
php-module.sonar.projectName=PHP Module
php-module.sonar.language=php
php-module.sonar.sources=
php-module.sonar.projectBaseDir=htdocs
php-module.sonar.exclusions=libraries/externals/**
# JavaScript module
js-module.sonar.projectName=JavaScript Module
js-module.sonar.language=js
js-module.sonar.sources=js
js-module.sonar.projectBaseDir=htdocs
But when i run sonar-runner, i get this error:
Exception in thread "main" org.sonar.runner.RunnerException: org.sonar.api.utils.SonarException: PHPMD execution failed with returned code '1'. Please check the documentation of PHPMD to know more about this failure
and the PHPMD error is
The parser has reached an invalid state near line "32" in file "/var/www/vhosts/dev3.xxxx.local/htdocs/libraries/externals/AvaTax4PHP/classes/ATConfig.class.php". Please check the following conditions: The keyword "parent" was used as type hint but the class "ATConfig" does not declare a parent.
But why is that happening if i've excluded the dir libraries in the project and the module?
Do i have to specify to PHPMD another list of exclusions?
For PHPMD (just as for PHP CodeSniffer, for example) you will have to specify a separate exclude pattern. You can use PHPMD's --excludeparameter for that.
Took me a while to figure it out, but you can set PHPMD's command line parameters with the following setting in your sonar-project.properties file:
sonar.phpPmd.argumentLine=--exclude libraries/externals
You can refer to this FAQ entry to know how to achieve your goal: http://docs.codehaus.org/display/SONAR/PHP+Plugin+FAQ#PHPPluginFAQ-HowdoIpreventexternaltoolsfromanalyzingsomesourcefiles
BTW, you should declare:
php-module.sonar.sources=.
, instead of:
php-module.sonar.sources=
I'm trying to (in a parallel fashion, that's it, as we're still developing under PHP 5.2.x for our main applications) adapt our current applications to PHP 5.4.x (using Apache 2.4.2 with PHP 5.4.1 in our testing server) but I'm finding some warnings in our current applications when we run them in the testing server.
For example... we're using constant definition in our current applications with a function that detects the language and loads a language file containing the definitions like idiomas/lang.php, being lang a 2-digit language representation (es, us, de, and so on).
Inside each language file there's some definitions like this one:
define("IDIOMA_AF", "Afrikaans");
define("IDIOMA_AR", "العربية");
define("IDIOMA_BG", "български език");
So, when we want to output a given translated text, we do this:
<?php echo IDIOMA_AF; ?>
The message PHP 5.4.1 outputs when the application is thrown at it is the following:
Notice: Constant IDIOMA_AF already defined in D:\apache\htdocs\aplicacion\modulos\base\idiomas\es.php on line 34
Does anyone have the same problem? I would like to know a bit about your experiences, as it would be useful to know how to solve these problems. We're thinking on implementing a better system using gettext (which I think is more organized and easier to handle in the long run, but still...), although we would like to run our current applications for a while before upgrading them.
It means you are trying to define the constant twice (which is not allowed).
You could try:
if (!defined('IDIOMA_AF')) define('IDIOMA_AF', 'Afrikaans');
Or trace, and fix, why you are defining a constant twice anyway.
The function get_defined_constants() is also a useful debugging tool for issues like these.
Or, just ignore those errors: error_reporting(E_ALL & ~E_NOTICE);
I am upgrading a site from Fedora 14, PHP4, and PEAR DB to Fedora 16, PHP 5.4 and PEAR MDB2 2.5.0b3, and I am getting the error
Fatal error: Call to undefined function: MDB2_Driver_MYSQL::getAll(). in /usr/share/php/MDB2.php on line 1892
Obviously, I've checked line 1892 of the MDB2.php file, and it contains the error reporting code for the __call magic method (allows you to call a specific function by passing it into __call)
I have checked for usages of __call, and there don't seem to be any. Likewise, when I try to find where MDB2_Driver_MYSQL is coming from, the only place it is even mentioned is in MDB2.php (as a comment about the driver for MySQL), in the class declaration (class MDB2_Driver_mysql extends MDB2_Driver_Common), and the description title in the .xml file.
I have manually included the /usr/share/php/MDB2/Extended.php file in the file where the MDB2_Driver_mysql class is defined, and that didn't help (not that this would have been a permanant fix...)
Has anyone encountered this error, and if so, what did you do to fix it? Google has proved nearly useless, as the only place it is specifically mentioned doesn't really deal with fixing it.
change getAll() in your class, to queryAll(), cause there some difference between DB & MDB2, and the same with getOne, getRow - they all changed to queryOne, queryRow. Here you can read about it http://www.phpied.com/db-2-mdb2/
Make sure you load the extended module in your code prior to making a query, similar to below:
$db->loadModule('Extended');
I have placed my own php file in /sites/all/modules/<myfolder> and call it via $.post(<myphppage>) from a static html page (javascript function) also in /sites/all/modules/<myfolder>.
However, the php does not appear to be executing as expected, but is getting called (access logs in Apache HTTPD show it is post'ed to).
If I try to manually request the same php page, I receive this error:
Fatal error: Call to undefined function db_insert() in /full/path/to/sites/modules/<myfolder>/<myphppage> on line x.
The echo statement I have in the php page is outputted properly above this error, and simply uses $_GET['paramname']. (And _POST, changed for testing direct request) to print a few query string parameters for debugging).
Also, when I added a call to watchdog, I receive:
Fatal error: Call to undefined function watchdog() in /full/path/to/sites/modules/<myfolder>/<myphppage> on line x.
Is it not possible to access the PHP page directly? Or is there a Drupal library I need to import? Or am I just plain missing something else with how Drupal works?
You are getting those errors about undefined functions because your PHP file is independent from Drupal and it is not bootstrapping it.
The Drupal way of doing what you are trying to do is to create a module (see Creating Drupal 7.x modules, and Creating Drupal 6.x modules) that defines a URL it handles with hook_menu(); that URL is then used with $.post().
As example of the way of bootstrapping Drupal, see the content of the index.php file that comes with every Drupal installation. (The following code is the one used from Drupal 7.)
/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
The code changes from Drupal 6 to Drupal 7, but drupal_bootstrap() is defined in both Drupal versions.
The correct way is to create a module, anyway. For a list of reasons why a module should use a PHP file that bootstraps Drupal, see Are there cases where a third-party module would need to use its own file similar to xmlrp.php, cron.php, or authenticate.php?