Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation error on Ubuntu 21.04 (g++ 11.1) #493

Closed
tomhenderson opened this issue Jul 8, 2021 · 9 comments · Fixed by #502
Closed

compilation error on Ubuntu 21.04 (g++ 11.1) #493

tomhenderson opened this issue Jul 8, 2021 · 9 comments · Fixed by #502

Comments

@tomhenderson
Copy link

While testing ns-3 with the most recent click code, I encountered a compilation error on Ubuntu 21.04 with g++ version
gcc version 11.1.0 (Ubuntu 11.1.0-1ubuntu1~21.04).

Steps to reproduce:

$ git clone https://github.com/kohler/click && cd click
$ configure && make

Error reported:

...
  CXX ../elements/icmp/icmperror.cc
In file included from ../include/clicknet/ip.h:5,
                 from ../include/clicknet/icmp.h:4,
                 from ../elements/icmp/icmperror.cc:20:
../include/click/cxxprotect.h:12:25: error: ‘linux_true’ was not declared in this scope
   12 | # define true           linux_true
      |                         ^~~~~~~~~~
...

Workaround:
The below patch works for me on this system; have not checked other systems.

diff --git a/include/click/cxxprotect.h b/include/click/cxxprotect.h
index 65662aff7..f199df45a 100644
--- a/include/click/cxxprotect.h
+++ b/include/click/cxxprotect.h
@@ -9,7 +9,6 @@
 # define public                linux_public
 # define namespace     linux_namespace
 # define false         linux_false
-# define true          linux_true
 #endif
 
 #ifndef CLICK_CXX_PROTECT
@tbarbette
Copy link
Collaborator

You need to give a few parameters to configure to build for ns3. Here you're compiling for a Kernel module ;)

@tomhenderson
Copy link
Author

You need to give a few parameters to configure to build for ns3. Here you're compiling for a Kernel module ;)

Sorry, I simplified for the issue report. Here are the arguments being passed to configure:

./configure --disable-linuxmodule --enable-nsclick --enable-wifi

It results in the same error. This configuration works on earlier Ubuntu, but not on Ubuntu 21.04.

kyechou added a commit to kyechou/aur-clickrouter-git that referenced this issue Nov 9, 2021
@sriharshAmur
Copy link

Has anybody found a solution for this? I'm facing the same issue

@kyechou
Copy link
Contributor

kyechou commented May 20, 2022

The above workaround works for me too (Arch Linux, kernel 5.17.8, GCC 12.1.0).

Workaround: The below patch works for me on this system; have not checked other systems.

diff --git a/include/click/cxxprotect.h b/include/click/cxxprotect.h
index 65662aff7..f199df45a 100644
--- a/include/click/cxxprotect.h
+++ b/include/click/cxxprotect.h
@@ -9,7 +9,6 @@
 # define public                linux_public
 # define namespace     linux_namespace
 # define false         linux_false
-# define true          linux_true
 #endif
 
 #ifndef CLICK_CXX_PROTECT

@botbotty
Copy link

Same error on Ubuntu 22.04

The problem seems to be with # include <netinet/in.h> inside ./include/clicknet/ip.h

If I add #undef true right before # include <netinet/in.h>, the compilation error disappears. It doesn't work if I add it after the include statement.

@tbarbette
Copy link
Collaborator

Is there a way to do that so it works also on old system without the define true? I think the define in netinet/in.h should be found at configure time and then expose the true or not according to the result of that.

What are your compile flags so I can try?

@yxxu
Copy link

yxxu commented Jun 18, 2022

@tomhenderson
dear tomhenderson, how do you correct? I meet same error on ubuntu 22.04

tbarbette pushed a commit to tbarbette/click that referenced this issue Jun 21, 2022
tbarbette pushed a commit that referenced this issue Jun 28, 2022
@kyechou
Copy link
Contributor

kyechou commented Jun 28, 2022

Hi @tbarbette, the build is still broken for me with #502. Here's the complete build output: https://pastebin.com/TsUtmApV.

$ ./configure --prefix=/usr --sbindir=/usr/bin --enable-all-elements
$ make -j1
...
  CREATE elements.mk
  CXX ../lib/userutils.cc
  CXX ../elements/ip6/addresstranslator.cc
  CXX ../elements/ip6/icmp6error.cc
  CXX ../elements/ip6/ip6routetable.cc
  CXX ../elements/ip6/lookupip6route.cc
  CXX ../elements/ip6/markip6header.cc
  CXX ../elements/ip6/protocoltranslator64.cc
  CXX ../elements/ip6/setip6address.cc
  CXX ../elements/ip6/protocoltranslator46.cc
  CXX ../elements/ip6/setip6dscp.cc
  CXX ../elements/ip/checkipheader2.cc
In file included from ../include/clicknet/ip6.h:6,
                 from ../include/clicknet/icmp6.h:4,
                 from ../elements/ip6/icmp6error.cc:19:
../include/click/cxxprotect.h:12:25: error: ‘linux_true’ was not declared in this scope
   12 | # define true           linux_true
      |                         ^~~~~~~~~~

It looks like we need to do the same thing for include/clicknet/ip6.h, which I assume is not enabled for Ubuntu?
But wouldn't it make more sense to fix the issue by including or defining/adding macro checks in include/click/cxxprotect.h directly, instead of modifying all the other files that include that file?

@tbarbette
Copy link
Collaborator

Ah yes I did not try with ip6.
Yes it would be great but I could not find what to check in the incriminated file, nor exactly where is the clashing use...

tbarbette added a commit that referenced this issue Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants