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

FOGL-9330 Update requirements.sh to allow build on Ubuntu 2x #52

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

praveen-garg
Copy link
Member

@praveen-garg praveen-garg commented Dec 12, 2024

Allow any Ubuntu 2x

@praveen-garg praveen-garg changed the title Update requirements.sh FOGL-9330 Update requirements.sh to allow build on Ubuntu 2x Dec 12, 2024
@praveen-garg
Copy link
Member Author

Error specific to Ubuntu 22.04 now

19:22:34  [ 40%] Building CXX object CMakeFiles/opendnp3.dir/cpp/libs/src/opendnp3/master/CommandSet.cpp.o
19:22:34  In file included from /home/ubuntu/opendnp3/cpp/libs/src/opendnp3/master/CommandSet.cpp:23:
19:22:34  /home/ubuntu/opendnp3/./cpp/libs/src/opendnp3/master/TypedCommandHeader.h: In member function 'virtual opendnp3::ICommandCollection<T>& opendnp3::TypedCommandHeader<T>::Add(const T&, uint16_t)':
19:22:34  /home/ubuntu/opendnp3/./cpp/libs/src/opendnp3/master/TypedCommandHeader.h:83:22: error: 'numeric_limits' is not a member of 'std'
19:22:34     83 |     if (index > std::numeric_limits<uint8_t>::max())
19:22:34        |                      ^~~~~~~~~~~~~~
19:22:34  /home/ubuntu/opendnp3/./cpp/libs/src/opendnp3/master/TypedCommandHeader.h:83:44: error: expected primary-expression before '>' token
19:22:34     83 |     if (index > std::numeric_limits<uint8_t>::max())
19:22:34        |                                            ^
19:22:34  /home/ubuntu/opendnp3/./cpp/libs/src/opendnp3/master/TypedCommandHeader.h:83:47: error: '::max' has not been declared; did you mean 'std::max'?
19:22:34     83 |     if (index > std::numeric_limits<uint8_t>::max())
19:22:34        |                                               ^~~
19:22:34        |                                               std::max
19:22:34  In file included from /usr/include/c++/11/algorithm:62,
19:22:34                   from /home/ubuntu/opendnp3/./cpp/libs/src/opendnp3/master/TypedCommandHeader.h:31,
19:22:34                   from /home/ubuntu/opendnp3/cpp/libs/src/opendnp3/master/CommandSet.cpp:23:
19:22:34  /usr/include/c++/11/bits/stl_algo.h:3467:5: note: 'std::max' declared here
19:22:34   3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
19:22:34        |     ^~~
19:22:35  make[2]: *** [CMakeFiles/opendnp3.dir/build.make:1084: CMakeFiles/opendnp3.dir/cpp/libs/src/opendnp3/master/CommandSet.cpp.o] Error 1
19:22:35  make[1]: *** [CMakeFiles/Makefile2:129: CMakeFiles/opendnp3.dir/all] Error 2
19:22:35  make: *** [Makefile:156: all] Error 2

cc @ashwini-k-pandey

@praveen-garg
Copy link
Member Author

@Mohit04tomar For the test purpose I kept release tag for Ubuntu 2x

The compilation seems okay but some other errors:

20:43:25  [100%] Linking CXX shared library libopendnp3.so
20:43:26  [100%] Built target opendnp3
20:43:26  Set the environment variable OPENDNP3_LIB_DIR to /home/ubuntu/opendnp3
20:43:26  export OPENDNP3_LIB_DIR=/home/ubuntu/opendnp3
20:43:26  Set the environment FLEDGE_ROOT
20:43:26  Set the environment FLEDGE_SRC
20:43:26  export FLEDGE_SRC=$FLEDGE_ROOT
20:43:26  CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
20:43:26    Compatibility with CMake < 2.8.12 will be removed from a future version of
20:43:26    CMake.
20:43:26  
20:43:26    Update the VERSION argument <min> value or use a ...<max> suffix to tell
20:43:26    CMake that the project does not need compatibility with older versions.
20:43:26  
20:43:26  
20:43:26  -- The C compiler identification is GNU 11.4.0
20:43:26  -- The CXX compiler identification is GNU 11.4.0
20:43:26  -- Detecting C compiler ABI info
20:43:26  -- Detecting C compiler ABI info - done
20:43:26  -- Check for working C compiler: /usr/bin/cc - skipped
20:43:26  -- Detecting C compile features
20:43:26  -- Detecting C compile features - done
20:43:26  -- Detecting CXX compiler ABI info
20:43:27  -- Detecting CXX compiler ABI info - done
20:43:27  -- Check for working CXX compiler: /usr/bin/c++ - skipped
20:43:27  -- Detecting CXX compile features
20:43:27  -- Detecting CXX compile features - done
20:43:27  -- No options set.
20:43:27     +Using found FLEDGE_ROOT /home/ubuntu/fledge
20:43:27  -- Using FLEDGE_ROOT for includes
20:43:27     +/home/ubuntu/fledge/C/common/include
20:43:27     +/home/ubuntu/fledge/C/services/common/include
20:43:27     +/home/ubuntu/fledge/C/thirdparty/rapidjson/include
20:43:27  -- Using FLEDGE_ROOT for libs 
20:43:27     +/home/ubuntu/fledge/cmake_build/C/lib
20:43:27  -- Configuring incomplete, errors occurred!
20:43:27  See also "/tmp/fledge-south-dnp3/build/CMakeFiles/CMakeOutput.log".
20:43:27  CMake Error at CMakeLists.txt:72 (message):
20:43:27    OPENDNP3_LIB_DIR /home/ubuntu/opendnp3/cpp/libs/include
20:43:27  
20:43:27    does not appear to be pointing at a valid OPENDNP3_LIB_DIR source tree

@praveen-garg
Copy link
Member Author

Looks like:

We need to make it any, lib or libs
release tag, has cpp/lib not cpp/libs

if (NOT EXISTS "${OPENDNP3_LIB_DIR}/cpp/libs/include")

cpp/lib/include

@praveen-garg praveen-garg marked this pull request as draft December 12, 2024 15:28
@praveen-garg
Copy link
Member Author

praveen-garg commented Dec 12, 2024

The new run fails to link

find_library(LIBOPENDP3 libopendnp3.a "${OPENDNP3_LIB_DIR}/build")

While we are getting .so

23:17:53  [100%] Linking CXX shared library libopendnp3.so
23:17:55  [100%] Built target opendnp3
23:17:55  Set the environment variable OPENDNP3_LIB_DIR to /home/ubuntu/opendnp3
23:17:55  export OPENDNP3_LIB_DIR=/home/ubuntu/opendnp3

Build logs says

23:15:01  CMake Warning:
23:15:01    Manually-specified variables were not used by the project:
23:15:01  
23:15:01      DNP3_DEMO
23:15:01      STATICLIBS

# stick with release 2.3.0 of opendnp3
git checkout tags/2.3.0
# Set TLS flag
useTLS=1
elif [[ ${OS_NAME} == *"Ubuntu"* && ( ${OS_VERSION} == "22."* || ${OS_VERSION} == "24."* ) ]]; then
# Set TLS flag

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it not a good idea to stick a fixed tag ..?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally Yes.

Looks like there were compatibility issues hence this approach.

Though I can see this can be improved and tested with newer stable release.

Bullseye Raspberry Pi OS also can have TLS.

message(FATAL_ERROR "OPENDNP3_LIB_DIR ${OPENDNP3_LIB_DIR}/cpp/libs/include \n"
"does not appear to be pointing at a valid OPENDNP3_LIB_DIR source tree")
return()
# Set the base directory where the 'lib' or 'libs' directories should be located

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the background for this change ..?

Copy link
Member Author

@praveen-garg praveen-garg Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 2.3.x tag does not work well with Ubuntu 22.04 with gcc11. There is a fix in 3.x.x release tag which has include limits.
There is a change in CMake that by default turned off static lib creation but shared lib.
And also 3.x.x has changed directory name - libs vs lib.
We can enable static lib with a new var in CMake.

@praveen-garg
Copy link
Member Author

With the last commit

~/opendnp3/build/cpp/lib$ ls
CMakeFiles  Makefile  cmake_install.cmake  libopendnp3.a

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 this pull request may close these issues.

2 participants