In this post, we will see How To Fix “Error: libpq-fe.h: No Such File or Directory”.
There can be various formats of the error depending on the context of use. Couple of those are shown below –
error: libpq-fe.h: No such file or directory
Can't find the 'libpq-fe.h header
psycopg2 fatal error libpq-fe.h no such file or directory
cannot open include file 'libpq-fe.h' no such file or directory
This issue occurs while installing postgresql or psycopg2 if the steps are not followed properly.
if( aicp_can_see_ads() ) {
}
- Did you install pyscopg2 correctly ? Note that – it is a C wrapper around the libpq postgreSQL client library. And hence there are few things that you need to take care of. Follow the below steps if not done already.
To solve the error, use the below –
Option 1 : General Steps
if( aicp_can_see_ads() ) {
}
- Python header files – These are needed for pycopg2. So install these by installing the the package – python-dev or python3-dev as per the python version.
sudo apt-get install python-dev <- for python 2.7 sudo apt-get install python3.5-dev <- python 3.5 sudo apt-get install python3.9-dev <- python 3.9
Note : While doing this step, if you see an error – “Python.h: No such file or directory”, the fix is explained here – How To Fix – fatal error: Python.h: No such file or directory ?
- libpq header files – These are also needed for psycopg2. So install these by installing the package libpq-dev.
sudo apt-get install libpq-dev
- pg_config – It is installed by the libpq-dev package. But it might get missed from being added to the PATH. Get the path . Generally it is – /usr/lib/postgresql/X.Y/bin/. And then add it to the PATH.
$ export PATH=/usr/lib/postgresql/X.Y/bin/:$PATH
- Assuming you followed the above steps, run the below –
$ pip install psycopg2
Option 2: For Ubuntu
Use below –
if( aicp_can_see_ads() ) {
}
sudo apt install libpq-dev
Option 3:
Use below snippets
sudo yum install postgresql-devel yum install python-devel postgresql-devel
Option 4 : Using already installed libpq-fe.h correctly
There is possibility that libpq-fe.h is already in the system. But it is not being correctly pointed at. Follow below steps for that.
- Check libpq version and info
brew info libpq
- Locate libpq-fe.h
yum install mlocate sudo updateb locate libpq-fe.h
- Update ~/.bash_profile. pg_config is installed by the libpq-dev package. But it might get missed from being added to the PATH. Get the path . Generally it is – /usr/lib/postgresql/X.Y/bin/. And then add it to the PATH.
export PATH=/usr/lib/postgresql/X.Y/bin/:$PATH OR export PATH=/usr/pgsql-10/bin/:$PATH
if( aicp_can_see_ads() ) {
}
- As a next step just install psycopg2 or whatever you have being doing. That should work.
Option 5 : For Mac
brew install libpq
brew link --force libpq
gem install pg
if( aicp_can_see_ads() ) {
}
Hope this helps to solve the error.
Other Interesting Reads –
-
How to Send Large Messages in Kafka ?
-
Fix Spark Error – “org.apache.spark.SparkException: Failed to get broadcast_0_piece0 of broadcast_0”
-
How to Handle Bad or Corrupt records in Apache Spark ?
-
How to use Broadcast Variable in Spark ?
-
Best Practices for Dependency Problem in Spark
-
Sample Code – Spark Structured Streaming vs Spark Streaming
-
Sample Code for PySpark Cassandra Application
-
How to Enable UTF-8 in Python ?
-
How to log an error in Python ?
-
Sample Python Code To Read & Write Various File Formats (JSON, XML, CSV, Text)
-
How to Handle Errors and Exceptions in Python ?
-
How to Handle Bad or Corrupt records in Apache Spark ?
-
How To Fix – Partitions Being Revoked and Reassigned issue in Kafka ?
-
What Are The Most Important Metrics to Monitor in Kafka ?
-
How To Connect Local Python to Kafka on AWS EC2 ?
libpq-fe.h no such file or directory ,libpq-fe.h no such file or directory psycopg2 ,fatal error libpq-fe.h no such file or directory centos ,cannot open include file 'libpq-fe.h' no such file or directory ,psycopg libpq-fe.h no such file or directory ,ruby fatal error libpq-fe.h no such file or directory ,python psycopg2 libpq-fe.h no such file or directory ,r fatal error libpq-fe.h no such file or directory ,libpq-fe.h no such file or directory centos ,libpq-fe.h no such file or directory centos 7 , ,error libpq-fe.h no such file or directory ,psycopg2 fatal error libpq-fe.h no such file or directory ,fatal error libpq-fe.h no such file or directory centos ,psycopg fatal error libpq-fe.h no such file or directory ,ruby fatal error libpq-fe.h no such file or directory ,r fatal error libpq-fe.h no such file or directory , , ,libpq-fe.h no such file or directory centos 7 ,libpq-fe.h no such file or directory psycopg2 ,libpq-fe h no such file or directory windows ,libpq-dev ,pip libpq-fe.h: no such file or directory ,can't find the 'libpq-fe.h header ,fatal error: libpq-fe.h: no such file or directory ubuntu ,libpq-fe.h psycopg2 , , ,libpq-fe.h no such file or directory centos 7 ,fatal error: libpq-fe.h: no such file or directory ubuntu ,can't find the 'libpq-fe.h header ,fatal error libpq-fe.h no such file or directory psycopg2 ,libpq-dev ,configure: error: cannot find libpq-fe h please specify correct postgresql installation path ,libpq-fe.h psycopg2 ,libpq-fe h file not found mac , , , , ,libpq-fe.h ,libpq-fe.h no such file ,libpq-fe.h psycopg2 ,libpq-fe.h centos ,libpq-fe.h debian ,libpq-fe.h windows ,libpq-fe.h install ubuntu ,libpq-fe.h brew ,libpq-fe.h fedora ,libpq-fe.h alpine ,libpq-fe.h apt ,arch libpq-fe.h ,can't find the 'libpq-fe.h header alpine ,alpine cannot find libpq-fe.h ,brew libpq-fe.h ,bundle libpq-fe.h ,bundle install libpq-fe.h ,libpq-fe.h centos 8 ,libpq-fe.h centos 6 ,#include libpq-fe.h ^ compilation terminated ,cannot find libpq-fe.h ,cannot find libpq-fe.h php ,can't find libpq-fe.h in /usr/include ,can't find the 'libpq-fe.h header windows ,libpq-fe.h download ,postgresql libpq-fe.h download ,debian install libpq-fe.h ,debian stretch libpq-fe.h ,docker cannot find libpq-fe.h ,libpq-fe.h' file not found mac ,libpq-fe.h file not found ,libpq-fe.h functions ,libpq-fe.h github ,libpq-fe.h gem install pg ,gcc libpq-fe.h ,how to get libpq-fe.h ,libpq-fe.h header ,can't find the 'libpq-fe.h header ubuntu 20.04 ,can't find the 'libpq-fe.h header centos 8 ,opensuse can't find the 'libpq-fe.h header ,how to download libpq-fe.h ,libpq-fe.h install ,libpq-fe.h yum install ,#include libpq-fe.h psycopg2 ,pip install psycopg2 libpq-fe.h ,/usr/include/postgresql/libpq-fe.h ,libpq-fe.h missing ,libpq-fe.h missing linux ,libpq-fe.h not found ,libpq-fe.h postgresql ,libpq-fe.h pip ,psycopg libpq-fe.h ,python libpq-fe.h ,rails postgres libpq-fe.h ,r postgres libpq-fe.h ,libpq-fe.h ubuntu ,unable to find libpq-fe.h ,ubuntu cannot find libpq-fe.h , ,/usr/include/libpq-fe.h ,libpq-fe.h windows download ,libpq-fe.h what is ,libpq-fe.h no such file or directory psycopg2 ,libpq-fe.h no such file or directory centos ,libpq-fe.h no such file or directory windows ,libpq-fe.h no such file or directory r ,libpq-fe.h no such file or directory c++ ,libpq-fe.h no such file or directory redhat ,python libpq-fe.h no such file or directory ,python psycopg2 libpq-fe.h no such file or directory ,error libpq-fe.h no such file or directory ,fatal error libpq-fe.h no such file or directory #include libpq-fe.h ,fatal error postgresql/libpq-fe.h no such file or directory ,libpq-fe.h no such file or directory ,cannot open include file 'libpq-fe.h' no such file or directory ,fatal error libpq-fe.h no such file or directory psycopg2 ,fatal error libpq-fe.h no such file or directory centos ,psycopg fatal error libpq-fe.h no such file or directory ,ruby fatal error libpq-fe.h no such file or directory ,r fatal error libpq-fe.h no such file or directory ,fatal error libpq-fe.h no such file or directory ,configure error cannot find libpq-fe.h ,libpq-fe.h no such file or directory #include libpq-fe.h ,postgresql/libpq-fe.h no such file or directory ,can't find the 'libpq-fe.h header ubuntu ,libpq-fe.h no such file or directory ubuntu ,psycopg2 fatal error libpq-fe.h ,libpq.a ,pip install psycopg2 error libpq-fe.h ,libpq postgresql ,centos 7 libpq-fe.h ,can't find the 'libpq-fe.h header centos ,centos cannot find libpq-fe.h ,libpq-fe.h centos 7 ,can't find the 'libpq-fe.h header centos 7 ,libpq-dev for centos , , ,#include libpq-fe.h ^ compilation terminated ,configure error cannot find libpq-fe.h ,configure error could not find libpq-fe.h ,configure error could not find libpq-fe.h header ,configure error header file libpq-fe.h is required ,error 'libpq-fe.h' file not found ,error cannot find libpq-fe.h ,error libpq-fe.h no such file or directory ,fatal error 'libpq-fe.h' file not found ,fatal error libpq-fe.h ,fatal error libpq-fe.h no such file or directory #include libpq-fe.h ,fatal error libpq-fe.h no such file or directory centos ,fatal error postgresql/libpq-fe.h ,fatal error postgresql/libpq-fe.h no such file or directory ,libpq-fe.h error eclipse ,libpq-fe.h error error ,libpq-fe.h error example ,libpq-fe.h error exception ,libpq-fe.h error git ,libpq-fe.h error github ,libpq-fe.h error java ,libpq-fe.h error javascript ,libpq-fe.h error juniper ,libpq-fe.h error jupyter notebook ,libpq-fe.h error keras ,libpq-fe.h error kernel ,libpq-fe.h error key ,libpq-fe.h error kubernetes ,libpq-fe.h error linux ,libpq-fe.h error list ,libpq-fe.h error loading ,libpq-fe.h error log ,libpq-fe.h error query ,libpq-fe.h error queue ,libpq-fe.h error timeout ,libpq-fe.h error windows ,libpq-fe.h error windows 10 ,libpq-fe.h error xcode ,libpq-fe.h error xml ,libpq-fe.h error xpath ,libpq-fe.h error yaml ,libpq-fe.h error youtube ,libpq-fe.h error zero ,libpq-fe.h error zerodha ,libpq-fe.h error zip ,libpq-fe.h error zoom ,libpq-fe.h error zoominfo ,libpq-fe.h not found ,pip install psycopg2 error libpq-fe.h ,psycopg fatal error libpq-fe.h ,psycopg2 fatal error libpq-fe.h ,#include libpq-fe.h ,#include libpq-fe.h ^ compilation terminated ,#include libpq-fe.h psycopg2 ,alpine cannot find libpq-fe.h ,alpine libpq-fe.h ,arch libpq-fe.h ,brew libpq-fe.h ,bundle install libpq-fe.h ,bundle libpq-fe.h ,can't find libpq-fe.h in /usr/include ,can't find the 'libpq-fe.h ,can't find the 'libpq-fe.h header ,can't find the 'libpq-fe.h header alpine ,can't find the 'libpq-fe.h header centos 8 ,can't find the 'libpq-fe.h header mac ,can't find the 'libpq-fe.h header osx ,can't find the 'libpq-fe.h header ubuntu 20.04 ,can't find the 'libpq-fe.h header windows ,cannot find libpq-fe.h ,cannot find libpq-fe.h php ,centos 7 libpq-fe.h ,centos libpq-fe.h ,could not find libpq-fe.h ,debian install libpq-fe.h ,debian libpq-fe.h ,debian stretch libpq-fe.h ,docker cannot find libpq-fe.h ,download libpq-fe.h ,error 'libpq-fe.h' file not found ,example libpq-fe.h ,fatal error libpq-fe.h ,fatal error postgresql/libpq-fe.h ,find header checking for libpq-fe.h ,gcc libpq-fe.h ,gem pg libpq-fe.h ,header file libpq-fe.h is required ,how to download libpq-fe.h ,how to get libpq-fe.h ,how to install libpq-fe.h in ubuntu ,instalar libpq-fe.h ,libpq-fe.h ,libpq-fe.h alpine ,libpq-fe.h apt ,libpq-fe.h brew ,libpq-fe.h c ,libpq-fe.h centos ,libpq-fe.h centos 6 ,libpq-fe.h centos 7 ,libpq-fe.h centos 8 ,libpq-fe.h debian ,libpq-fe.h download ,libpq-fe.h fedora ,libpq-fe.h functions ,libpq-fe.h gem install pg ,libpq-fe.h github ,libpq-fe.h header ,libpq-fe.h install ,libpq-fe.h install ubuntu ,libpq-fe.h missing ,libpq-fe.h missing linux ,libpq-fe.h no such file ,libpq-fe.h not found ,libpq-fe.h pip ,libpq-fe.h postgresql ,libpq-fe.h psycopg2 ,libpq-fe.h r ,libpq-fe.h rpm ,libpq-fe.h ubuntu ,libpq-fe.h visual studio ,libpq-fe.h what is ,libpq-fe.h windows ,libpq-fe.h windows download ,libpq-fe.h yum install , libpq-fe.h' file not found mac ,missing libpq-fe.h ,no file libpq-fe.h in /usr/local/include ,no such file libpq-fe.h ,opensuse can't find the 'libpq-fe.h header ,pip install psycopg2 libpq-fe.h ,postgresql libpq-fe.h download ,psycopg fatal error libpq-fe.h ,psycopg libpq-fe.h ,psycopg2 fatal error libpq-fe.h ,psycopg2 libpq-fe.h ,python libpq-fe.h ,r postgres libpq-fe.h ,rails can't find the 'libpq-fe.h header ,rails postgres libpq-fe.h ,rhel 7 libpq-fe.h ,rpostgresql libpq-fe.h ,ubuntu cannot find libpq-fe.h ,ubuntu libpq-fe.h ,unable to find libpq-fe.h ,what is libpq-fe.h ,where is libpq-fe.h ,windows libpq-fe.h ,yum install libpq-fe.h ,yum libpq-fe.h , ,
libpq-fe.h error ,error 'libpq-fe.h' file not found ,fatal error libpq-fe.h ,psycopg2 fatal error libpq-fe.h ,psycopg fatal error libpq-fe.h ,fatal error postgresql/libpq-fe.h ,error libpq-fe.h no such file or directory ,fatal error libpq-fe.h no such file or directory #include libpq-fe.h ,#include libpq-fe.h ^ compilation terminated ,fatal error postgresql/libpq-fe.h no such file or directory ,error cannot find libpq-fe.h ,configure error cannot find libpq-fe.h ,configure error header file libpq-fe.h is required ,pip install psycopg2 error libpq-fe.h ,fatal error 'libpq-fe.h' file not found mac ,fatal error libpq-fe.h no such file or directory centos ,fatal error 'libpq-fe.h' file not found
if( aicp_can_see_ads() ) {
if( aicp_can_see_ads() ) {
}
}
As per this answer, I performed a series of prerequisite setups to be ready to pip install python3 packages.
However, when I ran
python3 -m pip install psycopg2
I got the following error:
Downloading/unpacking psycopg2
Downloading psycopg2-2.6.2.tar.gz (376kB): 376kB downloaded
Running setup.py (path:/tmp/pip-build-1ocbvumt/psycopg2/setup.py) egg_info for package psycopg2
Installing collected packages: psycopg2
Running setup.py install for psycopg2
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
building 'psycopg2._psycopg' extension
gcc -pthread -Wno-unused-result -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python34/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090212 -I/opt/rh/rh-python34/root/usr/include/python3.4m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:27:0:
./psycopg/psycopg.h:31:22: fatal error: libpq-fe.h: No such file or directory
#include <libpq-fe.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /opt/rh/rh-python34/root/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-1ocbvumt/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('rn', 'n'), __file__, 'exec'))" install --record /tmp/pip-rfdowyqt-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/psycopg1.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.4/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.4/psycopg2
creating build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_transaction.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_module.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/testutils.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_connection.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.4/psycopg2/tests
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/psycopg
gcc -pthread -Wno-unused-result -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python34/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6.2 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090212 -I/opt/rh/rh-python34/root/usr/include/python3.4m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.4/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:27:0:
./psycopg/psycopg.h:31:22: fatal error: libpq-fe.h: No such file or directory
#include <libpq-fe.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /opt/rh/rh-python34/root/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-1ocbvumt/psycopg2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('rn', 'n'), __file__, 'exec'))" install --record /tmp/pip-rfdowyqt-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-1ocbvumt/psycopg2
Storing debug log for failure in /root/.pip/pip.log
The summary is, I suppose: error: command 'gcc' failed with exit status 1
What else could I be missing on my system to enable an installation of psycopg2?
Содержание
- How To Fix – “Error: Libpq-fe.h: No Such File or Directory” ?
- How To Fix – “Error: Libpq-fe.h: No Such File or Directory” ?
- Option 1 : General Steps
- Option 2: For Ubuntu
- Option 3:
- Option 4 : Using already installed libpq-fe.h correctly
- fatal error: postgresql/libpq-fe.h: No such file or directory #17
- Comments
- Footer
- Не удается найти заголовок ‘libpq-fe.h при попытке установить гем pg
- 38 ответов
- Fatal error libpq fe h no such file or directory
- Fatal error libpq fe h no such file or directory
- Submit correction
How To Fix – “Error: Libpq-fe.h: No Such File or Directory” ?
How To Fix – “Error: Libpq-fe.h: No Such File or Directory” ?
In this post, we will see How To Fix “Error: libpq-fe.h: No Such File or Directory”.
There can be various formats of the error depending on the context of use. Couple of those are shown below –
This issue occurs while installing postgresql or psycopg2 if the steps are not followed properly.
- Did you install pyscopg2 correctly ? Note that – it is a C wrapper around the libpq postgreSQL client library. And hence there are few things that you need to take care of. Follow the below steps if not done already.
To solve the error, use the below –
Option 1 : General Steps
- Python header files – These are needed for pycopg2. So install these by installing the the package – python-dev or python3-dev as per the python version.
Note : While doing this step, if you see an error – “Python.h: No such file or directory”, the fix is explained here – How To Fix – fatal error: Python.h: No such file or directory ?
- libpq header files – These are also needed for psycopg2. So install these by installing the package libpq-dev.
- pg_config – It is installed by the libpq-dev package. But it might get missed from being added to the PATH. Get the path . Generally it is – /usr/lib/postgresql/X.Y/bin/. And then add it to the PATH.
- Assuming you followed the above steps, run the below –
Option 2: For Ubuntu
Option 3:
Use below snippets
Option 4 : Using already installed libpq-fe.h correctly
There is possibility that libpq-fe.h is already in the system. But it is not being correctly pointed at. Follow below steps for that.
Источник
fatal error: postgresql/libpq-fe.h: No such file or directory #17
I’ve just updated sqlpp11 and your project and I can’t compile it.
$ cmake ..
— The CXX compiler identification is GNU 5.3.0
— Check for working CXX compiler: /usr/bin/c++
— Check for working CXX compiler: /usr/bin/c++ — works
— Detecting CXX compiler ABI info
— Detecting CXX compiler ABI info — done
— Detecting CXX compile features
— Detecting CXX compile features — done
— Using /usr/bin/c++ (compiler id: GNU)
— Found Sqlpp11: /usr/local/include/sqlpp11
— Configuring done
— Generating done
— Build files have been written to: /home/capsel/libs/sqlpp11-connector-postgresql/build
[capsel@ai build]$ make
Scanning dependencies of target sqlpp-postgresql
[ 20%] Building CXX object src/CMakeFiles/sqlpp-postgresql.dir/bind_result.cpp.o
In file included from /home/capsel/libs/sqlpp11-connector-postgresql/src/bind_result.cpp:34:0:
/home/capsel/libs/sqlpp11-connector-postgresql/src/detail/prepared_statement_handle.h:35:33: fatal error: postgresql/libpq-fe.h: No such file or directory
compilation terminated.
src/CMakeFiles/sqlpp-postgresql.dir/build.make:62: recipe for target ‘src/CMakeFiles/sqlpp-postgresql.dir/bind_result.cpp.o’ failed
make[2]: *** [src/CMakeFiles/sqlpp-postgresql.dir/bind_result.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target ‘src/CMakeFiles/sqlpp-postgresql.dir/all’ failed
make[1]: *** [src/CMakeFiles/sqlpp-postgresql.dir/all] Error 2
Makefile:127: recipe for target ‘all’ failed
make: *** [all] Error 2
postgresql version is 9.5.2.
The text was updated successfully, but these errors were encountered:
My distribution holds postgres headers in postgresql directory (not in pgsql like you have, probably) you need to change the path to pgsql/libpq-fe.h (or something similar I don’t remember to exact directory name)
Could you try applying attached patch file to newest commit from branch master and compiling?
This is fixed in the last commit on the master branch.
© 2023 GitHub, Inc.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
Не удается найти заголовок ‘libpq-fe.h при попытке установить гем pg
Я использую предварительную версию Ruby on Rails 3.1. Мне нравится использовать PostgreSQL, но проблема заключается в установке pg gem. Это дает мне следующую ошибку:
Как мне решить эту проблему?
38 ответов
В Ubuntu похоже, что заголовок является частью пакета libpq-dev (по крайней мере, в следующих версиях Ubuntu: 11.04 (Natty Narwhal), 10.04 (Lucid Lynx), 11.10 (Oneiric Ocelot), 12.04 (Precise Pangolin), 14.04 ( Trusty Tahr) и 18.04 (бионический бобр)):
Поэтому попробуйте установить libpq-dev или его эквивалент для вашей ОС:
- Для систем Ubuntu/Debian: sudo apt-get install libpq-dev
- В системах Red Hat Linux (RHEL): yum install postgresql-devel
- Для Mac Homebrew: brew install postgresql
- Для Mac MacPorts PostgreSQL: gem install pg — —with-pg-config=/opt/local/lib/postgresql[version number]/bin/pg_config
- Для OpenSuse: zypper in postgresql-devel
- Для ArchLinux: pacman -S postgresql-libs
/Dropbox_not_syncd/webs/3/linker$ gem install libpq-dev ERROR: Could not find a valid gem ‘libpq-dev’ (>= 0) in any repository [email protected]:
), но он не будет установлен E: Невозможно исправить проблемы, у вас есть поврежденные пакеты.
В macOS (ранее Mac OS X и OS X) используйте Homebrew для установки соответствующих заголовков:
а затем работает
В качестве альтернативы, вместо установки всего postgresql , вы можете brew install libpq и экспортировать правильные PATH и PKG_CONFIG_PATH как описано в разделе «Предостережения».
Я также попытался сделать gem install libpq-dev , но я получил эту ошибку:
Однако я обнаружил, что работа с sudo apt-get (которую я пытаюсь избежать с помощью Ruby on Rails) работает, т.е.
то я смог сделать
Я мог бы решить это по-другому. Я не нашел библиотеку в своей системе. Таким образом, я установил его с помощью приложения с основного сайта PostgreSQL. В моем случае (OS X) я нашел файл под /Library/PostgreSQL/9.1/include/ после завершения установки. Вы также можете иметь файл в другом месте в зависимости от вашей системы, если у вас уже установлен PostgreSQL.
Благодаря этой ссылке как добавить дополнительный путь для установки gem, я могу указать камень на lib с помощью этой команды:
После этого он работает, потому что теперь он знает, где найти недостающую библиотеку. Просто замените путь на нужное место для вашего libpq-fe.h
Не удается найти заголовок libpq-fe.h
У меня был успех на CentOS 7.0.1406, выполнив следующие команды:
В качестве альтернативы вы можете настроить подключаемый модуль, чтобы всегда устанавливать pg с этими параметрами (полезно для запуска диспетчера в средах развертывания),
- bundle config build.pg —with-pg-config=/usr/pgsql-9.4/bin/pg_config
/ .bundle / config, поэтому она не будет найдена, если вы запустите конфигурацию комплекта при входе в систему от имени пользователя root, но пакет будет запущен (например, с помощью capistrano) пользователем ‘deploy’.
Только для записи:
Приложение Ruby on Rails 4 в OS X с PostgresApp (в этом случае нужна версия 0.17.1 — вид старого проекта):
В Mac OS X выполните следующие действия:
***/path/to/pg_config*** — путь к pg_config
В моем случае это был пакет postgresql-server-dev-8.4 (я нахожусь Ubuntu 11.04 (Natty Narwhal), 64 бит).
Правильный ответ для пользователей Mac с помощью Postgres.app заключается в создании против libpq , поставляемого с этим пакетом. Например, с выпуском 9.4 (текущий на момент написания) все, что вам нужно, это:
Это сохранит ваш pg gem в синхронизации с точно установленной версией PostgreSQL. В этом случае установка чего-то из Homebrew — это отходы.
У меня была такая же проблема на Amazon Linux. Я мог бы найти заголовок libpq-fe.h , но почему-то это не сработало.
Он исходил из разных версий пакетов, которые были установлены разными пользователями на машине. Были установлены PostgreSQL 9.2 и PostgreSQL 9.3. Итак, убедитесь, что ваша версия PostgreSQL перед включением библиотек.
Для меня волшебная командная строка:
Более общий ответ для любого дистрибутива на основе Debian (который включает Ubuntu) заключается в следующем. Сначала установите пакет apt-file с правами root:
Это позволяет вам искать пакеты, содержащие файл. Затем обновите свою базу данных с помощью
(это можно запустить как обычный пользователь). Затем найдите отсутствующий заголовок, используя:
На моей машине это дает:
На Mac я решил использовать этот код:
Недавно я обновился до Mac X v10.10 (Yosemite) и с трудом создавал драгоценный камень pg .
Сообщаемая ошибка была типичной:
Мое решение было gem uninstall pg , а затем bundle update pg , чтобы заменить драгоценный камень последним. Я выполнил brew update; brew upgrade после установки Yosemite, чтобы получить последние версии пакетов, которые я установил ранее.
Я нашел этот ответ, и это был единственный, который работал у меня (Mac OS) — после исследования около двух дней:
У меня была такая же проблема в Mac OS, но я быстро установил жемчуг PostgreSQL, используя в терминале следующее:
(я сначала установил PostgreSQL с brew install postgresql .)
Для MacOS без установки сервера PostgreSQL:
Я запускаю Postgres.app на Mac, и мне приходилось
В CentOS я установил libpq-dev package , используя следующую команду
Выполнение gem install pg возвращает ту же ошибку, что и » No pg_config. trying anyway. If building fails, please try again with —with-pg-config=/path/to/pg_config «.
Установка драгоценного камня, как показано ниже, решена моя проблема
В Ubuntu установите «libpq-dev», чтобы избавиться от этой проблемы.
У меня это было только на OSX, работающем brew и [email protected] .
Мое исправление было следующим:
Я, наконец, решил эту проблему, но не использовал ранее описанные методы.
Используя brew install postgresql , я выясню, что он уже был установлен, но не связан.
Узнайте, где установлен PostgreSQL, и удалите его,
Затем brew install postgresql снова,
brew link postgresql
Местоположение libpq-fe.h зависит от того, где установлена ваша установка PostgreSQL (которая зависит от того, как вы ее установили). Используйте locate (http://en.wikipedia.org/wiki/Locate_%28Unix%29), чтобы найти файл libpq-fe.h на вашем компьютере. Если он существует, он будет находиться в каталоге include вашей установки PostgreSQL.
Каталог bin , содержащий pg_config , будет находиться в том же каталоге, что и каталог include . Как следует из этой ошибки, используйте параметр —with-pg-config для установки драгоценного камня:
Обратите внимание, что вам может потребоваться запустить updatedb , если вы никогда не использовали locate , или если вы не обновили его после установки PostgreSQL.
В CentOS 6.5 (Squeeze) я создал файл:
Обратите внимание, что вы должны установить свой путь PostgreSQL с файлом pg_config. Вы можете найти это с помощью команды:
и попробуйте выполнить команду еще раз.
Примечание. В любое время, когда вы меняете конфигурацию Bash — меняете конфигурацию profile.d — вы должны перезагрузить Bash.
Источник
Fatal error libpq fe h no such file or directory
Чтобы собрать (то есть, скомпилировать и скомпоновать) программу, использующую libpq , вы должны проделать следующие действия:
Включите заголовочный файл libpq-fe.h :
Если вы не сделаете этого, обычно вас ждут примерно такие сообщения об ошибках от компилятора:
Сообщите вашему компилятору каталог, в котором установлены заголовочные файлы PostgreSQL , передав ему параметр -I каталог . (В некоторых случаях компилятор сам может обращаться к нужному каталогу, так что этот параметр можно опустить.) Например, ваша команда компиляции может быть такой:
Если вы используете скрипты сборки Makefile, добавьте этот параметр в переменную CPPFLAGS :
Если существует возможность, что вашу программу будут компилировать другие пользователи, то путь к каталогу не следует жёстко задавать таким образом. Вместо этого вы можете воспользоваться утилитой pg_config и узнать, где в локальной системе находятся заголовочные файлы, следующим образом:
Если у вас установлена программа pkg-config , вместо этого вы можете выполнить:
Заметьте, что при этом перед путём сразу будет добавлен ключ -I .
Если требуемый параметр не будет передан компилятору, вы получите примерно такое сообщение об ошибке:
При компоновке окончательной программы добавьте параметр -lpq , чтобы была подключена библиотека libpq , а также параметр -L каталог , указывающий на каталог, в котором находится libpq . (Опять же, компилятор будет просматривать определённые каталоги по умолчанию.) Для максимальной переносимости указывайте ключ -L перед параметром -lpq . Например:
Каталог с библиотекой можно узнать, так же используя pg_config :
Или с помощью той же программы pkg-config :
Заметьте, что и в этом случае выводится полностью сформированный параметр, а не только путь.
В случае проблем в этой области возможны примерно такие сообщения об ошибках:
Они означают, что вы забыли добавить параметр -lpq .
Такая ошибка означает, что вы забыли добавить ключ -L или не указали правильный каталог.
Источник
Fatal error libpq fe h no such file or directory
To build (i.e., compile and link) a program using libpq you need to do all of the following things:
Include the libpq-fe.h header file:
If you failed to do that then you will normally get error messages from your compiler similar to:
Point your compiler to the directory where the PostgreSQL header files were installed, by supplying the -I directory option to your compiler. (In some cases the compiler will look into the directory in question by default, so you can omit this option.) For instance, your compile command line could look like:
If you are using makefiles then add the option to the CPPFLAGS variable:
If there is any chance that your program might be compiled by other users then you should not hardcode the directory location like that. Instead, you can run the utility pg_config to find out where the header files are on the local system:
If you have pkg-config installed, you can run instead:
Note that this will already include the -I in front of the path.
Failure to specify the correct option to the compiler will result in an error message such as:
When linking the final program, specify the option -lpq so that the libpq library gets pulled in, as well as the option -L directory to point the compiler to the directory where the libpq library resides. (Again, the compiler will search some directories by default.) For maximum portability, put the -L option before the -lpq option. For example:
You can find out the library directory using pg_config as well:
Or again use pkg-config :
Note again that this prints the full options, not only the path.
Error messages that point to problems in this area could look like the following:
This means you forgot -lpq .
This means you forgot the -L option or did not specify the right directory.
| Prev | Up | Next |
| 34.20. Behavior in Threaded Programs | Home | 34.22. Example Programs |
Submit correction
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.
Copyright © 1996-2023 The PostgreSQL Global Development Group
Источник
Содержание
- How To Fix – “Error: Libpq-fe.h: No Such File or Directory” ?
- How To Fix – “Error: Libpq-fe.h: No Such File or Directory” ?
- Option 1 : General Steps
- Option 2: For Ubuntu
- Option 3:
- Option 4 : Using already installed libpq-fe.h correctly
- Одновременная работа php 5.2 и php 5.3 на Ubuntu 12.04
How To Fix – “Error: Libpq-fe.h: No Such File or Directory” ?
How To Fix – “Error: Libpq-fe.h: No Such File or Directory” ?
In this post, we will see How To Fix “Error: libpq-fe.h: No Such File or Directory”.
There can be various formats of the error depending on the context of use. Couple of those are shown below –
This issue occurs while installing postgresql or psycopg2 if the steps are not followed properly.
- Did you install pyscopg2 correctly ? Note that – it is a C wrapper around the libpq postgreSQL client library. And hence there are few things that you need to take care of. Follow the below steps if not done already.
To solve the error, use the below –
Option 1 : General Steps
- Python header files – These are needed for pycopg2. So install these by installing the the package – python-dev or python3-dev as per the python version.
Note : While doing this step, if you see an error – “Python.h: No such file or directory”, the fix is explained here – How To Fix – fatal error: Python.h: No such file or directory ?
- libpq header files – These are also needed for psycopg2. So install these by installing the package libpq-dev.
- pg_config – It is installed by the libpq-dev package. But it might get missed from being added to the PATH. Get the path . Generally it is – /usr/lib/postgresql/X.Y/bin/. And then add it to the PATH.
- Assuming you followed the above steps, run the below –
Option 2: For Ubuntu
Option 3:
Use below snippets
Option 4 : Using already installed libpq-fe.h correctly
There is possibility that libpq-fe.h is already in the system. But it is not being correctly pointed at. Follow below steps for that.
Источник
Одновременная работа php 5.2 и php 5.3 на Ubuntu 12.04
1 час. Установка производилась на работающем dev сервере.
Актуально для разработчиков под Drupal 6 и 7 и всех кто всё еще использует PHP 5.2.
Не смотря на то, что Drupal 7 нормально работает на PHP 5.3, Drupal 6 по-прежнему чувствует себя гораздо лучше с PHP 5.2. Хотя ядро D6 давно совместимо с PHP 5.3, у большинства разработчиков возникает невыносимая икота, когда они получают запрос о обновлении модуля до новой версии. Поэтому разработка для D7 и D6, становится более удобной при одновременной работе обоих версий PHP. (прим. таже это невероятно упрощает администрирование и сопровождение dev серверов путем исключения сервера с 5.2)
Одним из способов решения данной проблемы является использование mod_php5 для обработки скриптов PHP 5.3, и использования FastCGI модуля при необходимости обработки скриптов под PHP 5.2. Соответственно, для Ubuntu 12.04, можно установить PHP 5.3 из репозитория и затем вручную скомпилировать и установить PHP 5.2. Установка PHP 5.3 из репозиториев является довольно простой операцией, которую вы, скорее всего, уже выполняли, так что давайте просто решим, что она выглядит примерно так:
sudo apt-get install php5 php5-common php5-cli php5-dev php5-mysql phpmyadmin php5-pgsql phppgadmin php5-gd php5-mcrypt php5-curl php-pear libapache2-mod-php5 php5-xdebug php5-codesniffer
Примечательно, хотя этот пост сосредоточен на том как установить PHP 5.2, обе версии работают одинаково хорошо.
Загрузка исходного кода PHP
Я первоначально начал с версии 5.2.10 (эта версия была установлена на наших stage серверах) но был внеезапно остановлен ошибкой OpenSSL на этапе конфигурирования.
/usr/include/openssl/conf.h:132:7: note: expected ‘struct lhash_st_CONF_VALUE *’ but argument is of type ‘int *’
make: *** [ext/openssl/openssl.lo] Error 1
для которой я не смог найти работающего фикса (относительно легко применимого), но этап выполнился с самой последней версией 5.2.17, выдав вместо этой, кучу других ошибок.
Что ж, загрузим и распакуем исходники в папку
/Downloads/php-5.2.17
wget museum.php.net/php5/php-5.2.17.tar.gz
tar zxf php-5.2.17.tar.gz
Пришло время приступить к конфигурированию пакета. Ниже приведен пример вызова скрипта ./configure:
Очевидно, что вы можете приспособить его к конкретным потребностям путем добавления и/или удаления соответствующих опций. Вы можете узнать больше о опциях которые вам нужны (или не нужны) в документации для PHP.
Итак, это, вероятно, не работает из коробки, не так ли? В большинстве случаев причина в отсутствующих зависимостях. Вы можете попробовать решить эту проблему одним выстрелом, если вы не слишком беспокоитесь об установке лишних библиотек и пакетов:
sudo apt-get install libxml2-dev libpcre3-dev libbz2-dev libcurl4-openssl-dev libdb4.8-dev libjpeg-dev libpng12-dev libxpm-dev libfreetype6-dev libmysqlclient-dev postgresql-server-dev-9.1 libt1-dev libgd2-xpm-dev libgmp-dev libsasl2-dev libmhash-dev unixodbc-dev freetds-dev libpspell-dev libsnmp-dev libtidy-dev libxslt1-dev libmcrypt-dev
Вы также можете исправлять ошибки отсутствующих зависимостей одну за другой, и устанавливать только те пакеты, которые действительно необходимы.
Давайте рассмотрим некоторые из возможных ошибок, (вы можете перейти к следующему разделу, если скрипт ./configure выполнен без ошибок и получено сообщение
Thank you for using PHP at the end of its execution
configure: error: xml2-config not found. Please check your libxml2 installation.
Эта ошибка предлагает нам проверить наличие пакета libxml2. В действительности же, это значит, что отсутствует его dev версия.
Давайте найдем доступные пакеты, которые могут помочь решить данную проблему:
$ apt-cache search libxml2 | grep dev
libcroco3-dev — Cascading Style Sheet (CSS) parsing and manipulation toolkit
libxml++2.6-dev — C++ interface to the GNOME XML library (libxml2)
libxml2-dev — Development files for the GNOME XML library
libgdome2-cpp-smart-dev — C++ bindings for GDome2 DOM implementation
libgdome2-dev — Development files for libgdome2
libgdome2-ocaml-dev — OCaml bindings for GDome2 DOM implementation
libgtkmathview-dev — rendering engine for MathML documents
libsp-gxmlcpp-dev — S+P C++ wrapper for Gnome libxml2/libxslt
Нас интересует libxml2-dev, устанавливаем его:
sudo apt-get install libxml2-dev
Такая же процедура применяется для всех отсутствующих библиотек, поэтому я приведу только окончательные команды установки:
configure: error: Could not find pcre.h in /usr
sudo apt-get install libpcre3-dev
configure: error: Please reinstall the BZip2 distribution
sudo apt-get install libbz2-dev
configure: error: Please reinstall the libcurl distribution — easy.h should be in /include/curl/
sudo apt-get install libcurl4-openssl-dev
configure: error: DBA: Could not find necessary header file(s).
checking for db4 major version… configure: error: Header contains different version
sudo apt-get install libdb4.8-dev
configure: error: libjpeg.(a|so) not found.
sudo apt-get install libjpeg-dev
configure: error: libpng.(a|so) not found.
sudo apt-get install libpng12-dev
configure: error: libXpm.(a|so) not found.
sudo apt-get install libxpm-dev
configure: error: freetype.h not found.
sudo apt-get install libfreetype6-dev
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
sudo apt-get install postgresql-server-dev-9.1
checking for FreeType 1 support… no — FreeType 2.x is to be used instead
configure: error: Your t1lib distribution is not installed correctly. Please reinstall it.
sudo apt-get install libt1-dev
configure: error: Unable to find gd.h anywhere under /usr
sudo apt-get install libgd2-xpm-dev
configure: error: Unable to locate gmp.h
sudo apt-get install libgmp-dev
configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!
sudo apt-get install libmysqlclient-dev
configure: error: sasl.h not found!
sudo apt-get install libsasl2-dev
configure: error: Please reinstall libmhash — I cannot find mhash.h
sudo apt-get install libmhash-dev
checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
sudo apt-get install unixodbc-dev
configure: error: Directory /usr is not a FreeTDS installation directory
sudo apt-get install freetds-dev
configure: error: Cannot find pspell
sudo apt-get install libpspell-dev
configure: error: SNMP sanity check failed. Please check config.log for more information.
sudo apt-get install libsnmp-dev
configure: error: Cannot find libtidy
sudo apt-get install libtidy-dev
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
sudo apt-get install libxslt1-dev
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
sudo apt-get install libmcrypt-dev
configure: error: Cannot find OpenSSL’s libraries
Добавьте следующее в опции ./configure:
—with-libdir=/lib/x86_64-linux-gnu
configure: error: You’ve configured extension pdo_sqlite to build statically, but it depends on extension pdo, which you’ve configured to build shared. You either need to build pdo_sqlite shared or build pdo statically for the build to be successful.
Добавьте следующее в опции ./configure
—with-pdo-sqlite=shared
—with-sqlite=shared
Make
Все настроено правильно и без ошибок? Тогда пришло время для компиляции (и чашечки кофе во время его выполнения):
sudo make
Теперь можно, попивая кофе, ждать приближение ошибок.
Да, весьма вероятно, что здесь все может пойти наперекосяк.
Вот две ошибки и один ворнинг, которые вы всего скорее всего получите:
ext/openssl/.libs/xp_ssl.o: In function `php_openssl_setup_crypto’:
ext/openssl/xp_ssl.c:357: undefined reference to `SSLv2_server_method’
ext/openssl/xp_ssl.c:337: undefined reference to `SSLv2_client_method’
Это связано с багом #54736 которые лекго решаются применением патча прикрепленного к этому багрепорту
Скачайте этот патч в папку
/Downloads/php-5.2.17 и выполните следующее:
patch -p1
Вы должны увидеть сообщение об успешном применении патча, наподобии этого:
patching file ext/openssl/xp_ssl.c
Hunk #1 succeeded at 332 (offset 4 lines).
Hunk #2 succeeded at 354 (offset 4 lines).
Hunk #3 succeeded at 583 (offset -50 lines).
Hunk #4 succeeded at 819 (offset -98 lines).
ext/gmp/gmp.c: In function ‘zif_gmp_random’:
ext/gmp/gmp.c:1399:69: error: ‘__GMP_BITS_PER_MP_LIMB’ undeclared (first use in this function)
ext/gmp/gmp.c:1399:69: note: each undeclared identifier is reported only once for each function it appears in
Пришло время исправить баг #50990
В одном из комментариев susan dot smith dot dev at gmail dot com предлагается следующее работающее решение, которое делает магию:
Я решила проблему заменой устаревшей постоянной определения __GMP_BITS_PER_MP_LIMB на GMP_LIMB_BITS, которая присутствует во всех предыдущих версиях и MPIR определяет тоже.
Вам нужно отредактировать файл ext/gmp/gmp.c и заменить __GMP_BITS_PER_MP_LIMB на GMP_LIMB_BITS. В моем случае это было строке 1399.
ext/zip/lib/.libs/zip_dirent.o: In function `memset’:
/usr/include/x86_64-linux-gnu/bits/string3.h:82: warning: memset used with constant zero length parameter; this could be due to transposed parameters
Последний баг #53568 который довольно легко исправляется: откройте файл ext/zip/lib/zip_dirent.c и замените строкй 478:
memset(&tm, sizeof(tm), 0);
на
memset(&tm, 0, sizeof(tm));
Больше ошибок нет!
Install
Простейший вариант установки вашей блеcтящей новой версии PHP 5.2 является следующая команда:
sudo make install
Кроме того, если вы планируете повторить ту же установку еще раз на других машинах, или просто хотите сохранить файл пакета установки на будущее, вы можете запустить:
sudo checkinstall
которая вместе с установкой PHP? также создаст deb пакет в текущем каталоге.
Теперь, какой бы путь вы не выбрали, у вас установленЗРЗ 5.2 в /usr/bin/php52
Конфигурационные файлы Apache
Конфигурационный каталог /etc/php52/apache2/ уже должен быть создан в процессе установки (создайте его, если он отсутствует). Теперь нужно настроить PHP 5.2 на использование тех же расширений и модулей, которые использует PHP 5.3,
sudo ln -s /etc/php5/conf.d /etc/php52
sudo ln -s /etc/php5/cli /etc/php52
Скопируйте файл php.ini-recommended в новый каталог (который будет определен в следующем шаге)
sudo cp php.ini-recommended /etc/php52/apache2/php.ini
и если нужно, внесите необходимые настройки.
Apache и FastCGI
Следующая вещь, которую мы сделаем, будет настройка apache для запуска PHP 5.2 используя FastCGI. Начнем установку fastcgi модуля:
sudo apt-get install libapache2-mod-fastcgi
Убедитесь, что все требуемые модули включены и перезапустите Apache:
sudo a2enmod cgi fastcgi actions
sudo service apache2 restart
Создайте исполняемый скрипт php52-cgi для запуска FastCGI версии PHP и поместите его в /usr/lib/cgi-bin/:
#!/bin/sh
PHPRC=»/etc/php52/apache2/»
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /usr/bin/php52/php-cgi
PHPRC этот параметр указывает на php.ini
PHP_FCGI_CHILDREN количество потоков
PHP_FCGI_MAX_REQUESTS лимит запросов
Вы можете узнать больше об этом на сайте FastCGI.
Дайте права на запуск:
sudo chmod +x /usr/lib/cgi-bin/php52-cgi
Наконец создайте новый файл /etc/apache2/php52.conf который будет использоваться для виртуальных хостов, которые требую использования PHP 5.2:
# Include file for virtual hosts that need to run PHP 5.2
ScriptAlias /php52-cgi /usr/lib/cgi-bin/php52-cgi
Action application/x-httpd-php5 /php52-cgi
AddHandler application/x-httpd-php5 .php
FilesMatch переопределяет обработчик php файлов.
ScriptAlias задет путь к CGI скрипту
AddHandler регистрирует новый обработчик
Action активизирует CGI-скрипт для работы с файлами переданных от обработчика.
Осталось только одно: для всех хостов, для которых вы хотите использовать PHP 5.2 нужно добавить в конфигурационный файл следующую строку:
Include php52.conf
и перегрузить новую конфигурацию:
sudo service apache2 reload
Поздравляю! Теперь у вас есть есть сервер с одновременно работающими версиями PHP 5.2 и PHP 5.3!
Источник
Development Versions:
devel
To build (i.e., compile and link) a program using libpq you need to do all of the following things:
-
Include the
libpq-fe.hheader file:#include <libpq-fe.h>
If you failed to do that then you will normally get error messages from your compiler similar to:
foo.c: In function `main': foo.c:34: `PGconn' undeclared (first use in this function) foo.c:35: `PGresult' undeclared (first use in this function) foo.c:54: `CONNECTION_BAD' undeclared (first use in this function) foo.c:68: `PGRES_COMMAND_OK' undeclared (first use in this function) foo.c:95: `PGRES_TUPLES_OK' undeclared (first use in this function)
-
Point your compiler to the directory where the PostgreSQL header files were installed, by supplying the
-Ioption to your compiler. (In some cases the compiler will look into the directory in question by default, so you can omit this option.) For instance, your compile command line could look like:directorycc -c -I/usr/local/pgsql/include testprog.c
If you are using makefiles then add the option to the
CPPFLAGSvariable:CPPFLAGS += -I/usr/local/pgsql/include
If there is any chance that your program might be compiled by other users then you should not hardcode the directory location like that. Instead, you can run the utility
pg_configto find out where the header files are on the local system:$pg_config --includedir/usr/local/includeIf you have
pkg-configinstalled, you can run instead:$pkg-config --cflags libpq-I/usr/local/includeNote that this will already include the
-Iin front of the path.Failure to specify the correct option to the compiler will result in an error message such as:
testlibpq.c:8:22: libpq-fe.h: No such file or directory
-
When linking the final program, specify the option
-lpqso that the libpq library gets pulled in, as well as the option-Lto point the compiler to the directory where the libpq library resides. (Again, the compiler will search some directories by default.) For maximum portability, put thedirectory-Loption before the-lpqoption. For example:cc -o testprog testprog1.o testprog2.o -L/usr/local/pgsql/lib -lpq
You can find out the library directory using
pg_configas well:$pg_config --libdir/usr/local/pgsql/libOr again use
pkg-config:$pkg-config --libs libpq-L/usr/local/pgsql/lib -lpqNote again that this prints the full options, not only the path.
Error messages that point to problems in this area could look like the following:
testlibpq.o: In function `main': testlibpq.o(.text+0x60): undefined reference to `PQsetdbLogin' testlibpq.o(.text+0x71): undefined reference to `PQstatus' testlibpq.o(.text+0xa4): undefined reference to `PQerrorMessage'
This means you forgot
-lpq./usr/bin/ld: cannot find -lpq
This means you forgot the
-Loption or did not specify the right directory.
