paceholder / nodeeditor

Qt Node Editor. Dataflow programming framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Q_NAMESPACE error when trying to build

opened this issue · comments

When I try to build this on Windows with msvc I get the following error:

nodeeditor/include/QtNodes/internal/Definitions.hpp(14): Error: Namespace declaration lacks Q_NAMESPACE macro.

Any clue how to fix that error?

Would be not bad to tell what Qt version you are using

Qt's docs say that Q_NAMESPACE_EXPORT which we have in the file performs the same function as your missing Q_NAMESPACE. For the sake of experimenting try to puth Q_NAMESPACE right after the namespace definition.

I am running on Windows and using Qt 5.9.7 and MSVC 19.34.31935.0 (Visual Studio 17 2022).

I also tried with MinGW CXX compiler as GNU 6.3.0, and got the same error.

From a quick search for the docs you mention, it looks like Q_NAMESPACE_EXPORT wasn't introduced until Qt 5.14, so that could be my issue. I tried putting Q_NAMESPACE right after the namespace definition, and it threw a bunch more errors, so I'll try installing a newer version of Qt to see if it resolves it!

Q_NAMESPACE_EXPORT wasn't introduced until Qt 5.14

Oh, I did not notice that. Sorry, I was initially developing just on 6.x and just lately fixed all inconsistencies to compile on the latest 5.15.xx

I think 5.15 is the only and the last supported version from the 5.x release, it makes sense to update your installation.

Hi, I got same error, and my env is: Ubuntu 20.04, Qt Ver: 5.12.
and 5.12 is default Qt version in Ubuntu 20.04, would you solved this problem for Qt5.12?

The continuous integration service on https://www.appveyor.com/ builds this project with MSVS and Qt 5.15

@soccerdude008 did you manage to fix the issue?

@paceholder Sorry I haven't had a chance to try downloading Qt 5.15 yet, but totally expect it will work in that case, so feel free to close out the issue. I guess the only thing you might change in the repo is in the README.rst it lists Qt > 5.2 as a dependency, so maybe update that to Qt >= 5.15?

I updated Readme

It is definitely worth allowing this project to compile on less than Qt 5.15 because Ubuntu 20.04 LTS uses Qt 5.12.8. Forcing users to upgrade to the latest version of Ubuntu or recompiling Qt or using a PPA repository with backported updates is painful to say the least.

What's furthermore is that nodeeditor won't build at all on Ubuntu 18.04 LTS because of line 3 in CMakeLists.txt:

cmake_policy(SET CMP0072 NEW)

This occurs because the CMake version that 18.04 supplies is older than the policy. Alas, CMake can be built from source and it will work again so long as Q_NAMESPACE is reimplemented. Overall, being able to compile this on older versions of Ubuntu means Qt deployments will work with older glibc versions, etc.

I use this project as a submodule and a CMake pipeline, and it is trivial to fix the problem (at least using the project as a shared libary) by replacing line 16 as follows:

diff --git a/include/QtNodes/internal/Definitions.hpp b/include/QtNodes/internal/Definitions.hpp
index ffb9670..5a0866c 100644
--- a/include/QtNodes/internal/Definitions.hpp
+++ b/include/QtNodes/internal/Definitions.hpp
@@ -13,7 +13,7 @@

 namespace QtNodes
 {
-Q_NAMESPACE_EXPORT(NODE_EDITOR_PUBLIC)
+Q_NAMESPACE

 /**
  * Constants used for fetching QVariant data from GraphModel.

Can we perhaps wrap this in an #ifdef ?

Looks like I spoke too soon - I see a commit has already fixed this. My reasoning still stands which makes me happy to see you are taking care of the backward compatibility so thank you!