Orthanc PostgreSQL 3.0: Compilation Problema


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:



  • 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!


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:


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:


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.


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>


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! =)


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>


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


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:


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.