ld : Undefined symbol - Aix

This is a discussion on ld : Undefined symbol - Aix ; can someone tell me why I get undefined symbols from my library libtest.a ? IBM XL C/C++ Version 8.0 ld from AIX 5.3 installation. on linux with gcc and GNU ld version 2.17 Debian GNU/Linux it works fine. t.cpp : ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: ld : Undefined symbol

  1. ld : Undefined symbol

    can someone tell me why I get undefined symbols from my library
    libtest.a ?
    IBM XL C/C++ Version 8.0
    ld from AIX 5.3 installation.

    on linux with gcc and GNU ld version 2.17 Debian GNU/Linux it works
    fine.

    t.cpp :
    int main(int argc, char **argv){
    //
    // here I call some functions from libtest.a
    // but not the function foo()!
    //
    }

    t2.h :
    class myclass {
    public:
    myclass();
    };

    t1.cpp :
    #include "t2.h"
    static myclass d;
    void foo() {
    }


    xlC -c t1.cpp
    ar rv libtest.a t1.o
    xlC -L. -ltest t.cpp

    ld: 0711-317 ERROR: Undefined symbol: .myclass::myclass()
    ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
    information.

    I know it is the "static myclass d;" but I don't refer to it.

    regards
    udo


  2. Re: ld : Undefined symbol

    On Thu, 05 Jul 2007 23:56:39 -0700, huber wrote:

    > can someone tell me why I get undefined symbols from my library
    > libtest.a ?
    > IBM XL C/C++ Version 8.0
    > ld from AIX 5.3 installation.
    >
    > on linux with gcc and GNU ld version 2.17 Debian GNU/Linux it works
    > fine.
    >
    > t.cpp :
    > int main(int argc, char **argv){
    > //
    > // here I call some functions from libtest.a
    > // but not the function foo()!
    > //
    > }
    >
    > t2.h :
    > class myclass {
    > public:
    > myclass();
    > };
    >
    > t1.cpp :
    > #include "t2.h"
    > static myclass d;
    > void foo() {
    > }
    >
    >
    > xlC -c t1.cpp
    > ar rv libtest.a t1.o
    > xlC -L. -ltest t.cpp
    >
    > ld: 0711-317 ERROR: Undefined symbol: .myclass::myclass()
    > ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
    > information.
    >
    > I know it is the "static myclass d;" but I don't refer to it.
    >
    > regards
    > udo


    Well... You're defining variable "d" at file scope as a global at file
    scope. Wouldn't that mean loading the module implicitly calls the
    default constructor for class "myclass"?

    -Chris

+ Reply to Thread