./waf gives undefined reference to main error

1.691 Aufrufe
Direkt zur ersten ungelesenen Nachricht

grim

ungelesen,
07.11.2014, 13:43:1707.11.14
an ns-3-...@googlegroups.com
I had to make a modified version of BulkSendApplication and it seems to give me this error when I try to build it. I made all the changes that I needed to make so that it wouldn't give any problems about two BulkSendApplication classes being compiled as well as adding what I needed in the my custom version. I get a bunch of these:

/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crtl.0(.debug_info): relocation ## has invalid symbol index ##

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_g6-linux-gnu/crtl.0: In function '_start':
(.text+0x20): undefined reference to 'main'
collect2: ld returned 1 exit status

Is this because I didn't remove the namespace ns3{} that encases the code in the files?

grim

ungelesen,
07.11.2014, 14:54:4007.11.14
an ns-3-...@googlegroups.com
Doing a bit of testing, I now believe that it is a problem with linking (never had this kind of problem before).  Is there a way to compile programs in ./waf using a makefile (or something equivalent)?  If so how do this?

Konstantinos

ungelesen,
07.11.2014, 15:42:5507.11.14
an ns-3-...@googlegroups.com
The equivalent of makefile for waf is wscript. 
I would suggest to study a bit the manual about how you can add a new model http://www.nsnam.org/docs/manual/html/support.html
You can simply extend the functionality of BulkSend without having any compiling/error problems.

grim

ungelesen,
07.11.2014, 16:08:1007.11.14
an ns-3-...@googlegroups.com
That's what we were trying to do before, but it would still have to be in separate files since our project is pretty big.  Thanks for the wscript info though, I'll take a look at it.

grim

ungelesen,
07.11.2014, 17:35:4307.11.14
an ns-3-...@googlegroups.com
I've read the document, and have my own wscript right now now but after i run the configure command, the build command still gives the linker errors.

Tom Henderson

ungelesen,
07.11.2014, 17:49:1807.11.14
an ns-3-...@googlegroups.com
On 11/07/2014 02:35 PM, grim wrote:
> I've read the document, and have my own wscript right now now but after
> i run the configure command, the build command still gives the linker
> errors.
>

Are you sure that your main() function is _not_ within namespace ns3 or
some other namespace? Not having a main() defined at global scope will
lead to this error. This doesn't look like a waf issue but instead the
compiler is complaining.

- Tom

grim

ungelesen,
07.11.2014, 17:58:4407.11.14
an ns-3-...@googlegroups.com
yup positive. 
I have a using namespace ns3;, but that's it.

grim

ungelesen,
07.11.2014, 18:12:4807.11.14
an ns-3-...@googlegroups.com
Here's what I get on the build command:

[1775/1789] cxxprogram: build/scratch/bulksend.cc.4.o -> build/scratch/bulksend
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crtl.0(.debug_info): relocation ## has invalid symbol index ##

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_g6-linux-gnu/crtl.0: In function '_start':
(.text+0x20): undefined reference to 'main'
collect2: ld returned 1 exit status

On Friday, November 7, 2014 1:43:17 PM UTC-5, grim wrote:

Tom Henderson

ungelesen,
07.11.2014, 18:44:2207.11.14
an ns-3-...@googlegroups.com
On 11/07/2014 03:12 PM, grim wrote:
> Here's what I get on the build command:
>
> [1775/1789] cxxprogram: build/scratch/bulksend.cc.4.o ->
> build/scratch/bulksend /usr/bin/ld:
> /usr/lib/debug/usr/lib/x86_64-linux-gnu/crtl.0(.debug_info):
> relocation ## has invalid symbol index ##
>
> /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_g6-linux-gnu/crtl.0:
> In function '_start': (.text+0x20): undefined reference to 'main'
> collect2: ld returned 1 exit status
>

The scratch directory is set up to create executables without needing a
wscript, but not for building multiple object files and linking them
together. So, the main choices for you are to:

1) add your application model files to the src/applications module and
modify the wscript accordingly
2) create a new module (as Konstantinos suggested)
3) write your own Makefile or wscript to do something else

- Tom

Konstantinos

ungelesen,
07.11.2014, 18:54:1907.11.14
an ns-3-...@googlegroups.com
Or, create a new folder in scratch and have multiple files there but only one with main.

Tom Henderson

ungelesen,
07.11.2014, 19:17:4907.11.14
an ns-3-...@googlegroups.com
On 11/07/2014 03:54 PM, Konstantinos wrote:
> Or, create a new folder in scratch and have multiple files there but
> only one with main.

Yes, this is probably not clear from the files provided by default in
subdir/.

- Tom

grim

ungelesen,
07.11.2014, 20:03:2307.11.14
an ns-3-...@googlegroups.com
Sorry at this point, I'm probably just really annoying now.  I ran into this issue with the subdirectory inside scratch. waf says that it can't create the directory that i made in scratch.  I assume this means I need a wscript that does something with the directory.  I can't find anything in the link you gave me nor a good example inside of ns3 directories.
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten