pgRouting / osm2pgrouting

Import tool for OpenStreetMap data to pgRouting database
https://pgrouting.org
GNU General Public License v2.0
292 stars 110 forks source link

libpq-fe.h problem in stack exchange #74

Open cvvergara opened 9 years ago

cvvergara commented 9 years ago

Joseph post

I'm trying to install osm2pgrouting. I have installed all the required packages and I also have changed the #include "libpq-fe.h" to #include postgresql/libpq-fe.h" in the src/Export2DB.h. However when I'm trying to do "make", I get this error:

Linking CXX executable osm2pgrouting
CMakeFiles/osm2pgrouting.dir/src/Export2DB.cpp.o: In function `Export2DB::~Export2DB()':
Export2DB.cpp:(.text+0x2ea): undefined reference to `PQfinish'
CMakeFiles/osm2pgrouting.dir/src/Export2DB.cpp.o: In function `Export2DB::connect()':
Export2DB.cpp:(.text+0x38c): undefined reference to `PQconnectdb'
Export2DB.cpp:(.text+0x3a2): undefined reference to `PQstatus'
CMakeFiles/osm2pgrouting.dir/src/Export2DB.cpp.o: In function `Export2DB::createTables()':
Export2DB.cpp:(.text+0x46f): undefined reference to `PQexec'
Export2DB.cpp:(.text+0x47f): undefined reference to `PQresultStatus'
Export2DB.cpp:(.text+0x49b): undefined reference to `PQerrorMessage'
Export2DB.cpp:(.text+0x4d1): undefined reference to `PQclear'
Export2DB.cpp:(.text+0x5f2): undefined reference to `PQexec'
Export2DB.cpp:(.text+0x602): undefined reference to `PQresultStatus'
Export2DB.cpp:(.text+0x618): undefined reference to `PQresultStatus'
Export2DB.cpp:(.text+0x636): undefined reference to `PQerrorMessage'
Export2DB.cpp:(.text+0x66c): undefined reference to `PQclear'
Export2DB.cpp:(.text+0x6fd): undefined reference to `PQexec'
Export2DB.cpp:(.text+0x70d): undefined reference to `PQresultStatus'
Export2DB.cpp:(.text+0x729): undefined reference to `PQerrorMessage'
Export2DB.cpp:(.text+0x75f): undefined reference to `PQclear'
Export2DB.cpp:(.text+0x7e7): undefined reference to `PQexec'
Export2DB.cpp:(.text+0x7f7): undefined reference to `PQresultStatus'
Export2DB.cpp:(.text+0x813): undefined reference to `PQerrorMessage'
Export2DB.cpp:(.text+0x849): undefined reference to `PQclear'
Export2DB.cpp:(.text+0x8cb): undefined reference to `PQexec'
Export2DB.cpp:(.text+0x8db): undefined reference to `PQresultStatus'
Export2DB.cpp:(.text+0x8f7): undefined reference to `PQerrorMessage'
Export2DB.cpp:(.text+0x92d): undefined reference to `PQclear'
Export2DB.cpp:(.text+0x9af): undefined reference to `PQexec'
Export2DB.cpp:(.text+0x9bf): undefined reference to `PQresultStatus'
Export2DB.cpp:(.text+0x9db): undefined reference to `PQerrorMessage'
Export2DB.cpp:(.text+0xa11): undefined reference to `PQclear'
Export2DB.cpp:(.text+0xa93): undefined reference to `PQexec'
Export2DB.cpp:(.text+0xaa3): undefined reference to `PQresultStatus'
...
sanak commented 9 years ago

Above issue seems to be same as #59 . @aj07mm comment: https://github.com/pgRouting/osm2pgrouting/issues/59#issuecomment-105255976

I fixed it already, so I think that using develop branch will solve the problem. My comment: https://github.com/pgRouting/osm2pgrouting/issues/59#issuecomment-105715588 My pull request: https://github.com/pgRouting/osm2pgrouting/pull/61

cvvergara commented 9 years ago

The just used master and it didn't generate me the problem, but using develop it did.

sanak commented 9 years ago

Oh, okay. (Sorry for unchecking the following link.) http://gis.stackexchange.com/questions/149426/error-while-installing-osm2pgrouting-ubuntu14-04

Then, my fix may be the issue's cause... I will check it also on my Ubuntu VirtualBox environment.

cvvergara commented 9 years ago

in master

mapas@cvergara:~/osm2pgrouting/osm2pgrouting_repo/build$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

mapas@cvergara:~/osm2pgrouting/osm2pgrouting_repo/build$ make
Scanning dependencies of target osm2pgrouting
[  7%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/XMLParser.cpp.o
[ 14%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/OSMDocumentParserCallback.cpp.o
[ 21%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/Type.cpp.o
[ 28%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/osm2pgrouting.cpp.o
[ 35%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/Node.cpp.o
[ 42%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/Way.cpp.o
[ 50%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/Relation.cpp.o
[ 57%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/math_functions.cpp.o
[ 64%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/Class.cpp.o
[ 71%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/utils.cpp.o
[ 78%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/OSMDocument.cpp.o
[ 85%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/ConfigurationParserCallback.cpp.o
[ 92%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/Export2DB.cpp.o
[100%] Building CXX object CMakeFiles/osm2pgrouting.dir/src/Configuration.cpp.o
Linking CXX executable osm2pgrouting
[100%] Built target osm2pgrouting
mapas@cvergara:~/osm2pgrouting/osm2pgrouting_repo/build$ sudo make install
[sudo] password for mapas: 
Sorry, try again.
[sudo] password for mapas: 
[100%] Built target osm2pgrouting
Install the project...
-- Install configuration: ""
-- Installing: /usr/share/bin/osm2pgrouting
-- Up-to-date: /usr/share/osm2pgrouting/COPYING
-- Installing: /usr/share/osm2pgrouting/Readme.md
-- Up-to-date: /usr/share/osm2pgrouting/mapconfig.xml
-- Up-to-date: /usr/share/osm2pgrouting/mapconfig_for_cars.xml

wierd things happen, I didnt get it now in develop.

sanak commented 9 years ago

Okay, thanks for information.

cvvergara commented 9 years ago

But I here is part of my history:

mapas@cvergara:~/osm2pgrouting/osm2pgrouting_repo$         
-- Boost version: 1.55.0
-- Boost version: 1.55.0
-- Found the following Boost libraries:
--   program_options
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mapas/osm2pgrouting/osm2pgrouting_repo/build
Linking CXX executable osm2pgrouting
CMakeFiles/osm2pgrouting.dir/src/Export2DB.cpp.o: In function `Export2DB::~Export2DB()':
Export2DB.cpp:(.text+0x31d): undefined reference to `PQfinish'
CMakeFiles/osm2pgrouting.dir/src/Export2DB.cpp.o: In function `Export2DB::connect()':
Export2DB.cpp:(.text+0x386): undefined reference to `PQconnectdb'
Export2DB.cpp:(.text+0x39f): undefined reference to `PQstatus'
CMakeFiles/osm2pgrouting.dir/src/Export2DB.cpp.o: In function `Export2DB::createTables()':
cvvergara commented 9 years ago

@sanak Lets do something, @sarthak-0415 is working on osm2pgrouting, so I will make sure it works for linux first, and then we move to mac.

sanak commented 9 years ago

@cvvergara Hmm... On my Ubuntu 14.04 VirtualBox environment, there was no error on both of master and develop branch. (The following is develop branch result.) develop

By the way, I couldn't understand why vagvaf did the following.

I also have changed the #include "libpq-fe.h" to #include postgresql/libpq-fe.h" in the src/Export2DB.h.

In my understanding, above changing include path is not necessary.

cvvergara commented 9 years ago

Now that I think about it, and wnet carefully on my history I think vagvaf might be @sarthak-0415.

sanak commented 9 years ago

Okay.

dpsspatial commented 8 years ago

I had this error as well, and posted the following response on GIS.SE:

I had this error on a Linux machine that did not have postgresql installed.

The solution was to simply install libpq-devvia the following command:

sudo apt-get install libpq-dev

The /user/include/postgresql/ directory and libpq-fe.h were created just fine, and when I did the make / make install, there were no issues.

Here's the thread I found the solution on: http://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem

cvvergara commented 8 years ago

@sanak Can you please verify and suggest so I can put a comment on the dependencies installation page

sanak commented 8 years ago

@cvvergara Okay, I will check it again at this weekend.

rosetnt commented 8 years ago

my os is centos6.6, (Note that the parameter is '/usr/pgsql-9.3/lib/libpq.so ' instead of '/usr/pgsql-9.3/lib' ) :
cmake -DPOSTGRESQL_INCLUDE_DIR:PATH=/usr/pgsql-9.3/include -DPOSTGRESQL_LIBRARIES:PATH=/usr/pgsql-9.3/lib/libpq.so -H. -Bbuild