# shared mysqlnd extension ...

- Thread: https://externals.io/message/62315
- Original archive: https://news-web.php.net/php.internals/62315
- Started by Lester Caine on 2012-08-20T21:52:23+00:00
- Messages: 13
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #62315 — Lester Caine — 2012-08-20T21:52:23+00:00

URL: https://externals.io/message/62315#62315

Having now got mysql running on the PHP5.4.3 machine, I'm trying to compile 
mysqlnd and mysqli as extensions to load and unload as required.

php_mysqlnd_config.h no longer exists, but why is the config file named 
config9.m4 rather than config.m4? What do I need to get these two extensions to 
build on Linux? My cuurent attempts based on google results only results in 
"Warning: PHP Startup: Invalid library (maybe not a PHP library) 'mysqlnd.so' in 
Unknown on line 0" after 'make'

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #62318 — Ferenc Kovacs — 2012-08-20T22:01:19+00:00

URL: https://externals.io/message/62315#62318 · In reply to: #62315

> Having now got mysql running on the PHP5.4.3 machine, I'm trying to
> compile mysqlnd and mysqli as extensions to load and unload as required.
>
> php_mysqlnd_config.h no longer exists, but why is the config file named
> config9.m4 rather than config.m4? What do I need to get these two
> extensions to build on Linux? My cuurent attempts based on google results
> only results in "Warning: PHP Startup: Invalid library (maybe not a PHP
> library) 'mysqlnd.so' in Unknown on line 0" after 'make'
>
>
hi

I would try
--with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd
--enable-pdo=shared --with-pdo-mysql=shared,mysqlnd
how are you doing currently?
why is this an internals question?

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #62319 — Andrey Hristov — 2012-08-20T22:04:07+00:00

URL: https://externals.io/message/62315#62319 · In reply to: #62315

> Having now got mysql running on the PHP5.4.3 machine, I'm trying to
> compile mysqlnd and mysqli as extensions to load and unload as required.
>
> php_mysqlnd_config.h no longer exists, but why is the config file named
> config9.m4 rather than config.m4? What do I need to get these two
> extensions to build on Linux? My cuurent attempts based on google
> results only results in "Warning: PHP Startup: Invalid library (maybe
> not a PHP library) 'mysqlnd.so' in Unknown on line 0" after 'make'
>

File is called config9.m4, because this guarantees an order of run, if 
it was config.m4 no order is guaranteed during configure. It was Jani's 
idea.

Andrey

---

## #62320 — Lester Caine — 2012-08-20T22:50:11+00:00

URL: https://externals.io/message/62315#62320 · In reply to: #62319

Andrey Hristov wrote:
> 
> > […]
>
> File is called config9.m4, because this guarantees an order of run, if it was
> config.m4 no order is guaranteed during configure. It was Jani's idea.

So what happens when trying to just build mysqlnd as I do any other extra 
module? Is simply renaming it the correct action?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #62321 — Lester Caine — 2012-08-20T22:51:35+00:00

URL: https://externals.io/message/62315#62321 · In reply to: #62318

Ferenc Kovacs wrote:
>     Having now got mysql running on the PHP5.4.3 machine, I'm trying to compile
>     mysqlnd and mysqli as extensions to load and unload as required.
>
>     php_mysqlnd_config.h no longer exists, but why is the config file named
>     config9.m4 rather than config.m4? What do I need to get these two extensions
>     to build on Linux? My cuurent attempts based on google results only results
>     in "Warning: PHP Startup: Invalid library (maybe not a PHP library)
>     'mysqlnd.so' in Unknown on line 0" after 'make'
>
> I would try
> --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --enable-pdo=shared
> --with-pdo-mysql=shared,mysqlnd
> how are you doing currently?
phpize in mysqlnd folder which is why config9.m4 does not work and has to be 
renamed, but it's calling php_mysqlnd_config.h which also does not exist.
I do not want to touch the existing core install as that is what runs all my 
sites, so I only need mysqlnd and mysqli as extra shared modules so I can switch 
them off without affecting the current working system.

> why is this an internals question?
Because no one answered on general :(
But since the core code base does not compile it seems internal to me anyway.

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #62322 — Rasmus Lerdorf — 2012-08-20T23:16:03+00:00

URL: https://externals.io/message/62315#62322 · In reply to: #62321

> Ferenc Kovacs wrote:
> > […]
> Because no one answered on general :(
> But since the core code base does not compile it seems internal to me
> anyway.

The bundled extensions are not designed to be built standalone using
phpize as you have discovered. The core codebase builds perfectly using
the procedure it was designed for. And you don't have to touch your core
install. Just add the flags or build in a separate directory if you are
worried and type make install-modules and it will install any shared
modules from that build without touching anything else. Or you can
simply copy the modules/*.so files you want to your extension_dir manually.

-Rasmus

---

## #62325 — Lester Caine — 2012-08-21T00:12:39+00:00

URL: https://externals.io/message/62315#62325 · In reply to: #62322

Rasmus Lerdorf wrote:
> 
> > […]
> The bundled extensions are not designed to be built standalone using
> phpize as you have discovered. The core codebase builds perfectly using
> the procedure it was designed for. And you don't have to touch your core
> install. Just add the flags or build in a separate directory if you are
> worried and type make install-modules and it will install any shared
> modules from that build without touching anything else. Or you can
> simply copy the modules/*.so files you want to your extension_dir manually.

Except that mysqlnd does not build as a shared module even when doing a full 
build. mysqli is fine built either way, and a standalone build of mysqlnd 
creates a module without any warnings, just not one that works, but there seems 
to be no way to flag from a core build that mysqlnd should be built shared? 
There is no mysqlnd.so file to copy over, and only a stand alone build seems to 
have the relevant flag :(

SO am I going to have to just create a parallel installation with mysqlnd 
included statically? Will the thirty odd existing extensions still work with 
that without having to recompile them? I ask since I understood that the 
php-config file needed to match the base code, and this would change when 
rebuilding the base code. In the past I've ended up recompiling everything just 
to get a working set of extensions.

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #62326 — Rasmus Lerdorf — 2012-08-21T00:19:51+00:00

URL: https://externals.io/message/62315#62326 · In reply to: #62325

> Rasmus Lerdorf wrote:
> > […]
> 
> Except that mysqlnd does not build as a shared module even when doing a
> full build. mysqli is fine built either way, and a standalone build of
> mysqlnd creates a module without any warnings, just not one that works,
> but there seems to be no way to flag from a core build that mysqlnd
> should be built shared? There is no mysqlnd.so file to copy over, and
> only a stand alone build seems to have the relevant flag :(

mysqlnd is not a standalone extension at all. It is infrastructure code
that needs to be linked into your PHP in order for extensions to use it.
Once you have that you can load shared mysql, mysqli and pdo_mysql
extensions against it. And no, it won't affect other extensions that
mysqlnd is there.

But again, this is a question for php-install, not internals. This is
pretty basic stuff.

-Rasmus

---

## #62335 — Lester Caine — 2012-08-21T08:41:40+00:00

URL: https://externals.io/message/62315#62335 · In reply to: #62326

Rasmus Lerdorf wrote:
> mysqlnd is not a standalone extension at all. It is infrastructure code
> that needs to be linked into your PHP in order for extensions to use it.

OK that is the key piece of information I was missing. I though we had got over 
the 'needs to be built in' and had made it optional!

I asked originally on php-general and was pointed to
Fixed bug http://bugs.php.net/55609 (mysqlnd cannot be built shared). (Johannes)
This specifically say ...
"It's also possible to use --enable-mysqlnd=shared"

SO I simply assumed that was the case, it does not give an error message like 
other miss configurations do ...
AH - JUST use --enable-mysqlnd=shared and don't add the mysqli shared module at 
the same time and the core build happily creates a shared module! But ...
"Unable to load dynamic library '/opt/php5/ext/mysqlnd.so' - 
/opt/php5/ext/mysqlnd.so: undefined symbol: executor_globals in Unknown on line 0"

THIS the same problem I get if I don't recompile the extensions after changing 
the core build and the feedback was that this is because of using incompatible 
php-config files!

So should I be updating that bug to the current state of play? That this is 
actually by design? Or create a new bug that states that 
'--enable-mysqlnd=shared' should not be allowed? Or is there some third position 
in this jigsaw?

Anyway I now have parallel apache modules one with and one without mysqlnd ... 
after screwing up the entire machine because I forgot that php overwrites the 
modules in apache even with apache running :(
Now to move all the mysql data over ...

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #62337 — Gustavo Lopes — 2012-08-21T10:10:50+00:00

URL: https://externals.io/message/62315#62337 · In reply to: #62335

Em 2012-08-21 10:41, Lester Caine escreveu:
>
> SO I simply assumed that was the case, it does not give an error
> message like other miss configurations do ...
> AH - JUST use --enable-mysqlnd=shared and don't add the mysqli shared
> module at the same time and the core build happily creates a shared
> module! But ...
> "Unable to load dynamic library '/opt/php5/ext/mysqlnd.so' -
> /opt/php5/ext/mysqlnd.so: undefined symbol: executor_globals in
> Unknown on line 0"
>
> THIS the same problem I get if I don't recompile the extensions after
> changing the core build and the feedback was that this is because of
> using incompatible php-config files!
>
> So should I be updating that bug to the current state of play? That
> this is actually by design? Or create a new bug that states that
> '--enable-mysqlnd=shared' should not be allowed? Or is there some
> third position in this jigsaw?
>

It usually helps that the extension you compile is binary compatible 
with the PHP build you're loading it in. In your case, I'd guess you 
compiled PHP with ZTS support but mysqlnd without.

As to whether '--enable-mysqlnd=shared' actually works or not I can't 
be sure as I haven't tested it. But there's nothing in the problem 
you're having that points to it not working when built properly.

-- 
Gustavo Lopes

---

## #62339 — Lester Caine — 2012-08-21T12:10:16+00:00

URL: https://externals.io/message/62315#62339 · In reply to: #62337

Gustavo Lopes wrote:
> > […]
>
> It usually helps that the extension you compile is binary compatible with the
> PHP build you're loading it in. In your case, I'd guess you compiled PHP with
> ZTS support but mysqlnd without.
>
> As to whether '--enable-mysqlnd=shared' actually works or not I can't be sure as
> I haven't tested it. But there's nothing in the problem you're having that
> points to it not working when built properly.

Current situation is that I've run a clean build of the Apache module with 
mysqlnd included statically, and the mysqli extension is compiled as shared. If 
I add the '--enable-mysqlnd=shared' then it does build a shared mysqlnd module, 
but the module is unusable due to the 'executor_globals' error, so either there 
should be no option TO build shared? Or the problem in the shared module needs 
fixing?

What was causing me more confusion ( for the last two hours ) was that I could 
not get the remote machine to connect to the database, so I was not sure if the 
mysqli module was working at all. I've had to 'create' an extra set of users on 
the PHP5.4 machine as 'localhost' will not work as a connection. I've found some 
references to needing to use the ip address, and with some juggling I now have a 
working connection on that machine via the domain name ... finally.

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #62340 — Gustavo Lopes — 2012-08-21T12:45:13+00:00

URL: https://externals.io/message/62315#62340 · In reply to: #62339

Em 2012-08-21 14:10, Lester Caine escreveu:
> Gustavo Lopes wrote:
> > […]
>
> Current situation is that I've run a clean build of the Apache module
> with mysqlnd included statically, and the mysqli extension is 
> compiled
> as shared. If I add the '--enable-mysqlnd=shared' then it does build 
> a
> shared mysqlnd module, but the module is unusable due to the
> 'executor_globals' error, so either there should be no option TO 
> build
> shared? Or the problem in the shared module needs fixing?

I've just tried to compile mysqlnd and mysqli shared and it worked (at 
least sapi/cli/php -n -d extension_dir=modules -d extension=mysqlnd.so 
-d extension=mysqli.so -i showed no problems).

It is at least conceivable that there's some bug I'm not hitting. In 
any case, this is a development mailing list. So you can either try to 
figure out the problem yourself using this mailing list asking for 
pointers if necessary -- that means actually checking the source code, 
inspecting symbols in the binaries, preprocessor defines after configure 
etc. -- or you can file a bug report with clear, complete steps for 
reproducing the problem.

-- 
Gustavo Lopes

---

## #62346 — Lester Caine — 2012-08-21T16:47:47+00:00

URL: https://externals.io/message/62315#62346 · In reply to: #62340

Gustavo Lopes wrote:
> I've just tried to compile mysqlnd and mysqli shared and it worked (at least
> sapi/cli/php -n -d extension_dir=modules -d extension=mysqlnd.so -d
> extension=mysqli.so -i showed no problems).

Correct, it compiles fine, but what setup are you running your mysqlnd.so on? 
This may simply be a problem with the Apache module build, but trying to include 
mysqlnd.so gives an error and Apache

> It is at least conceivable that there's some bug I'm not hitting. In any case,
> this is a development mailing list. So you can either try to figure out the
> problem yourself using this mailing list asking for pointers if necessary --
> that means actually checking the source code, inspecting symbols in the
> binaries, preprocessor defines after configure etc. -- or you can file a bug
> report with clear, complete steps for reproducing the problem.

https://bugs.php.net/bug.php?id=62880

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
