ogr2ogr libcurl error in Mac OS - php

I am working to run "ogr2ogr" command in terminal.
I got this error message.
dyld: Library not loaded: libcurl.4.dylib Referenced from:
/usr/local/bin/ogr2ogr Reason: Incompatible library version: ogr2ogr
requires version 8.0.0 or later, but libcurl.4.dylib provides version
7.0.0
There is a mismatch between the system requirement and library requirement. As I can tell, the latest curl is version 7 http://curl.haxx.se/download.html,
why is this asking for version 8? I also tried to upgrade curl with brew
but couldn't symlink into /usr/local, because would cause conflicts with
the OS.
In order to figure this problem: I started by figuring out if the Curl is used by different
$$ Which curl
/usr/bin/curl
I installed GDAL on mac by fellowing these instructions (StackOverFlow Post).
To explore where the ogr2ogr is, I run the command.
$$ which ogr2ogr
/usr/local/bin/ogr2ogr
I fellowed these instructions :
Download curl sources: http://curl.haxx.se/download/curl-7.25.0.zip
Unarchive the zip file somewhere
Open a Terminal window and go to the directory containing curl sources
Type: CFLAGS=-m64 ./configure
Type: make
Type: sudo make install
Source :
But it doesn't work out.
Another approach
I downloaded this file, unzip it into the bin/ directory, but when I tried to run it. I got this problem
../../bin/libcurl.4.dylib: cannot execute binary fil
There is one answer I found that seems very helpful, but I couldn't find it very practical.
If you didn't define the --with-curl option when running GDAL
./configure, then
GDAL will link with the curl library indicated by "curl-config --libs"
You likley have several libcurl on your system and the one that got used when
linking GDAL is not the one available at runtime.
The 8.0.0 or 7.0.0 don't necessarily reflect the "human readable" version of
the curl library. It might be some other numbering scheme related to how the
API/ABI of the library evolves, or something linked to packaging.
How can we do that in a practical way.
I read many articles before posting this question here, Anyone have any ideas on how to solve this problem ?

Have you checked this out?
Python Anaconda linking
I did that, then simlinked some stuff:
ln -s libcurl.4.0.0.dylib libcurl.3.dylib
Another error came up, now pertaining to libxml2.
I did:
brew install libxml2 libxslt
brew link --force libxml2 libxslt
And now ogr2ogr is finally working

Related

Can't open PHP, dyld: Library not loaded

I am aware there are many other questions related to this error, but I have tried all the answers and nothing worked.
Full error
dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
Referenced from: /usr/local/opt/php#7.1/bin/php
Reason: image not found
Abort trap: 6
When did the error occur?
Right after updating Ruby to 2.6.3 via RVM.
Whenever I enter "php" into the terminal the error appears.
Steps taken
Basic steps: Restart Macbook, opened new terminal window.
Uninstall/Reinstall: Node, Openssl, libpng, Ruby
Update/Upgrade: brew
Unlinked/Linked: libidn, autoconf
Given myself all rights via chown -R /usr/local
OpenSSL: $ sudo rm /usr/bin/openssl, brew reinstall openssl#1.1
Brew cleanup
Reinstalled PHP
Versions
Mac OS Mojave 10.14.6
PHP 7.4
Ruby 2.6.3p62
RVM 1.29.9
When running Brew Doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
/opt/local/bin/python2.7-config
/opt/local/bin/curl-config
/opt/local/bin/ncursesw6-config
/opt/local/bin/pcre-config
/opt/local/bin/ncurses6-config
/opt/local/bin/pcap-config
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
(here it posts all the /usr/local/include/node files, but the list exceeds character limitations)
Any ideas on how to solve this error?
I had similar issue which I fixed this way:
brew reinstall php
I will answer my own question for others who might run into a similar issue
After having uninstalled and reinstalled every single keg of brew I found the following solution:
Uninstall PHP
Run brew cleanup
Check your /usr/local/opt folder for any folders named php
Delete the folder (in my case it was called 'php#7.1')
Open a new terminal window
Run 'brew search php' in the terminal and make sure no php keg is installed.
Simply type 'php -v' in the terminal. For me this showed a version number, indicating that php was (at one point) installed without brew. You can choose to uninstall this version or update it to the newest version.
Conclusion
In my case I believe it was simply that PHP 7.1 was already installed and I installed a 2nd version (7.4) via brew.
The error 'Referenced from: /usr/local/opt/php#7.1/bin/php' was obviously searching for something in this folder and after deleted it, the error stopped.
In my case, i had multiple version of php installed on my macOs, which was later remedies with laradock.
Primary problem:
❯ php -v
dyld[62395]: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicuio.70.dylib
Referenced from: <31116583-6CB3-3C7B-AD46-52FF1431267E> /opt/homebrew/Cellar/php#7.4/7.4.30/bin/php
Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicuio.70.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicuio.70.dylib' (no such file), '/opt/homebrew/opt/icu4c/lib/libicuio.70.dylib' (no such file), '/usr/local/lib/libicuio.70.dylib' (no such file), '/usr/lib/libicuio.70.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.70.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.70.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.70.dylib' (no such file), '/usr/local/lib/libicuio.70.dylib' (no such file), '/usr/lib/libicuio.70.dylib' (no such file, not in dyld cache)
Also tried
❯ brew uninstall php
Warning: Calling plist_options is deprecated! Use service.require_root instead.
Please report this issue to the mongodb/brew tap (not Homebrew/brew or Homebrew/core), or even better, submit a PR to fix it:
/opt/homebrew/Library/Taps/mongodb/homebrew-brew/Formula/mongodb-community.rb:55
As indicated "Referenced from" a php version was still installed after mutliple attempts of brew uninstall php
Solution:
rm -rf /opt/homebrew/etc/php
After above brew install php without a problem.
Hope this helps.

How to install Gearman PHP extension on Windows?

Background:
1. How can i install gearman php extension on Windows OS?
2. Installing gearman PHP extension on Windows using cygwin and pecl
Following the answer in 1. question, I've made my cygwin work, downloaded and compiled gearman, and got the first gearman worker example to work:
Problem:
To run the same example from PHP script, I still need PHP extension. Somewhere I've seen that I might get to install PECL extension using PEAR, so:
I've downloaded go-pear.phar into C:\...\php5.6.16
ran php go-pear.phar
installed PEAR in system mode -> success
Now I can do: C:\...\php5.6.16>pecl install gearman which gives:
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl
channel-update pecl.php.net" to update
downloading gearman-1.1.2.tgz ...
Starting to download gearman-1.1.2.tgz (30,961 bytes)
.........done: 30,961 bytes
3 source files, building
ERROR: The DSP gearman.dsp does not exist.
Which would indeed be a sorcery if it worked, as that extension should be probably built/compiled accordingly to PHP itself. What is the least painful way to make this work? Is there a way how to do this without installing Visual Studio? I've also seen Net_Gearman PEAR package that might perhaps be wrapped / tweaked to be used just as the PECL one?
I'm currently using WAMP3.1.1 with PHP5.6.16 it comes with + VC15 x64 Thread Safe PHP7.2.2, need Gearman to work with at least one of those two. Any help appreciated
I've followed these 2 guides:
https://www.sitepoint.com/compiling-php-from-source-on-windows/
https://wiki.php.net/internals/windows/stepbystepbuild
1. I've downloaded:
Visual Studio 2012
.NET Framework 4.7.1 (which at the end just flashed a message that it's already installed)
Windows SDK _X_EN_DVD.iso
php-sdk-binary-tools-20110915.zip
deps-5.6-vc11-x64.7z (dependencies)
php-src-php-5.6.16.zip (GitHub release)
2. Compiled PHP
(note this is all from Native Tools Command Prompt, I didn't even actually start VS at all)
used just configure --disable-all --enable-cli --enable-pdo
3. Tried to compile PECL Gearman
found out it can't really be done on Windows
4. Found Gearman wrapper for Windows:
mhlavac/gearman on GitHub

Install PHP 7.0 Internationalization extension (Intl) on XAMPP on Mac

I followed the instructions outlined here:
Install PHP Internationalization extension (Intl) on XAMPP on Mac
Ran sudo pecl install intl
selected the correct files from the Cellar
then this error happened:
/private/tmp/pear/temp/intl/intl_error.h:24:10: fatal error:
'ext/standard/php_smart_str.h' file not found
include
^ 1 error generated. make: *** [php_intl.lo] Error 1 ERROR: `make' failed
No matter, did some research and found out that PHP 7.0.8 deprecated php.smart_str.h to php.smart_string.h
So given my scant knowledge of C++ I copied smart_string.h to smart_str.h and renamed all the headers from STRING to string.....
re-ran pecl -no luck....more errors......without knowing where the .c files are and remaking php (not really interested in going that far) since anyway I'm using XAMPP so that ended that option.
I have php 5.5 on my mac, deep in the usr/local/bin folder
so next step was to get pecl to use those files and generate an intl.so file....
Did that....I have the intl.so file so put it in the 'extensions' folder in XAMPP (for reference: /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012)
Ran php and came up with this error:
Warning: PHP Startup: Unable to load dynamic library
'/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so'
- dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so,
9): Symbol not found: _zval_used_for_init Referenced from:
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
Expected in: flat namespace in
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
in Unknown on line 0
I imagine it has to do with different versions?
In any case I can't get pecl to install intl without a make error in PHP 7.0.8 on XAMPP. There is no documentation on this and you'd think that if you deprecate a header.h file you'd update all extensions?
Install intl.so in PHP 7 seems impossible?
After a lot of research I was finally able to resolve this. Detailed steps here:
before you begin, check which php path is set. it should be /Applications/XAMPP/xamppfiles/bin/php. If not you can change it by PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}". more detail here
Overall idea is to build the intl-extension from PHP source code on your own. Before you begin make sure you have installed Xcode. Also, install the latest version of autoconf. this might help:
brew install autoconf
Next download the version of PHP you use in XAMPP from php.net. I am using 7.1.18. This version worked for me: php-7.1.31, I’m guessing if you follow the steps it might work for 7.0 or 7.2 as well. Do let me know if it does or doesnt, I’ll update this post. Do not use PHP 7.3 for Magento 2.3.0, it is not supported.
Extract the tar.gz file using (I extracted it inside ~/Downloads/ folder )
tar -xzvf php-7.1.31.tar.gz
cd into the extracted folder
cd php-7.1.31
change to subfolder ext/intl
cd ext/intl/
Run these commands to build the extension
/Applications/XAMPP/bin/phpize
./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/
make
sudo make install
you can now delete all files you downloaded and also the extracted folders.
Open /Applications/XAMPP/xamppfiles/etc/php.ini , and add extension=intl.so
Restart your Apache using XAMPP GUI and it should work.
So far, it seems that extension intl.so for php is bundled with php
and should be compiled with php (intl --enabled). XAMPP does not support this (as of Oct 2016), MAMP does. I do not know about other distros. However, if you're willing to recompile PHP 7, it's worth it just to do that and enable it during compiling.
So....I ran with MAMP. Then I decided that I would simply install apache 2.4 and php 7 and Mysql without the stack and the junk that comes with MAMP or XAMPP and everything works like a charm... so if you need to use CakePHP or intl support etc... just drop XAMPP/MAMP and go with a standard install. I used homebrew (MacOS) and everything is working fine.
Update: As regards Windows, XAMPP does not default it, but you can add the module (dll) in php.ini and works like a charm
The error means that XAMPP doesn't have PHP compiled with intl. You may try:
pecl install intl
but probably it won't work as well.
See: PHP Bug #72879 Pecl install intl make error with PHP 7.0.8.
As for the workaround, try installing memcached extension instead of memcache, e.g.
pecl install memcached
Note: It also requires libmemcached package/library to be installed beforehand. For macOS, install via: brew install libmemcached.
If you wanna try without homebrew, with native apache and php, look at my aswer here: https://stackoverflow.com/a/55131868/3692846

How to install pthreads on a phpfarm php installation

Documenting my struggles to help others and hopefully get some feedback on how I could have done it better.
The command pecl install pthreads fails due to the php installed on my ubuntu 13.04 box not having zts configured.
Options:
1) The ubuntu respository does not have a php package with zts enabled. As of this post, ubuntu only has php 5.4.9 in it's repository (Released: 22 Nov 2012). It is possible to compile a php version from source - which I eventually did (see below), but..
2) I .. ALSO .. wanted to use phpfarm for the ability to run different versions of PHP on my local setup. On github, there is Christian Weiske's original contribution here (phpfarm) and a fork that he has contributed to, by François Poirotte - also called phpfarm. Francois' fork has a few more options to configure ('post-install customization') but I was not able to make that work with a PECL extension. I'm curious to know if misunderstood how to do that, because it looks to me that it just simply does not take PECL commands.
3). Prior to recompiling php from source, I loaded phpfarm (tried both versions), enabled php-fpm (FastCGI) and was able to get my apache2 server to use a phpfarm version (5.5.10) which showed up in a phpinfo() output. But the php-cli always showed the original php version (5.4.9) in the cli (run: php -v). Running (run: php -i | grep php.ini) showed /etc/php5/cli but I had previously removed php5 and aptitude show php5 returned a state of 'not installed.' I even renamed the /etc/php5 directory to see if I could force the system to use the phpfarm php version. Obviously, this is incorrect thinking and I went on to simply compile php 5.6 from source. But, is there something more to do to get a phpfarm php to be used in the cli? I read that the cli loads it's configuration file on a per command basis, unlike the apache2. If I could have run the 5.5.10 version (configured with zts) then I could have then done pecl install pthreads and then re-complied the phpfarm 5.5.10 version with pthreads enabled. Although it appears I will be able to run various versions of php in the apache server, will I ever be able to switch-phpfarm to another version and see it working in the php-cli? Also, I was uncertain on where I could have loaded a pthreads file for the phpfarm compile process to find and use it; could I have done it that way?
4) This stackoverflow post, essentially posted by Joe Watkins - the developer of pThreads is a perfect how-to on getting pThreads installed on a Ubuntu system that has had php configured with zts (Zend Thread Safety). (Thanks Joe!)
A nice tutorial on using phpfarm configured with fast-cgi and the apache server to help run websites under different php configurations.
So what gives with php, php-cli and the phpfarm?
I'm not sure about phpfarm, but do know of another solution ...
Multi
A tool for maintaining multiple installations of PHP in multiple configurations
https://github.com/datingvip/multi
This is a bit more user orientated, will allow you to build many configurations and versions of php, any tagged release of php, and any patched version from any fork of php-src.
In addition, because I wrote it, it will install pthreads for you.
git clone https://github.com/datingvip/multi
cd multi
VERSION=5.5.10 DBG=no-debug ZTS=zts ./php.multi
The above commands will yield an installation of PHP (in one suitable configuration, of one version) in /opt/php.
Look at php.defaults for configuration options and adjust before building
Should configuration fail on, for example, something related to a library like libxml2, it will usually be the case that
sudo apt-get install library-dev
Where library is replaced with the name of the library holding up the build, will fix the problem for you. If it does not, a quick google should get you going again.
Once the build is complete
source /path/to/multi/php.env 5.5.10
Note: multi will always install pthreads for any zts version automatically
I hope that gets you somewhere ...

Compiling a PHP extension as non-thread-safe

I am trying to compile the imagemagick (imagick) extension to use in a non-thread-safe environment on windows.
I am using PHP 5.3.10 and have set up Visual C++ express as my compiling environment.
The problem is that I am using a non-thread-safe version of PHP as a FCGI module in Apache 2.2.
Thus, my PHP is supplied with a php5.lib and not a php5ts.lib. I believe this is the reason why I am getting these errors:
imagick.obj : error LNK2019: unresolved external symbol __imp__tsrm_mutex_alloc referenced in function _zm_startup_imagick
I have only ever built and compiled things on linux, so am not too sure how to do this on a windows environment.
How can I compile the extension so that it is non-thread-safe?
I downloaded the threadsafe binary of PHP 5.3.10 to get a copy of php5ts.lib. I was then able to compile the extension.
I am guessing that setting the ZTS preprocessor directive to either 1 or 0 would cause the extension to compile as either threadsafe or non-thread-safe. (Not too sure about this, so if someone could let me know if this is correct or not, it would be much appreciated. :) )
I then set up a virtual machine running Windows 7 and installed the latest version of WAMP. Reason being that it used a threadsafe version of PHP.
I placed the dll in the ext folder in the PHP installation and enabled it in php.ini. However, even after trying both the ts and nts version in WAMP, I would get:
PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.3.10/ext/imagick.dll' - The specified module could not be found.
in Unknown on line 0
But the thing is that c:/wamp/bin/php/php5.3.10/ext/imagick.dll' does exist, and yes I have checked this a lot of times.
I then downgraded ImageMagick to 6.6.2-10-Q16, but still see the same problem.
The same issue occurs on my dev machine running a nts version of PHP 5.3.10 on Apache 2.2 (all installed manually).
Looks like I could be wrong regarding the ZTS preprocessor. If I set ZTS=0 and compile, using dependency walker on the compiled dll still shows that it requires php5ts.dll which is only present on threadsafe versions of PHP.
I did more tinkering with dependency walker and found that I had to statistically link to msvc100d.dll. I then removed ZTS in the preprocessor definition and was able to compile using php5.lib instead of php5ts.dll. I think this should get me a non-ts dll.
However, when loading the extension, I am still getting:
PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'imagick.dll' in Unknown on line 0
And errors from dependency walker:
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
Installed visual c++ express 2008 and compiled using platform toolkit v90, but still facing the same issues.
Any tips appreciated :)
Solution Found! See my answer.
Got it! I hope this can help those compiling php extensions on windows in the future. What I have done is based on: https://wiki.php.net/internals/windows/stepbystepbuild
Note: I read an answer on this site that said compiling PHP extensions by itself on windows is unsupported. Based on my experiments yesterday, it seems to be a lot of work as well, so I am using the PHP build process.
The best way is to use the PHP build process.
Install Visual C++ Express 2008 (any version will do, but express is free) and Windows SDK 6.1 (note that we want the 6.1 version not anything older or newer).
Install the SVN client tools if you haven't done so and restart for your PATH variable to take effect.
Get the PHP SDK binary tools and extract it to C:\php-sdk.
Start the CMD Shell under Microsoft Windows SDK v6.1 in your start menu and run cd C:\php-sdk.
Run setenv /x86 /xp /release this creates a 32-bit release. You can use /x64 to build a 64-bit release (I have not tried this).
run bin\phpsdk_setvars.bat
run bin\phpsdk_buildtree.bat php53dev
Download the PHP source code and extract it to C:\php-sdk\php53dev\vc9\x86 so that you end up with C:\php-sdk\php53dev\vc9\x86\php5.3-xyz
Download the latest deps and extract everything to C:\php-sdk\php53dev\vc9\x86. You may be prompted to overwrite any existing folders, so press yes.
run cd C:\php-sdk\php53dev\vc9\x86
Check out the latest version of your extension from the svn repository: svn co http://svn.php.net/repository/pecl/imagick/trunk pecl/imagick I am checking out imagick here.
Install any dependencies. In my case, I need to install ImageMagick, so I downloaded the latest recommended windows binary. You will need to restart after installation to update your PATH variable, but you can do this after you have compiled. Make sure you install the C/C++ headers and includes as well.
Copy the contents of the includes directory from the ImageMagick install directory to C:\php-sdk\php53dev\vc9\x86\deps\include.
Copy the contents of the lib directory from the ImageMagick install directory to C:\php-sdk\php53dev\vc9\x86\deps\lib
Now, let's build: run cd C:\php-sdk\php53dev\vc9\x86\php5.3-xyz then buildconf then configure --help. Look at the help properly. It will show you all config flags and any avaliable extensions to enabled. In my case, since I added imagick, I had an option called --with-imagick
Run config: configure --enable-cli --with-imagick=shared --disable-zts If you want to build a non-thread-safe binary use --disable-zts, otherwise remove that configuration flag. I am not sure why, but sometimes extensions use the --with-myextension flag and sometimes --enable-myextension, so check configure --help for the flag to use. If you add =shared after the extension flag, it will be compiled as a separate DLL, which si what we want.
Compile: run nmake then nmake snap.
Done :) Check C:\php-sdk\php53dev\vc9\x86\php-5.3.10\Release (non-thread-safe) or C:\php-sdk\php53dev\vc9\x86\php-5.3.10\Release_TS (thread-safe). Your compiled binaries should be in there. The compiled extensions (pecl), should be in a ZIP file similiar to pecl-5.3.10-nts-Win32-VC9-x86.zip. Open this file and extract the extensio DLL to your ext folder in your PHP installation.
Enable the PHP extension and restart your webserver. Run phpinfo() and check that the extension is enabled.
If the extension does not work properly, make sure you reboot to update your PATH variable. In my case, I need to have the imagemagick install directory in my PATH variable.
???
Profit!
Is there a reason you need to compile? Why not download? It's usually much simpler/quicker on Windows.
VC6: http://www.sk89q.com/2010/03/vc6-windows-binaries-for-imagick-2-3-0/
VC9: http://valokuva.org/builds/

Categories