Request for assistance on build failed with "Undefined reference to 'main' collect2: error: ld returned 1 exit status" error

493 views
Skip to first unread message

Stephen Olu-Ojo

unread,
Jul 8, 2021, 6:35:30 AM7/8/21
to ns-3-users
Good day sir,
Please sir, my project deals with coordination of interference in LTE networks, by comparing the performances of Soft Fractional Frequency Reuse (SFFR) and Distributed Fractional Frequency Reuse (DFFR) Algorithms.  the source codes for  "lte-ffr-distributed-algorithm.cc" and "lte-ffr-soft-algorithm.cc" file are attached for both .cc and .h, and I have an error (undefined reference to 'main' , collect2: error: ld returned 1 exist status) for both algorithms whenever I try to run the algorithms on NS-3.29

Sir, I will be elated and it will be my greatest pleasure to hear from you as soon as possible, for further discussions and to move forward on my project.
Stephen Olu-Ojo.jpg
lte-ffr-soft-algorithm.h
lte-ffr-distributed-algorithm.cc
lte-ffr-distributed-algorithm.h
lte-ffr-soft-algorithm.cc

Adil Alsuhaim

unread,
Jul 9, 2021, 10:26:22 AM7/9/21
to ns-3-users
This error is a sign that some file under the ./scratch folder should have a main function but doesn't. None of your files have a main function. 

I usually create folders for my projects under scratch. For your example, try creating a folder MyLTE under scratch  and place all related files in MyLTE, and then run it as

    ./waf --run MyLTE
 
But in MyLTE, you must have one .cc file with a main function.  

Sanjay Jaiman

unread,
Jul 9, 2021, 1:47:44 PM7/9/21
to ns-3-users
I created a quick "main.cc" in your dir to link your program to build an executable.  It compiles and links.  You can build upon this - 

main.cpp - 

/**
 * SIMULATION shell
 *
 *
 * Sanjay Jaiman
 */

#include "lte-ffr-soft-algorithm.h"
#include <ostream>
#include <sstream>
#include <stdio.h>
#include <string>
#include <ctime>
#include <ns3/log.h>
#include <ns3/integer.h>

using namespace ns3;

// Logging keyword
NS_LOG_COMPONENT_DEFINE ("lte-ffr_simulation.cc");

void simRunUpdates();

int main(int argc, char *argv[]) {
    Ptr<LteFfrSoftAlgorithm> lte_ffr_alg = CreateObject<LteFfrSoftAlgorithm> ();
    lte_ffr_alg->SetAttribute("UlCommonSubBandwidth", IntegerValue(7));

    //---------------------------------------------------------------------------

    std::cout << "Starting Simulation..." << std::endl;
    Simulator::Stop(Seconds(15));

    Simulator::Schedule(Seconds(1), &simRunUpdates);

    Simulator::Run();

    //---------------------------------------------------------------------------
    Simulator::Destroy();

}


/**
 * Simulation Run Update
 */
void simRunUpdates() {
    time_t rawtime;
    struct tm* timeinfo;
    char buffer[80];

    time(&rawtime);
    timeinfo = localtime(&rawtime);

    strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S %Z", timeinfo);
    std::string str(buffer);

    std::cout << str << ": " << Simulator::Now().GetSeconds() << "1 seconds completed" << std::endl;

    Simulator::Schedule(Seconds(1), &simRunUpdates);
}



Stephen Olu-Ojo

unread,
Jul 15, 2021, 9:30:34 AM7/15/21
to ns-3-users
Thank you so much for your help and assistance.
I used the main.cc file you created and creating a folder for my work. It builds successfully but giving me msg="Log component "LteFfrSoftAlgorithm" has already been registered once.", file=../src/core/model/log.cc, line=128
terminate called without an active exception
I tried checking the log.cc file but I don't know what line 128 means, and i need help for the algorithm to run and give results needed for my work with respect to the throughput, capacity, and variation in the number of users.
Also, I need help on how to modify the algorithms based on the simulation parameters I want to work with.

Thank you so much for your time, as i await your quick response.
TStephen Olu-Ojo2.jpg

Tom Henderson

unread,
Jul 15, 2021, 9:45:50 AM7/15/21
to ns-3-...@googlegroups.com, Stephen Olu-Ojo
On 7/15/21 6:30 AM, Stephen Olu-Ojo wrote:
> Thank you so much for your help and assistance.
> I used the main.cc file you created and creating a folder for my work.
> It builds successfully but giving me msg="Log component
> "LteFfrSoftAlgorithm" has already been registered once.",

This error means that you have defined the log component
"LteFfrSoftAlgorithm" in more than one .cc file. Search your .cc files
and make sure it is defined only once.

- Tom

Stephen Olu-Ojo

unread,
Jul 22, 2021, 1:35:16 PM7/22/21
to ns-3-users
Thank you, it works perfectly.
Now I am trying to use GtkConfigStore to edit some default values, but its not bringing out the default values for editing, and I want to calculate the throughput and SINR as well. Please I will be grateful for help on this. Thank you once again.

Stephen

Stephen Olu-Ojo

unread,
Jul 22, 2021, 1:45:13 PM7/22/21
to ns-3-users

Good day Sanjay Jaiman, how are you doing?

Thanks for your help with the main.cc Algorithm.
Please I will love to have your WhatsApp contact and gmail for further discussions and as well get to know you.

I will be elated to receive your response on stephe...@gmail.com.

Kind regards.
Stephen

Ayesha M Ahamed

unread,
Aug 12, 2021, 6:31:11 AM8/12/21
to ns-3-users
did you get the solution to this problem?
even i am facing the same issue, kindly help me to solve it.
thanks and regards
Ayesha

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/7273b7b3-904d-466e-b439-76c3945ab3fen%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages