Orthanc PostgreSQL 3.0: Compilation Problema

Hi!

I’d like to ask for help trying to compile OrthancPostgreSQL-3.0. Please =)

In upgrading from Orthanc 1.3.2 to 1.5.2, I ran into the following issue while recompiling the PostgreSQL plugin, version 3.0 (just released):

/opt/git/rispacs/orthanc/plugins/orthanc-databases/Framework/PostgreSQL/PostgreSQLStatement.cpp: In member function ‘void OrthancDatabases::PostgreSQLStatement::Prepare()’:
/opt/git/rispacs/orthanc/plugins/orthanc-databases/Framework/PostgreSQL/PostgreSQLStatement.cpp:202:7: error: ‘LOG’ was not declared in this scope
LOG(ERROR) << "PostgreSQL error: " << message;
^~~

My orthanc-databases repository clone is pointing to OrthancPostgreSQL-3.0 and Orthanc itself to 1.5.2. I’m recompiling everything since my own Orthanc is modified (and the builds themselves are integrated).

The plugin was cmake’d as follows:

$ cmake -DUSE_SYSTEM_ORTHANC_SDK=ON -DORTHANC_FRAMEWORK_SOURCE=path -DORTHANC_FRAMEWORK_ROOT=$ORTHANC_FRAMEWORK_ROOT -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON $SRC_DIR

Notes:

  • ORTHANC_FRAMEWORK_ROOT: Orthanc source directory

  • SRC_DIR: OrthancPostgreSQL-3.0 source directory

For the record, I’m running an updated Debian Buster. No modifications were made to the plugin.

Thanks for any help!

Luiz

You should start using a fresh build directory (delete and recreate it).

For reference, here is the CMake invocation I use on Ubuntu 16.04:

cmake ~/orthanc-databases/PostgreSQL -DCMAKE_BUILD_TYPE=Release -DALLOW_DOWNLOADS=ON -DUSE_SYSTEM_GOOGLE_TEST=OFF -DUSE_SYSTEM_ORTHANC_SDK=OFF

Hi Sébastien!

You’re right. To compensate for that, my script recrates the build directory each time around. A bit extreme, I agree, but it does its job.

Having runmake on verbose mode, I learned that this is what make actually executes:

/usr/bin/c++ -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_HAS_FILESYSTEM_V3=1 -DHAS_ORTHANC_EXCEPTION=1 -DJSONCPP_DEPRECATED_STACK_LIMIT=5000 -DORTHANC_API_VERSION="1.3" -DORTHANC_DATABASE_VERSION=6 -DORTHANC_DEFAULT_DICOM_ENCODING=Encoding_Latin1 -DORTHANC_ENABLE_BASE64=1 -DORTHANC_ENABLE_CIVETWEB=0 -DORTHANC_ENABLE_CURL=0 -DORTHANC_ENABLE_DCMTK=0 -DORTHANC_ENABLE_DCMTK_NETWORKING=0 -DORTHANC_ENABLE_JPEG=0 -DORTHANC_ENABLE_LOCALE=0 -DORTHANC_ENABLE_LOGGING=1 -DORTHANC_ENABLE_LOGGING_STDIO=0 -DORTHANC_ENABLE_LUA=0 -DORTHANC_ENABLE_MD5=1 -DORTHANC_ENABLE_MONGOOSE=0 -DORTHANC_ENABLE_MYSQL=0 -DORTHANC_ENABLE_PKCS11=0 -DORTHANC_ENABLE_PLUGINS=1 -DORTHANC_ENABLE_PNG=0 -DORTHANC_ENABLE_POSTGRESQL=1 -DORTHANC_ENABLE_PUGIXML=0 -DORTHANC_ENABLE_SQLITE=0 -DORTHANC_ENABLE_SSL=1 -DORTHANC_ENABLE_ZLIB=1 -DORTHANC_HAS_EMBEDDED_RESOURCES=1 -DORTHANC_MAXIMUM_TAG_LENGTH=256 -DORTHANC_PLUGIN_VERSION="3.0" -DORTHANC_SANDBOXED=0 -DORTHANC_STATIC=0 -DORTHANC_VERSION="1.5.2" -DORTHANC_VERSION_MAJOR=1 -DORTHANC_VERSION_MINOR=5 -DORTHANC_VERSION_REVISION=2 -DOrthancPostgreSQLStorage_EXPORTS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1 -I/opt/git/rispacs/orthanc/plugins/Build/orthanc-postgresql/AUTOGENERATED -I/usr/src/gtest -I/usr/include/jsoncpp -I/opt/git/rispacs/orthanc/1.5.2/Resources/CMake/…/… -I/usr/include/postgresql -I/usr/include/postgresql/11/server -Wall -Wno-long-long -Wno-variadic-macros -std=c++11 -Wno-deprecated-declarations -fPIC -DORTHANC_ENABLE_LOGGING_PLUGIN=1 -o CMakeFiles/OrthancPostgreSQLStorage.dir/opt/git/rispacs/orthanc/plugins/orthanc-databases/Framework/PostgreSQL/PostgreSQLDatabase.cpp.o -c /opt/git/rispacs/orthanc/plugins/orthanc-databases/Framework/PostgreSQL/PostgreSQLDatabase.cpp

I’ve run this command with the “-E” switch and attached the file to this e-mail. What’s funny is that even though the correct environment variables are used (highlighted above) and the InternalLogger gets generated, the LOG and VLOG macros are not present, like they were #undefine’d. It seems one the headers included after Core/Logging.h is included is the culprit. There’s boost/lexical_cast.hpp, libpq-fe.h, c.h and catalog.h. I’ll take a look at them now.

In case you’re interested, Core/Logging.h begins at line 89036 and goes on until line 89111. VLOG and LOG are nowhere to be found:

[valmont@alis-sol orthanc-postgresql]$ grep -e ‘\bLOG\b’ -e ‘\bVLOG\b’ CMakeFiles/OrthancPostgreSQLStorage.dir/opt/git/rispacs/orthanc/plugins/orthanc-databases/Framework/PostgreSQL/PostgreSQLDatabase-pre.cpp
LOG(20) << "PostgreSQL error: "
LOG(17) << “Closing connection to PostgreSQL”;
LOG(20) << "PostgreSQL error: " << message;
LOG(20) << “The PostgreSQL database is locked by another instance of Orthanc”;
LOG(TRACE) << "PostgreSQL: " << sql;
LOG(20) << "PostgreSQL error: " << message;
[valmont@alis-sol orthanc-postgresql]$

I’ll see what I can do about it and reply here.

Thanks!

PostgreSQLDatabase-pre.cpp (2.88 MB)

Hi, Sébastien!

I ran your cmake line and unfortunatelly got the same error. But this I got this, which had eluded me previously:

[ 23%] Building CXX object CMakeFiles/OrthancPostgreSQLStorage.dir/opt/git/rispacs/orthanc/plugins/orthanc-databases/Framework/PostgreSQL/PostgreSQLLargeObject.cpp.o
In file included from /usr/include/postgresql/11/server/postgres.h:47,
from /opt/git/rispacs/orthanc/plugins/orthanc-databases/Framework/PostgreSQL/PostgreSQLDatabase.cpp:32:
/usr/include/postgresql/11/server/utils/elog.h:26: warning: “LOG” redefined
#define LOG 15 /* Server operational messages; sent only to

In file included from /opt/git/rispacs/orthanc/plugins/Build/orthanc-postgresql/Orthanc-1.5.2/Resources/CMake/…/…/Plugins/Samples/Common/…/…/…/Core/OrthancException.h:37,
from /opt/git/rispacs/orthanc/plugins/Build/orthanc-postgresql/Orthanc-1.5.2/Resources/CMake/…/…/Plugins/Samples/Common/OrthancPluginException.h:42,
from /opt/git/rispacs/orthanc/plugins/Build/orthanc-postgresql/Orthanc-1.5.2/Resources/CMake/…/…/Plugins/Samples/Common/OrthancPluginCppWrapper.h:36,
from /opt/git/rispacs/orthanc/plugins/orthanc-databases/Framework/PostgreSQL/PostgreSQLParameters.h:28,
from /opt/git/rispacs/orthanc/plugins/orthanc-databases/Framework/PostgreSQL/PostgreSQLDatabase.h:28,
from /opt/git/rispacs/orthanc/plugins/orthanc-databases/Framework/PostgreSQL/PostgreSQLDatabase.cpp:22:
/opt/git/rispacs/orthanc/plugins/Build/orthanc-postgresql/Orthanc-1.5.2/Resources/CMake/…/…/Plugins/Samples/Common/…/…/…/Core/Logging.h:116: note: this is the location of the previous definition

define LOG(level) ::Orthanc::Logging::InternalLogger \

In other words, Core/Logging.h is included as part of the very first include directive. And because of #pragma once, it is not included again at line 36. So I pulled up these lines:

#if PG_VERSION_NUM >= 110000

include <postgres.h>

undef LOG // This one comes from <postgres.h>, and conflicts with <Core/Logging.h>

#endif

So they are the very first lines in that file. Now, save from a few warnings, compilation runs just fine! =)

To wrap things up, I took a look at my copy of Orthanc source to see if I changed anything in that respect and it seems not the case. I suppose. Here’s list of files that have been changed:

[valmont@alis-sol 1.5.2]$ hg status
M Core/FileStorage/FilesystemStorage.h
M Core/FileStorage/IStorageArea.h
M Core/HttpServer/HttpServer.cpp
M Core/Logging.cpp
M OrthancServer/IServerListener.h
M OrthancServer/LuaScripting.cpp
M OrthancServer/LuaScripting.h
M OrthancServer/OrthancRestApi/OrthancRestApi.cpp
M OrthancServer/ServerContext.cpp
M OrthancServer/ServerContext.h
M OrthancServer/ServerIndex.cpp
M OrthancServer/ServerIndex.h
M OrthancServer/ServerJobs/ArchiveJob.cpp
M Plugins/Engine/OrthancPlugins.cpp
M Plugins/Engine/OrthancPlugins.h
M Plugins/Include/orthanc/OrthancCPlugin.h
[valmont@alis-sol 1.5.2]$

Still, I’m not 100% satisfied. Alas, I’ve got pressing matters to deal with. In case you’re interested, I can send you the diff to those mods.

Thanks! =)

Hi!

I writting yet again just to make the last e-mail a little more complete in case anyone faces the same issues and because I had to perform a slightly different change on a couple more files.

The lines that were pulled up were these:

#include <pg_config.h>

#if PG_VERSION_NUM >= 110000

include <postgres.h>

undef LOG // This one comes from <postgres.h>, and conflicts with <Core/Logging.h>

#endif

And it had to be done in the following files:

[valmont@alis-sol orthanc-databases]$ hg status
M Framework/PostgreSQL/PostgreSQLDatabase.cpp
M Framework/PostgreSQL/PostgreSQLResult.cpp
M Framework/PostgreSQL/PostgreSQLStatement.cpp
[valmont@alis-sol orthanc-databases]$

I got sidetracked because, having upgraded from Stretch to Buster, there was an old postgresql-server-dev-9.6 still lying around. So just hitting “make” again in the build directory yield a “false positive” so to speak. I have completed a full rebuild, hence this e-mail.

One more thing, courtesy of something I can only describe as a cmake cache, the actual command line ended up being like so:

cmake -DUSE_SYSTEM_ORTHANC_SDK=ON -DORTHANC_FRAMEWORK_SOURCE=path -DORTHANC_FRAMEWORK_ROOT=/opt/git/rispacs/orthanc/1.5.2 -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON -DUSE_SYSTEM_LIBPQ=ON -DPostgreSQL_ADDITIONAL_SEARCH_PATHS=/usr/include/postgresql/11 /opt/git/rispacs/orthanc/plugins/orthanc-databases/PostgreSQL

I believe there’s a cache between cmake runs, even if I remove the build directory. Point being: Buster’s libpq-fe.h (from postgresqç-server-dev-11) lies in a directory not searched for by FindPostgreSQL.cmake, hence the need for PostgreSQL_ADDITIONAL_SEARCH_PATHS.

Sorry about all those e-mails

HTH

Dear Luiz,

I confirm I met the same issue as you during the packaging of the PostgreSQL plugin for Debian.

It is now fixed in the mainline by the following changeset:
https://bitbucket.org/sjodogne/orthanc-databases/commits/9263b3de37ed71b60e6a0420f6c494f9a11dc8a8

HTH,
Sébastien-

Is a 64bit version of the plugin available for Windows yet?

Not yet: The Osimis Windows 64bit installers will be updated once we finish the rework of the MySQL plugins as well.