Closed donnekgit closed 5 years ago
It's the answer in #15.
When compiling, use cmake -DCMAKE_CXX_FLAGS="-Wall -std=c++11"
Please ensure your GCC support c++11.
Hope it can solve your problem
Thank you for this, but it doesn't work - I get the same message, even though 4.8.4 is supposed to cover all aspects of C++11.
I installed GCC7, and that also gives the same message:
kevin@akkad:~/other1/downloads/pg_jieba/build$ cmake -DCMAKE_CXX_FLAGS="-Wall -std=c++11" ..
-- The C compiler identification is GNU 7.2.0
-- The CXX compiler identification is GNU 7.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- 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
-- Setting pg_jieba build type -
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find PostgreSQL (missing: PostgreSQL_TYPE_INCLUDE_DIR) (found
version "9.3.21")
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-2.8/Modules/FindPostgreSQL.cmake:151 (find_package_handle_standard_args)
CMakeLists.txt:11 (find_package)
There doesn't seem to be anything of interest in the CMakeOutput.log, and in fact it doesn't mention PostgreSQL.
Is it absolutely certain that this is a compiler problem, and not something to do with an inability to find a required PostgreSQL file?
I'd really like to get pg_jieba working for a GPL Chinese reading assistant I'm working on - it would save a rather clunky call to Python Jieba in a PHP application.
谢谢你!
In fact, this is mostly to do with PostgreSQL. There are some suggestions here.
I installed libpq-dev and postgresql-server-dev-all as suggested, but still got the same result. The file /usr/share/cmake-2.8/Modules/FindPostgreSQL.cmake only recognises PostgreSQL versions up to 9.1, but editing that file to refer to 9.3 as suggested did not resolve the issue.
I then upgraded cmake to cmake3 (3.5.1), which removes cmake 2.8.12. This allowed the build to proceed:
kevin@akkad:~/other1/downloads/pg_jieba/build$ cmake -DCMAKE_CXX_FLAGS="-Wall -std=c++11" ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- 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
-- Setting pg_jieba build type -
-- Found PostgreSQL: /usr/lib/libpq.so (found version "9.3.22")
-- POSTGRESQL_EXECUTABLE is /usr/lib/postgresql/9.3/bin/postgres
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kevin/other1/downloads/pg_jieba/build
However, make then gives a warning:
kevin@akkad:~/other1/downloads/pg_jieba/build$ make
Scanning dependencies of target pg_jieba
[ 50%] Building CXX object CMakeFiles/pg_jieba.dir/pg_jieba.cpp.o
/home/kevin/other1/downloads/pg_jieba/pg_jieba.cpp: In constructor ‘pg_jieba::PgJieba::PgJieba(const string&, const string&, const string&)’:
/home/kevin/other1/downloads/pg_jieba/pg_jieba.cpp:205:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (auto i = 1; i < num_types; ++i) {
^
[100%] Linking CXX shared library pg_jieba.so
[100%] Built target pg_jieba
Running sudo make install
appears to install the extension:
kevin@akkad:~/other1/downloads/pg_jieba/build$ sudo make install
[sudo] password for kevin:
[100%] Built target pg_jieba
Install the project...
-- Install configuration: ""
-- Installing: /usr/lib/postgresql/9.3/lib/pg_jieba.so
-- Installing: /usr/share/postgresql/9.3/extension/pg_jieba.control
-- Installing: /usr/share/postgresql/9.3/extension/pg_jieba--1.1.0.sql
-- Installing: /usr/share/postgresql/9.3/tsearch_data/jieba.dict.utf8
-- Installing: /usr/share/postgresql/9.3/tsearch_data/jieba.hmm_model.utf8
-- Installing: /usr/share/postgresql/9.3/tsearch_data/jieba.user.dict.utf8
-- Installing: /usr/share/postgresql/9.3/tsearch_data/jieba.stop
-- Installing: /usr/share/postgresql/9.3/tsearch_data/jieba.idf.utf8
but PostgreSQL refuses to install it:
qiezi=# create extension pg_jieba;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!>
I repeated the whole process using GCC 7.2.0 instead of GCC 4.8.4, with the same result. It therefore seems that pg_jieba can't be used on Ubuntu 14.04 until that constructor warning can be fixed.
I then tried installing on Ubuntu 16.04, PostgreSQL 9.5.11, GCC 5.4.0, cmake 3.5.1. After installing libpq-dev and postgresql-server-dev-all, the build, make and install proceed with no errors:
lois@lois-Aspire-V3-371:~/Downloads/pg_jieba/build$ cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- 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
-- Setting pg_jieba build type -
-- Found PostgreSQL: /usr/lib/x86_64-linux-gnu/libpq.so (found version "9.5.12")
-- POSTGRESQL_EXECUTABLE is /usr/lib/postgresql/9.5/bin/postgres
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lois/Downloads/pg_jieba/build
lois@lois-Aspire-V3-371:~/Downloads/pg_jieba/build$ make
Scanning dependencies of target pg_jieba
[ 50%] Building CXX object CMakeFiles/pg_jieba.dir/pg_jieba.cpp.o
[100%] Linking CXX shared library pg_jieba.so
[100%] Built target pg_jieba
lois@lois-Aspire-V3-371:~/Downloads/pg_jieba/build$ sudo make install
[sudo] password for lois:
[100%] Built target pg_jieba
Install the project...
-- Install configuration: ""
-- Installing: /usr/lib/postgresql/9.5/lib/pg_jieba.so
-- Installing: /usr/share/postgresql/9.5/extension/pg_jieba.control
-- Installing: /usr/share/postgresql/9.5/extension/pg_jieba--1.1.0.sql
-- Installing: /usr/share/postgresql/9.5/tsearch_data/jieba.dict.utf8
-- Installing: /usr/share/postgresql/9.5/tsearch_data/jieba.hmm_model.utf8
-- Installing: /usr/share/postgresql/9.5/tsearch_data/jieba.user.dict.utf8
-- Installing: /usr/share/postgresql/9.5/tsearch_data/jieba.stop
-- Installing: /usr/share/postgresql/9.5/tsearch_data/jieba.idf.utf8
The extension also installs on PostgreSQL. However, the results it gives are not as expected, and I have opened another issue for that.
Is there any chance of resolving the constructor issue so that pg_jieba can run on Ubuntu 14.04?
Try
apt-get install libpq-dev postgresql-server-dev-all
?? I've already done that (see above). As I said, it appears that pg_jieba can't run on 14.04 because of a coding issue:
pg_jieba.cpp:205:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (auto i = 1; i < num_types; ++i) {
It may be that this just can't be fixed for 14.04 - I don't know.
I am having difficulties compiling pg_jieba.
But then at
cmake ..
I get:This is on Ubuntu 14.04.5, gcc 4.8.4, PostgreSQL 9.3.21, and pg_config is present and working. This seems to be the same error reported at https://github.com/jaiminpan/pg_jieba/issues/15, but it hasn't been closed yet, and I don't (yet) know enough Chinese to figure out why!