Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to build PHP PDO extension for Rocket U2

Tags:

I wonder if anyone can help me with a problem that is making me pull what's left of my hair out...

I am currently working on a project that requires me to talk to a Unidata database. PHP has no native driver to access this type of database, however, after some Googling, I found the following:

https://u2devzone.rocketsoftware.com/accelerate/articles/u2-pdo-driver/u2-pdo-driver.

I have the U2 Intercall header and library and I think I am including them correctly. However, the extension compiles but does not pass the tests as it errors out with

pdo_u2.so: undefined symbol: ic_universe_session in Unknown on line 0 

which suggests to me that it is not being linked against the library. When I edit the makefile and specify by hand that the library should be included, it errors out with

relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /home/kaigoh/Downloads/intcall/lib/libuvic.a: could not read symbols: Bad value collect2: error: ld returned 1 exit status make: *** [pdo_u2.la] Error 1 

I have tried forcing the -fPIC switch in the makefile but I get the same error.

I simply do not know enough about compiling custom PHP extensions to assist myself, and I am hoping there is a guru here who can point me in the right direction!

UPDATE: This compiles perfectly using a 32-bit install of Linux, so no idea why it is failing with a 64-bit install...

like image 488
kaigoh Avatar asked Jan 01 '13 11:01

kaigoh


People also ask

What is PDO PHP extension?

The PHP Data Objects ( PDO ) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions.

How do I know if PHP PDO is installed?

The -i is used to display the output of phpinfo(). The |grep will filter the list to the ones containing PDO.

What is PDO in PHP with example?

The PHP Data Objects (PDO) defines a lightweight interface for accessing databases in PHP. It provides a data-access abstraction layer for working with databases in PHP. It defines consistent API for working with various database systems.


2 Answers

I know I asked this question a long while back, but the ultimate solution I came up with was to write a piece of middleware in C# with the .Net libraries from Rocket along with some PHP classes that can read and process the data from UniData.

If anyone is interested in more detail in how I accessed UniData from PHP, please feel free to drop me a line.

like image 197
kaigoh Avatar answered Oct 17 '22 15:10

kaigoh


lib/libuvic.a needs to be recompiled with -fPIC, not just the code that's trying to link to it. I can't tell from your output samples whether you recompiled the library with -fPIC as well, or not.

like image 25
CXJ Avatar answered Oct 17 '22 16:10

CXJ