Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#149 Strange linking problems

release_3.9.x
closed
nobody
None
5
2012-09-15
2007-03-28
Kumar Appaiah
No

Dear IT++ developers,

I am using IT++ on Debian GNU/Linux (the experimental 3.99.1 package which I created).

I am having some problems linking IT++ files. Actually, I am unable to do so with this:

g++ pkg-config --cflags itpp ofdm.cpp -o ofdm pkg-config --libs itpp -Wall -ggdb

The error I get is:
g++ -ggdb -Wall itpp-config --cflags --libs ofdm.cpp -o ofdm
/tmp/ccZLD7TC.o: In function main': /home/kumar/CC++/itpp/OFDM/ofdm.cpp:9: multiple definition ofmain'
/usr/lib/libfrtbegin.a(frtbegin.o):(.text+0x0): first defined here
/usr/bin/ld: Warning: size of symbol main' changed from 69 in /usr/lib/libfrtbegin.a(frtbegin.o) to 3248 in /tmp/ccZLD7TC.o /usr/lib/libfrtbegin.a(frtbegin.o): In functionmain':
(.text+0x35): undefined reference to MAIN__' collect2: ld returned 1 exit status make: *** [ofdm] Error 1 make: Targetall' not remade because of errors.

However, with the following, it works smoothly:

g++ pkg-config --cflags itpp ofdm.cpp -o ofdm pkg-config --libs itpp -Wall -ggdb

Though this doesn't stop my work, this shouldn't happen, right? Or is this expected? I do notice that doing an nm on libfrtbegin.a shows that it has a main in it.

Should you need any more details, please tell me.

Thanks.

Kumar

Discussion

  • Logged In: YES
    user_id=1004597
    Originator: NO

    This is not a bug... and completely unrelated to the IT++ library.

    To perform compilation and linking at one stage, the compiler flags and sources needs to be passed before libraries, e.g.:
    a) CORRECT:
    g++ -O2 -g -I/usr/local/include -o abc abc.cpp -L/usr/local/lib -lmylib
    b) WRONG:
    g++ -O2 -g -I/usr/local/include -L/usr/local/lib -lmylib -o abc abc.cpp

    In future, please do not report unconfirmed bugs here. Instead, please ask on the Help forum before!

    /ediap