omnetpp / omnetpp-resultfiles

Abandoned project.
27 stars 18 forks source link

Compilation fails with current compiler #12

Open ApolloLV opened 7 years ago

ApolloLV commented 7 years ago
common/bigdecimal.cc: In member function 'int64_t BigDecimal::getDigits(int, int) const':
common/bigdecimal.cc:149:33: error: call of overloaded 'abs(const int64_t&)' is ambiguous
     int64 val = abs(this->intVal);
kk-1 commented 6 years ago

I have openSUSE Tumbleweed 64 bit R 3.5.1 gcc 8.1.1 The command (after donwloading the tar.gz file) install.packages("~/Downloads/omnetpp_0.6-1.tar.gz", repos = NULL, type = "source") gives error similar to the ApolloLV's above: ... common/bigdecimal.cc:41:32: error: ‘int64_t abs(int64_t)’ conflicts with a previous declaration static inline int64 abs(int64 x) { return x >= 0 ? x : -x; } ...

Please help us to fix it

All the best...

bbaumgartl commented 6 years ago

For me using c++98 worked (tested with R 3.3.3 and g++ 6.3.0 on debian 9.4).

sed -i '/^CXX *=/ s/g++/g++ -std=gnu++98/' /etc/R/Makeconf

Maybe you have to change the path to your Makeconf on other distros.

sraddon commented 5 years ago

I'm having the same problem as @kk-1 . I'm sorry @bbaumgartl but I don't quite get your solution, I'm quite new to all this. Could you give me a step by step on how to get from

sudo R CMD INSTALL /home/username/Downloads/omnetpp_0.6-1.tar.gz

(which is failing) to your proposed solution?

Failing that @kk-1 could you detail how you fixed the issue?

bbaumgartl commented 5 years ago

No problem. Before you try to install the omnetpp R module with the command you posted you have to configure the c++ compiler to use the older c++98 standard. This can be done by modifying the configuration file /etc/R/Makeconf (for debian). In that file there is the variable CXX. With this variable you can control which c++ compiler R is using while installing/building your custom modules. On debian g++ is used as compiler. If you add the compiler option -std=gnu++98 behind g++ the compiler will use the c++98 standard. After you saved the configuration file you can try to install the module again. The command i posted sed ... does all of this just in one line. ;)

sraddon commented 5 years ago

@bbaumgartl Thanks a lot for the description, I managed to get the compiler running with gnu++98 as you suggested. I'm new to linux, its cool you can do all that in one line! I think it would take at least 10 clicks in windows!

Unfortunately I am still running into the same error. It is however giving me more information on the error now, which is good. As @kk-1 mentioned above there seems to be an issue in compiling BigDecimal.cc

Here is the appropriate section of the stack:

common/bigdecimal.cc: In function ‘int64_t abs(int64_t)’:
**common/bigdecimal.cc:41:32: error: ‘int64_t abs(int64_t)’ conflicts with a previous declaration
 static inline int64 abs(int64 x) { return x >= 0 ? x : -x; }**
                                ^
In file included from /usr/include/c++/7/cmath:47:0,
                 from /usr/include/c++/7/math.h:36,
                 from common/bigdecimal.h:33,
                 from common/bigdecimal.cc:33:
/usr/include/c++/7/bits/std_abs.h:56:3: note: previous declaration ‘long int std::abs(long int)’
   abs(long __i) { return __builtin_labs(__i); }
   ^~~
common/bigdecimal.cc: In member function ‘int64_t BigDecimal::getDigits(int, int) const’:
**common/bigdecimal.cc:149:33: error: call of overloaded ‘abs(const int64_t&)’ is ambiguous
     int64 val = abs(this->intVal);**

Do you know how to resolve the issue? I have also tried installing on a different computer entirely (linux based) and am running into the same issue there as well so I'm fairly sure its not something to do with my machine specifically.

bbaumgartl commented 5 years ago

I am not sure if i can help you any further, since i don't have access to my original development environment anymore. But if you can give me more information on your system (distribution and version, compiler and version) i can try to reproduce the problem. You can get this information with the following commands:

uname -a
g++ --version
cat /etc/*-release
# If the one above does not work
hostnamectl | grep 'System\|Kernel\|Architecture'

PS: If you are pasting commandline output or source code try to use code formatting so it is easier to read. You can find examples here https://guides.github.com/features/mastering-markdown/. ;)

sraddon commented 5 years ago

Thanks for your help here is the info:

sraddon@Sam-Portable:~$ uname -a
Linux Sam-Portable 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
sraddon@Sam-Portable:~$ g++ --version
g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

sraddon@Sam-Portable:~$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

I initially installed this on a clean copy of Ubuntu, so I'm hoping it should be reasonably easy to reproduce... but you never know with these things!

sraddon commented 5 years ago

This is no longer necessary, noticed that Michele Segata did a commit last year (20th September) that fixed this issue, it has not yet been incorporated into the official release which is why I couldn't compile. In the end it was just a matter of copying their change to BigDecimal.cc over and then it worked. This issue can probably be marked as closed now?

Thanks for your help nonetheless, I've learnt a few things from the experience which is good!

ApolloLV commented 5 years ago

Before closing the issue, we should make sure that the segata changes are actually included in the next release