Export symbols from .a files

Discussion in 'C++' started by ernesto, Jul 5, 2005.

  1. ernesto

    ernesto Guest

    Hi, everybody:

    I created this very small class on Windos32, mingw:

    main.h
    ------
    #ifdef DLL
    #define DLLEXPORT __declspec(dllexport)
    #else
    #define DLLEXPORT __declspec(dllimport)
    #endif

    class DLLEXPORT A
    {
    public:
    A();
    virtual ~A();

    virtual const char* GetMessage();
    };

    class DLLEXPORT B : public A
    {
    public:
    B();
    virtual ~B();

    virtual const char* GetMessage();
    };


    main.cpp
    ----------
    #include <stdio.h>

    #include "main.h"

    A::A()
    {
    printf("A constructor\n");
    }

    A::~A()
    {
    printf("A destructor\n");
    }

    const char* A::GetMessage()
    {
    return "Hello A world";
    }

    B::B()
    {
    printf("B constructor\n");
    }

    B::~B()
    {
    printf("B destructor\n");
    }

    const char* B::GetMessage()
    {
    return "B sides are better";
    }

    I compiled it using:

    g++ -c main.cpp -DDLL
    ar -r main.a main.o
    g++ -shared -o main.dll main.a -Wl,-output-def,main.def

    and it does not export any symbols, but doing a:

    g++ -shared -o main.dll main.o -Wl,-output-def,main.def

    exports all classes and methods perfectly.

    Any ideas?


    ernesto
    ernesto, Jul 5, 2005
    #1
    1. Advertising

  2. ernesto wrote:
    > Hi, everybody:
    >
    > I created this very small class on Windos32, mingw:
    >
    > main.h
    > ------
    > [...]
    > main.cpp
    > ----------
    > [...]
    > I compiled it using:
    >
    > g++ -c main.cpp -DDLL
    > ar -r main.a main.o
    > g++ -shared -o main.dll main.a -Wl,-output-def,main.def
    >
    > and it does not export any symbols, but doing a:
    >
    > g++ -shared -o main.dll main.o -Wl,-output-def,main.def
    >
    > exports all classes and methods perfectly.
    >
    > Any ideas?



    Please post to a newsgroup dedicated to your compiler. Your question
    is compiler-specific and as such is off-topic in a language newsgroup.
    I recommend gnu.g++.help.

    V
    Victor Bazarov, Jul 5, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2aWQgVmFsbGU=?=

    Invalid export DLL or export format

    =?Utf-8?B?RGF2aWQgVmFsbGU=?=, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,614
    =?Utf-8?B?RGF2aWQgVmFsbGU=?=
    Oct 29, 2003
  2. ernesto

    Cannot export class symbols

    ernesto, Jun 28, 2005, in forum: C++
    Replies:
    1
    Views:
    489
    Victor Bazarov
    Jun 28, 2005
  3. Replies:
    3
    Views:
    1,456
    Rolf Magnus
    Jan 18, 2009
  4. Maarten Porters
    Replies:
    1
    Views:
    426
    Florian Gilcher
    Jul 28, 2008
  5. John Kelly

    export symbols

    John Kelly, Jun 23, 2010, in forum: Perl Misc
    Replies:
    2
    Views:
    104
    John Kelly
    Jun 23, 2010
Loading...

Share This Page