Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Export symbols from .a files (http://www.velocityreviews.com/forums/t446861-export-symbols-from-a-files.html)

ernesto 07-05-2005 06:22 PM

Export symbols from .a files
 
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


Victor Bazarov 07-05-2005 06:57 PM

Re: Export symbols from .a files
 
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


All times are GMT. The time now is 01:58 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.