From 2acba8f7a553dcfcad3f2dddc28bce679aaf031b Mon Sep 17 00:00:00 2001 From: long long <84077194+kirazero17@users.noreply.github.com> Date: Mon, 15 Jun 2026 00:24:25 -0400 Subject: [PATCH 1/2] fix macro stuffs --- model/p4-core-pipeline.cc | 6 ++++++ model/p4-core-psa.cc | 6 ++++++ model/p4-core-v1model.h | 6 ++++++ model/p4-nic-pna.h | 6 ++++++ wscript | 0 5 files changed, 24 insertions(+) mode change 100644 => 100755 wscript diff --git a/model/p4-core-pipeline.cc b/model/p4-core-pipeline.cc index bd30e49..8e5c4e0 100644 --- a/model/p4-core-pipeline.cc +++ b/model/p4-core-pipeline.cc @@ -23,6 +23,12 @@ #include "ns3/register-access-v1model.h" #include "ns3/simulator.h" +#undef LOG_INFO +#undef LOG_ERROR +#undef LOG_DEBUG +#undef LOG_WARN +#undef LOG_LOGIC + NS_LOG_COMPONENT_DEFINE("P4CoreV1modelPipeline"); namespace ns3 diff --git a/model/p4-core-psa.cc b/model/p4-core-psa.cc index 94d0119..7362ccb 100644 --- a/model/p4-core-psa.cc +++ b/model/p4-core-psa.cc @@ -23,6 +23,12 @@ NS_LOG_COMPONENT_DEFINE("P4CorePsa"); +#undef LOG_INFO +#undef LOG_ERROR +#undef LOG_DEBUG +#undef LOG_WARN +#undef LOG_LOGIC + namespace ns3 { diff --git a/model/p4-core-v1model.h b/model/p4-core-v1model.h index 3af2e09..cd65086 100644 --- a/model/p4-core-v1model.h +++ b/model/p4-core-v1model.h @@ -28,6 +28,12 @@ #define SSWITCH_VIRTUAL_QUEUE_NUM_V1MODEL 8 +#undef LOG_INFO +#undef LOG_ERROR +#undef LOG_DEBUG +#undef LOG_WARN +#undef LOG_LOGIC + namespace ns3 { class P4CoreV1model : public P4SwitchCore { diff --git a/model/p4-nic-pna.h b/model/p4-nic-pna.h index 08970cc..2e80315 100644 --- a/model/p4-nic-pna.h +++ b/model/p4-nic-pna.h @@ -22,6 +22,12 @@ #include "ns3/p4-queue.h" #include "ns3/p4-switch-core.h" +#undef LOG_INFO +#undef LOG_ERROR +#undef LOG_DEBUG +#undef LOG_WARN +#undef LOG_LOGIC + namespace ns3 { diff --git a/wscript b/wscript old mode 100644 new mode 100755 From e50c0592ba3016662691f21acea58b4993384918 Mon Sep 17 00:00:00 2001 From: long long <84077194+kirazero17@users.noreply.github.com> Date: Mon, 15 Jun 2026 05:02:29 -0400 Subject: [PATCH 2/2] somehow, to fix the bm_runtime undefined, you need to manually copy the libbmruntime.a from the bmv2 build folder to /usr/local/lib, then edit the cmakelist and the set_pkg_config_env script as I do --- CMakeLists.txt | 23 +++++++++++++++++++++++ set_pkg_config_env.sh | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09b9b2b..ab21a89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,12 @@ include(FindPkgConfig) set(third_party_libraries "bm" "gmp" + "jsoncpp" + "libpcap" + "nanomsg" + "libxxhash" + "bmruntime" + "thrift" ) # Initialize variables to collect sources and libraries @@ -41,6 +47,23 @@ if(PKG_CONFIG_FOUND) endforeach() endif() +# Prefer pkg-config, but also add fallback libraries from /usr/local/lib +# to avoid unresolved BMv2/Thrift symbols when module names differ. +find_library(RUNTIMESTUBS_LIB runtimestubs PATHS /usr/local/lib) +if(RUNTIMESTUBS_LIB) + list(APPEND third_party_libs ${RUNTIMESTUBS_LIB}) +endif() + +find_library(BMRUNTIME_LIB bmruntime PATHS /usr/local/lib) +if(BMRUNTIME_LIB) + list(APPEND third_party_libs ${BMRUNTIME_LIB}) +endif() + +find_library(THRIFT_LIB thrift PATHS /usr/local/lib) +if(THRIFT_LIB) + list(APPEND third_party_libs ${THRIFT_LIB}) +endif() + list(APPEND third_party_libs -L/usr/local/lib) # Core module construction diff --git a/set_pkg_config_env.sh b/set_pkg_config_env.sh index ee2b147..ff0f9ca 100755 --- a/set_pkg_config_env.sh +++ b/set_pkg_config_env.sh @@ -11,6 +11,17 @@ Version: 1.15.0 Libs: -L\${libdir} -lbmall Cflags: -I\${includedir}" >/usr/local/lib/pkgconfig/bm.pc +echo "prefix=/usr/local +exec_prefix=\${prefix} +libdir=\${exec_prefix}/lib +includedir=/usr/local/include/bm + +Name: BMv2 +Description: Behavioral Model +Version: 1.15.0 +Libs: -L\${libdir} -lbmruntime +Cflags: -I\${includedir}" >/usr/local/lib/pkgconfig/bmruntime.pc + echo "prefix=/usr/lib/ exec_prefix=\${prefix} libdir=\${exec_prefix} @@ -32,3 +43,14 @@ Description: Behavioral Model Target Simple Switch Version: 1.15.0 Libs: -L\${libdir} -lsimpleswitch_thrift Cflags: -I\${includedir}" >/usr/local/lib/pkgconfig/simple_switch.pc + +echo "prefix=/usr/local +exec_prefix=\${prefix} +libdir=\${exec_prefix}/lib +includedir=/usr/local/include/bm + +Name: psa switch +Description: Behavioral Model Target PSA Switch +Version: 1.15.0 +Libs: -L\${libdir} -lpsaswitch_thrift +Cflags: -I\${includedir}" >/usr/local/lib/pkgconfig/psa_switch.pc \ No newline at end of file