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

Trying to build the new SIPp 3.6.1 on CentOS 7 #485

Closed
nchaigne opened this issue Sep 17, 2020 · 8 comments
Closed

Trying to build the new SIPp 3.6.1 on CentOS 7 #485

nchaigne opened this issue Sep 17, 2020 · 8 comments

Comments

@nchaigne
Copy link

Hello,

I'm trying to build the new SIPp 3.6.1 on CentOS 7.
I'm not sure of the prerequisites, I did not find much information except that I need CMake.

So I tried with:

./build.sh --common

Which gives me errors:

Building C object CMakeFiles/sipp.dir/src/rijndael.c.o
/home/build/sipp-3.6.1/src/screen.cpp: In member function ‘void ScreenPrinter::print_closing_stats()’:
/home/build/sipp-3.6.1/src/screen.cpp:86:15: error: ‘line’ does not name a type
     for (auto line : lines) {
               ^
/home/build/sipp-3.6.1/src/screen.cpp:90:5: error: expected ‘;’ before ‘if’
     if (currentScreenToDisplay != DISPLAY_STAT_SCREEN) {
     ^
/home/build/sipp-3.6.1/src/screen.cpp:90:5: error: expected primary-expression before ‘if’
/home/build/sipp-3.6.1/src/screen.cpp:90:5: error: expected ‘;’ before ‘if’

(etc.)

cmake --version
cmake version 2.8.12.2

Is this too old maybe ?
If so could you detail the prerequisites for building SIPp 3.6.1 ?

Thanks for your help.

@wdoekes
Copy link
Member

wdoekes commented Sep 17, 2020

I think your c++ compiler is too old.

Try this:

diff --git a/src/screen.cpp b/src/screen.cpp
index bbf9cd2..925bd1f 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -83,15 +83,15 @@ void print_statistics(int last)
 void ScreenPrinter::print_closing_stats() {
     M_last = true;
     get_lines();
-    for (auto line : lines) {
-        printf("%s\n", line.c_str());
+    for (auto it = lines.begin(); it != lines.end(); ++it) {
+        printf("%s\n", (*it).c_str());
     }
 
     if (currentScreenToDisplay != DISPLAY_STAT_SCREEN) {
         currentScreenToDisplay = DISPLAY_STAT_SCREEN;
         get_lines();
-        for (auto line : lines) {
-            printf("%s\n", line.c_str());
+        for (auto it = lines.begin(); it != lines.end(); ++it) {
+            printf("%s\n", (*it).c_str());
         }
     }
 
@@ -100,8 +100,8 @@ void ScreenPrinter::print_closing_stats() {
 void ScreenPrinter::print_to_file(FILE* f)
 {
     get_lines();
-    for (auto line : lines) {
-        fprintf(f, "%s\n", line.c_str());
+    for (auto it = lines.begin(); it != lines.end(); ++it) {
+        fprintf(f, "%s\n", (*it).c_str());
     }
 }
 
@@ -114,8 +114,8 @@ void ScreenPrinter::redraw()
     if (!M_headless) {
         get_lines();
         erase();
-        for (auto line : lines) {
-            printw("%s\n", line.c_str());
+        for (auto it = lines.begin(); it != lines.end(); ++it) {
+            printw("%s\n", (*it).c_str());
         }
 
         if (command_mode) {

@nchaigne
Copy link
Author

I have gcc 9.3.1 (from devtoolset-9), this is not sufficient ?

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.3.1-20200408/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)

@wdoekes
Copy link
Member

wdoekes commented Sep 17, 2020

Seems odd. I have g++-7.5 and it works just fine over here.

Maybe you have some other compiler flag going on, but I cannot tell from your output.

make VERBOSE=1
?

Also, I realise I changed the iterator-stuff, but not the auto-stuff, which the compiler actually complained about.

So, the entire change would then be:

diff --git a/include/screen.hpp b/include/screen.hpp
index 13a9708..e2ad1f2 100644
--- a/include/screen.hpp
+++ b/include/screen.hpp
@@ -43,6 +43,8 @@ void print_statistics(int last);
 extern int key_backspace;
 extern int key_dc;
 
+typedef std::vector<std::string> string_array;
+
 class ScreenPrinter {
 public:
     ScreenPrinter():
@@ -63,7 +65,7 @@ private:
     void draw_repartition_detailed(CStat::T_dynamicalRepartition * tabRepartition,
                                  int sizeOfTab);
 
-    std::vector<std::string> lines;
+    string_array lines;
 
     bool M_last = false;
 };
diff --git a/src/screen.cpp b/src/screen.cpp
index bbf9cd2..5521a44 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -83,15 +83,15 @@ void print_statistics(int last)
 void ScreenPrinter::print_closing_stats() {
     M_last = true;
     get_lines();
-    for (auto line : lines) {
-        printf("%s\n", line.c_str());
+    for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+        printf("%s\n", (*it).c_str());
     }
 
     if (currentScreenToDisplay != DISPLAY_STAT_SCREEN) {
         currentScreenToDisplay = DISPLAY_STAT_SCREEN;
         get_lines();
-        for (auto line : lines) {
-            printf("%s\n", line.c_str());
+        for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+            printf("%s\n", (*it).c_str());
         }
     }
 
@@ -100,8 +100,8 @@ void ScreenPrinter::print_closing_stats() {
 void ScreenPrinter::print_to_file(FILE* f)
 {
     get_lines();
-    for (auto line : lines) {
-        fprintf(f, "%s\n", line.c_str());
+    for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+        fprintf(f, "%s\n", (*it).c_str());
     }
 }
 
@@ -114,8 +114,8 @@ void ScreenPrinter::redraw()
     if (!M_headless) {
         get_lines();
         erase();
-        for (auto line : lines) {
-            printw("%s\n", line.c_str());
+        for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+            printw("%s\n", (*it).c_str());
         }
 
         if (command_mode) {

@nchaigne
Copy link
Author

Apparently CMake is explicitly using "/bin/c++" which is the distros default... (gcc version 4.8.5, that's old)
In generated file "CMakeFiles/sipp.dir/build.make", for example we can see:

CMakeFiles/sipp.dir/src/call_generation_task.cpp.o: src/call_generation_task.cpp
        $(CMAKE_COMMAND) -E cmake_progress_report /home/build/sipp-3.6.1/CMakeFiles $(CMAKE_PROGRESS_1)
        @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building CXX object CMakeFiles/sipp.dir/src/call_generation_task.cpp.o"
        /bin/c++   $(CXX_DEFINES) $(CXX_FLAGS) -o CMakeFiles/sipp.dir/src/call_generation_task.cpp.o -c /home/build/sipp-3.6.1/src/call_generation_task.cpp

I've solved my issue by editing the "build.sh" as follows:

CMAKE_OPT="-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++"
cmake . $CMAKE_OPT -DUSE_GSL=1 -DUSE_PCAP=1 -DUSE_SSL= -DUSE_SCTP=

@wdoekes
Copy link
Member

wdoekes commented Sep 17, 2020

Could you also try the change above?

I'll gladly let that land in 3.6.x because I don't want to make the 3.6 branch incompatible because of just those 4 auto uses.

@nchaigne
Copy link
Author

Actually CMake does correctly use the newer compiler.
I first ran "./build.sh" without having installed that newer compiler.
When running "./build.sh" again, the CMake files are not re-generated, and thus the build failed.
I tried again from a clean state, now the build works just fine. :)

@nchaigne
Copy link
Author

I tried to build with the older compiler with your source changes above.
There are other errors now:

[ 18%] Building C object CMakeFiles/sipp.dir/src/rijndael.c.o
/home/build/sipp-3.6.1/src/screen.cpp: In member function ‘void ScreenPrinter::get_lines()’:
/home/build/sipp-3.6.1/src/screen.cpp:171:25: error: ‘to_string’ is not a member of ‘std’
                         std::to_string(currentRepartitionToDisplay) +
                         ^
/home/build/sipp-3.6.1/src/screen.cpp: In member function ‘void ScreenPrinter::draw_scenario_screen()’:
/home/build/sipp-3.6.1/src/screen.cpp:531:27: error: ‘to_string’ is not a member of ‘std’
                         ? std::to_string(curmsg->nb_lost).c_str()
                           ^
/home/build/sipp-3.6.1/src/screen.cpp:539:27: error: ‘to_string’ is not a member of ‘std’
                         ? std::to_string(curmsg->nb_lost).c_str()
                           ^
/home/build/sipp-3.6.1/src/screen.cpp:566:39: error: ‘to_string’ is not a member of ‘std’
                                     ? std::to_string(curmsg->nb_lost).c_str()
                                       ^
/home/build/sipp-3.6.1/src/screen.cpp:624:39: error: ‘to_string’ is not a member of ‘std’
                                     ? std::to_string(curmsg->nb_lost).c_str()
                                       ^
/home/build/sipp-3.6.1/src/screen.cpp:638:46: error: ‘to_string’ is not a member of ‘std’
                      curmsg->retrans_delay ? std::to_string(curmsg->nb_timeout).c_str() : "",
                                              ^
[ 21%] gmake[2]: *** [CMakeFiles/sipp.dir/src/screen.cpp.o] Error 1

@wdoekes
Copy link
Member

wdoekes commented Sep 18, 2020

Ok. So 626de65 made things work with pre-C++11 compilers.

And for the dev (master or 3.7.x) branch I added appropriate checks for a newer compiler.

Thanks for the report!

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

No branches or pull requests

2 participants