Issue building ns-3.28 on Macbook M1 (ARM based)

1,756 views
Skip to first unread message

Nathália Vasconcelos

unread,
May 16, 2021, 11:48:01 PM5/16/21
to ns-3-users
Hi, everyone. I hope you are all well. I have been pondering about posting this here, but I am feeling that I won't go further without your help. I am currently running Mac Os X Big Sur version 11.3.1, with an M1 Chip (ARM-64). First and foremost, I tried to build the latest version following the steps described at https://www.nsnam.org/docs/tutorial/html/getting-started.html. I chose to Download ns-3 using Git, specifically with the download.py command and then I followed up to the Building with build.py section. I managed to build the project with success using ns-3.33 and ns-3-dev. Then, I downloaded using the command ./download.py -n ns-3.28 and tried to build this version. Unfortunately, it did not work. The next step was to fully delete the folder and only download ns-3.28. I tried to build it and faced the some errors such as:

[ 923/2642] Compiling src/sixlowpan/examples/example-ping-lr-wpan.cc

In file included from src/fd-net-device/bindings/ns3module.cc:1:

In file included from src/fd-net-device/bindings/ns3module.h:3:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:61:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyport.h:325:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:

../version:1:1: error: expected unqualified-id

3-dev

I had some problems with C++ typedef such as ptrdiff_t using xcode command line tools version 2384. My gcc is 4.2.1 and my clang is 12.0.5.

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:674:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iterator:562:13: error: unknown type name 'ptrdiff_t'

    typedef ptrdiff_t difference_type;

Since I am out of ideas on how to solve it, I wanted to hear from you if you faced a similar problem or if you want to share a line of thought about it, I would be glad to read it.

Nathália Vasconcelos

unread,
May 16, 2021, 11:53:10 PM5/16/21
to ns-3-users
As I mentioned above, version ns-3.33 works like a charm. Why I think this is important to mention in this thread: because it indicates that my environment is able to successfully compile C++ and Python code and ARM architecture is compatible with the newest version of ns-3.

Waf: Leaving directory `/Users/nath/workspace/ns-3-allinone/ns-3.33/build'

Build commands will be stored in build/compile_commands.json

'build' finished successfully (3m26.110s)

Leaving directory `/Users/nath/workspace/ns-3-allinone/./ns-3.33'

% ./waf --run hello-simulator

Waf: Entering directory `/Users/nath/workspace/ns-3-allinone/ns-3.33/build'

Waf: Leaving directory `/Users/nath/workspace/ns-3-allinone/ns-3.33/build'

Build commands will be stored in build/compile_commands.json

'build' finished successfully (0.507s)

Hello Simulator

Sagar Patel

unread,
Jun 12, 2021, 11:25:43 PM6/12/21
to ns-3-users
This problem not isolated to M1 Macs. Rather, I think this issue is tied to a newer version of clang shipped with macOS Big Sur. ns-3.30.1, ns-3.31 and ns-3.32 do not compile on macOS Big Sur either for the same reason:

../../version:1:1: error: expected unqualified-id
3.30.1

I haven't tried installing an older version of clang to see if this is indeed the problem.

Sagar Patel

unread,
Jun 13, 2021, 7:52:40 PM6/13/21
to ns-3-users
I've debugged the issue, and it looks like the ns-3 developers have already figured it out as well [1, 2]. I'll let you check out #309 for details of what the problem is.

Ideally you try to figure out which commits to cherry-pick to prevent .. from being included, but I couldn't find a particular set that worked well, so I created a hack. Take a look at the attached patch. It boils down to
  • changing the VERSION variable in ./wscript to whatever version of ns-3 you're using, and
  • deleting the VERSION file in the top-level directory.
This compiles (and runs) ns-3.30.1 on the most recent version of macOS and Xcode. For other versions of ns-3, set the version variable accordingly.
version.patch

htahi...@gmail.com

unread,
Feb 25, 2023, 5:00:27 PM2/25/23
to ns-3-users

I have tried deleting the VERSION file and editing ./wscript with correct version of it, still not working. 

BTW, how i can apply the patch file you have provided above?

Output:

Entering directory `/Users/abcd/ns-allinone-3.32/./ns-3.32'

 =>  /usr/local/opt/pyt...@3.11/bin/python3.11 waf configure --enable-examples --enable-tests --with-pybindgen ../pybindgen-0.21.0

Waf: The wscript in '/Users/abcd/ns-allinone-3.32/ns-3.32' is unreadable

Traceback (most recent call last):

  File "/Users/abcd/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 102, in waf_entry_point

    set_main_module(wscript)

  File "/Users/abcd/ns-allinone-3.32/ns-3.32/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Scripting.py", line 142, in set_main_module

    Context.g_module=Context.load_module(file_path)

htahi...@gmail.com

unread,
Feb 25, 2023, 5:01:01 PM2/25/23
to ns-3-users
Hej! have you been able to solve the problem?

Tommaso Pecorella

unread,
Feb 25, 2023, 6:00:33 PM2/25/23
to ns-3-users

Beware: older ns-3 releases are NOT supported.
In particular, for ARM-based Macs I'd strongly suggest to use no less than 3.37, as we fixed several issues, some of them related to the different floating point architecture.

Moreover, WAF has been removed, and now ns-3 uses cmake.

igs...@gmail.com

unread,
Jan 9, 2024, 3:53:30 AMJan 9
to ns-3-users
Hello ns-3 Users,

Yesterday, I tried to install ns-3 on an ARM based new Apple Mac M2.

The Screenshots are very big because of the high resolutions of that amazing M2 MacBook - So I could not past the entire procedure here.

I just followed the official ns-3 installation procedure presented in https://www.nsnam.org/docs/installation/ns-3-installation.pdf.

I recorded all the steps and presented them as it is in my blog : Procedure for Installing ns-3 (3.40) on New Apple Mac M1/M2.

Even though it is a very late reply, I am writing this here because, still, someone wants to install ns-3 on their Mac M1/M2.

Charles Pandian.
Reply all
Reply to author
Forward
0 new messages