Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

compiling ns3-gym on Apple M4

81 views
Skip to first unread message

guzh...@gmail.com

unread,
Nov 13, 2024, 5:33:22 AM11/13/24
to ns-3-users
Hello, NS3 community,

I am trying to compile ns3-gym (located in the contrib folder) on Release 3.36 in cmake on apple m4. The following issues are encoutered:

fatal error: 'google/protobuf/runtime_version.h' file not found

fatal error: 'zmq.hpp' file not found

However, the configuration of NS3 seems working, and no missing zmq and protobuf error can be seen. (these packages are installed using homebrew, zeromq, protobuf, protobuf-c).

Would you please help on this issue? Many thanks in advance. I attach the configure output below.

Regards,
Zhouyou

-- Using default output directory /Users/charles_gu/Documents/GitHub/sparse-wi-fi/ns-3-dev/build
-- Proceeding without cmake-format
-- find_external_library: SQLite3 was found.
-- Harfbuzz is required by GTK3 and was not found.
-- LibXML2 was found.
-- Lib RT is not supported on Mac OS X. Continuing without it.
-- Visualizer requires Python bindings
CMake Warning (dev) at build-support/macros-and-definitions.cmake:884 (find_package):
  Policy CMP0167 is not set: The FindBoost module is removed.  Run "cmake
  --help-policy CMP0167" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

Call Stack (most recent call first):
  CMakeLists.txt:125 (process_options)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find Boost (missing: Boost_INCLUDE_DIR)
-- GSL was not found. Continuing without it.
-- docs: doxygen documentation not enabled due to missing dependencies: doxygen;dot;dia
-- Failed to locate sphinx-build executable (missing: SPHINX_EXECUTABLE)
-- docs: sphinx documentation not enabled due to missing dependencies: Sphinx;epstopdf;pdflatex;latexmk;convert;dvipng
-- Platform doesn't support TAP and EMU features. Continuing without them.
-- Precompiled headers were enabled
-- Processing contrib/opengym
-- Processing src/antenna
-- Processing src/aodv
-- Processing src/applications
-- Processing src/bridge
-- Processing src/brite
-- find_external_library: brite was not found. Missing headers: "Brite.h" and missing libraries: "brite".
-- Skipping src/brite
-- Processing src/buildings
-- Processing src/click
-- find_external_library: click was not found. Missing headers: "simclick.h" and missing libraries: "nsclick;click".
-- Skipping src/click
-- Processing src/config-store
-- Processing src/core
-- Boost Units are an optional feature of length.cc.; Ubuntu ships it within the libboost-dev package.; You may need to clean up the CMake cache after installing it to pass this check.
-- Processing src/csma
-- Processing src/csma-layout
-- Processing src/dsdv
-- Processing src/dsr
-- Processing src/energy
-- Processing src/flow-monitor
-- Processing src/internet
-- Processing src/internet-apps
-- Processing src/lr-wpan
-- Processing src/lte
-- Processing src/mesh
-- Processing src/mobility
-- Processing src/netanim
-- Processing src/network
-- Processing src/nix-vector-routing
-- Processing src/olsr
-- Processing src/openflow
-- find_external_library: openflow was not found. Missing headers: "openflow.h" and missing libraries: "openflow".
-- Skipping src/openflow
-- Processing src/point-to-point
-- Processing src/point-to-point-layout
-- Processing src/propagation
-- Processing src/sixlowpan
-- Processing src/spectrum
-- Processing src/stats
-- Processing src/test
-- Processing src/topology-read
-- Processing src/traffic-control
-- Processing src/uan
-- Processing src/virtual-net-device
-- Processing src/wave
-- Processing src/wifi
-- Processing src/wimax
-- ---- Summary of optional NS-3 features:
Build profile                 : default
Build directory               : /Users/charles_gu/Documents/GitHub/sparse-wi-fi/ns-3-dev/build
BRITE Integration             : OFF (missing dependency)
DES Metrics event collection  : OFF (not requested)
DPDK NetDevice                : OFF (not requested)
Emulation FdNetDevice         : OFF (not requested)
Examples                      : OFF (not requested)
File descriptor NetDevice     : OFF (missing dependency)
GNU Scientific Library (GSL)  : OFF (missing dependency)
GtkConfigStore                : OFF (missing dependency)
MPI Support                   : OFF (not requested)
NS-3 Click Integration        : OFF (missing dependency)
NS-3 OpenFlow Integration     : OFF (missing dependency)
Netmap emulation FdNetDevice  : OFF (not requested)
PyViz visualizer              : OFF (missing dependency)
Python Bindings               : OFF (not requested)
Real Time Simulator           : OFF (missing dependency)
SQLite stats support          : ON
Tap Bridge                    : OFF (not requested)
Tap FdNetDevice               : OFF (not requested)
Tests                         : OFF (not requested)


Modules configured to be built:
antenna                   aodv                      applications              
bridge                    buildings                 config-store              
core                      csma                      csma-layout              
dsdv                      dsr                       energy                    
flow-monitor              internet                  internet-apps            
lr-wpan                   lte                       mesh                      
mobility                  netanim                   network                  
nix-vector-routing        olsr                      opengym                  
point-to-point            point-to-point-layout     propagation              
sixlowpan                 spectrum                  stats                    
topology-read             traffic-control           uan                      
virtual-net-device        wave                      wifi                      
wimax                    

Modules that cannot be built:
brite                     click                     fd-net-device            
mpi                       openflow                  tap-bridge                
test                      visualizer                


-- Configuring done (3.6s)
-- Generating done (1.8s)
-- Build files have been written to: /Users/charles_gu/Documents/GitHub/sparse-wi-fi/ns-3-dev/cmake-cache
Finished executing the following commands:
cd cmake-cache; /opt/homebrew/bin/cmake .. ; cd ..

Gabriel Ferreira

unread,
Nov 13, 2024, 8:51:21 AM11/13/24
to ns-3-users
Each module handles their error messages and warnings. So while the configuration may have succeeded, it doesn't necessarily mean everything was found.
Looking at their code, they do have messages, so I'm going to assume you are using a wrong version, or you have a dirty cmake-cache where it was not found (usually the case when you can't see the compiler versions being tested).


./ns3 clean && ./ns3 configure

guzh...@gmail.com

unread,
Nov 13, 2024, 9:24:47 AM11/13/24
to ns-3-users
Thank you so much for your timely reply!

I added some printing msg to the cmake file in ns3gym as below, and the cmake output is also attached. It seems libs can be found but somehow the head files are not found on macOS/homebrew. Do you have any hint to address this issue? Note that cmake works well on ubuntu with exactly the same codes.

Thanks again

include(FindPkgConfig)
if(NOT PKG_CONFIG_FOUND)
    message(STATUS "pkgconf not found")
    return()
endif()

pkg_check_modules(ZMQ libzmq)
if(NOT ZMQ_FOUND)
    message(STATUS "zeromq not found")
    return()
endif()

# Print ZeroMQ include directories
message(STATUS "ZeroMQ Include Paths:")
foreach(include_dir ${ZMQ_INCLUDE_DIRS})
    message(STATUS "  - ${include_dir}")
endforeach()

# Print ZeroMQ library directories
message(STATUS "ZeroMQ Library Paths:")
foreach(lib_dir ${ZMQ_LIBRARY_DIRS})
    message(STATUS "  - ${lib_dir}")
endforeach()

# Optionally, print the libraries to link against
message(STATUS "ZeroMQ Libraries:")
foreach(lib ${ZMQ_LIBRARIES})
    message(STATUS "  - ${lib}")
endforeach()

find_package(Protobuf 3.0.0)
if(NOT Protobuf_FOUND)
    message(STATUS "protobuf not found")
  return()
endif()


# Print Protobuf include directories
message(STATUS "Protobuf Include Directories:")
foreach(include_dir ${Protobuf_INCLUDE_DIRS})
    message(STATUS "  - ${include_dir}")
endforeach()

# Print Protobuf library directories
message(STATUS "Protobuf Library Directories:")
foreach(lib_dir ${Protobuf_LIBRARY_DIRS})
    message(STATUS "  - ${lib_dir}")
endforeach()

# Print Protobuf libraries to link against
message(STATUS "Protobuf Libraries:")
foreach(lib ${Protobuf_LIBRARIES})
    message(STATUS "  - ${lib}")
endforeach()

set(proto_source_files
    model/messages.proto
)

# generate proto file for C++
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${proto_source_files})
file(RELATIVE_PATH PROTO_HDRS_REL ${CMAKE_CURRENT_SOURCE_DIR} ${PROTO_HDRS})

# generate proto file for Python
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/model PROTOMODEL_PATH)
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/model/ns3gym/ns3gym PROTOBINDING_PATH)
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${proto_source_files} proto_source_file_native)
EXECUTE_PROCESS(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --proto_path=${PROTOMODEL_PATH} --python_out=${PROTOBINDING_PATH}
        ${proto_source_file_native} RESULT_VARIABLE rv)
IF(${rv})
    MESSAGE("Generation of ns3gym Protobuf Python messages failed. Source file: ${proto_native}")
ENDIF()

set(source_files
    helper/opengym-helper.cc
    model/container.cc
    model/opengym_env.cc
    model/opengym_interface.cc
    model/spaces.cc
    ${PROTO_SRCS}
)

set(header_files
    helper/opengym-helper.h
    model/container.h
    model/opengym_env.h
    model/opengym_interface.h
    model/spaces.h
    ${PROTO_HDRS_REL}
)

build_lib(
  LIBNAME opengym
  SOURCE_FILES ${source_files}
  HEADER_FILES ${header_files}
  LIBRARIES_TO_LINK
    ${libcore}
    ${ZMQ_LIBRARIES}
    ${Protobuf_LIBRARIES}
  TEST_SOURCES
    test/opengym-test-suite.cc
)

# add location of generated messages.pb.h to include directories
target_include_directories(
  ${libopengym-obj}
  PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
)


***************************
****CMAKE OUTPUT******
***************************
-- CCache is enabled. Precompiled headers are disabled by default.

-- Using default output directory /Users/charles_gu/Documents/GitHub/sparse-wi-fi/ns-3-dev/build
-- Proceeding without cmake-format
-- find_external_library: SQLite3 was found.
-- Harfbuzz is required by GTK3 and was not found.
-- LibXML2 was found.
-- Lib RT is not supported on Mac OS X. Continuing without it.
-- Visualizer requires Python bindings
CMake Warning (dev) at build-support/macros-and-definitions.cmake:884 (find_package):
  Policy CMP0167 is not set: The FindBoost module is removed.  Run "cmake
  --help-policy CMP0167" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

Call Stack (most recent call first):
  CMakeLists.txt:125 (process_options)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find Boost (missing: Boost_INCLUDE_DIR)
-- GSL was not found. Continuing without it.
-- docs: doxygen documentation not enabled due to missing dependencies: doxygen;dot;dia
-- Failed to locate sphinx-build executable (missing: SPHINX_EXECUTABLE)
-- docs: sphinx documentation not enabled due to missing dependencies: Sphinx;epstopdf;pdflatex;latexmk;convert;dvipng
-- Platform doesn't support TAP and EMU features. Continuing without them.
-- Processing contrib/opengym
-- ZeroMQ Include Paths:
--   - /opt/homebrew/Cellar/zeromq/4.3.5_1/include
--   - /opt/homebrew/Cellar/libsodium/1.0.20/include
-- ZeroMQ Library Paths:
--   - /opt/homebrew/Cellar/zeromq/4.3.5_1/lib
-- ZeroMQ Libraries:
--   - zmq
-- Protobuf Include Directories:
--   - /opt/homebrew/include
-- Protobuf Library Directories:
-- Protobuf Libraries:
--   - /opt/homebrew/lib/libprotobuf.dylib
Build profile                 : debug
-- Configuring done (0.5s)
-- Generating done (0.2s)
-- Build files have been written to: /Users/charles_gu/Documents/GitHub/sparse-wi-fi/ns-3-dev/build

Finished executing the following commands:
cd build; /opt/homebrew/bin/cmake .. ; cd ..

guzh...@gmail.com

unread,
Nov 13, 2024, 10:49:19 AM11/13/24
to ns-3-users
I figured it out. simply export env parameters so cmake can know where to find the lib and include. Note that cppzmq is needed for the zmq.hpp file.

run the following:

brew install cmake python gcc pkg-config protobuf protobuf-c ninja zeromq cppzmq ccache

ls -l /opt/homebrew/lib/libprotobuf.dylib
ls -l /opt/homebrew/lib/libzmq.dylib

export CPATH="/opt/homebrew/include:$CPATH"
export CPLUS_INCLUDE_PATH="/opt/homebrew/include:$CPLUS_INCLUDE_PATH"
export LDFLAGS="-L/opt/homebrew/lib $LDFLAGS"
export CPPFLAGS="-I/opt/homebrew/include $CPPFLAGS"
export PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH"
export CMAKE_PREFIX_PATH="/opt/homebrew:$CMAKE_PREFIX_PATH"
export LIBRARY_PATH="/opt/homebrew/lib:$LIBRARY_PATH"

Then, configure and build



Reply all
Reply to author
Forward
0 new messages