The attachement includes three projects

/d/VC6Projects/X1 => created in VC, generate DLL

/d/MyCProjects/T2 => created in Eclipse CDT, Export DLL

/d/MyCProjects/T3 => created in Eclipse CDT, import both X1 dll && T2 Dll

 

$ cat  /d/VC6Projects/X1/FApi.cpp

// FApi.cpp: implementation of the FApi class.

//

//////////////////////////////////////////////////////////////////////

 

#define FAPI_LIB

//include "stdafx.h"

#include "FApi.h"

 

//////////////////////////////////////////////////////////////////////

// Construction/Destruction

//////////////////////////////////////////////////////////////////////

 

FApi::FApi()

{

 

}

 

FApi::~FApi()

{

 

}

 

void FApi::sayHello()

{

 

}

 

###

### I compiled  the class to X1.dll in VC6.

###

 

$ nm X1.dll

nm: X1.dll: no symbols

 

Vic@Teck-ZhangWK /d/VC6Projects/X1/Release

$  pexports X1.dll >X1.def

 

Vic@Teck-ZhangWK /d/VC6Projects/X1/Release

$ cat X1.def

LIBRARY X1.dll

EXPORTS

??0FApi@@QAE@ABV0@@Z

??0FApi@@QAE@XZ

??1FApi@@UAE@XZ

??4FApi@@QAEAAV0@ABV0@@Z

??_7FApi@@6B@ DATA

?sayHello@FApi@@UAEXXZ

 

#

# It seems the def has so many

#

Vic@Teck-ZhangWK /d/VC6Projects/X1/Release

 

 

 

 

$ dlltool -dllname X1.dll -d X1.def -l libX1.a

 

Vic@Teck-ZhangWK /d/VC6Projects/X1/Release

$  nm libX1.a

 

dkbkt.o:

00000000 b .bss

00000000 d .data

00000000 i .idata$4

00000000 i .idata$5

00000000 i .idata$7

00000000 t .text

00000000 I __libX1_a_iname

 

dkbkh.o:

00000000 b .bss

00000000 d .data

00000000 i .idata$2

00000000 i .idata$4

00000000 i .idata$5

00000000 t .text

00000000 I __head_libX1_a

         U __libX1_a_iname

00000000 i fthunk

00000000 i hname

 

dkbks00005.o:

00000000 b .bss

00000000 d .data

00000000 i .idata$4

00000000 i .idata$5

00000000 i .idata$6

00000000 i .idata$7

00000000 t .text

00000000 T ?sayHello@FApi@@UAEXXZ

         U __head_libX1_a

00000000 I __imp_?sayHello@FApi@@UAEXXZ

 

dkbks00004.o:

00000000 b .bss

00000000 d .data

00000000 i .idata$4

00000000 i .idata$5

00000000 i .idata$6

00000000 i .idata$7

00000000 t .text

         U __head_libX1_a

00000000 I __imp_??_7FApi@@6B@

 

dkbks00003.o:

00000000 b .bss

00000000 d .data

00000000 i .idata$4

00000000 i .idata$5

00000000 i .idata$6

00000000 i .idata$7

00000000 t .text

00000000 T ??4FApi@@QAEAAV0@ABV0@@Z

         U __head_libX1_a

00000000 I __imp_??4FApi@@QAEAAV0@ABV0@@Z

 

dkbks00002.o:

00000000 b .bss

00000000 d .data

00000000 i .idata$4

00000000 i .idata$5

00000000 i .idata$6

00000000 i .idata$7

00000000 t .text

00000000 T ??1FApi@@UAE@XZ

         U __head_libX1_a

00000000 I __imp_??1FApi@@UAE@XZ

 

dkbks00001.o:

00000000 b .bss

00000000 d .data

00000000 i .idata$4

00000000 i .idata$5

00000000 i .idata$6

00000000 i .idata$7

00000000 t .text

00000000 T ??0FApi@@QAE@XZ

         U __head_libX1_a

00000000 I __imp_??0FApi@@QAE@XZ

 

dkbks00000.o:

00000000 b .bss

00000000 d .data

00000000 i .idata$4

00000000 i .idata$5

00000000 i .idata$6

00000000 i .idata$7

00000000 t .text

00000000 T ??0FApi@@QAE@ABV0@@Z

         U __head_libX1_a

00000000 I __imp_??0FApi@@QAE@ABV0@@Z

 

Vic@Teck-ZhangWK /d/VC6Projects/X1/Release

 

 

$ cat /d/MyCProjects/T3/T3.cpp

//============================================================================

// Name        : T3.cpp

// Author      : Vic

// Version     :

// Copyright   : Vic

// Description : Hello World in C++, Ansi-style

//============================================================================

 

#include <iostream>

#include <FApi.h>

#include <FApi2.h>

#include <t1.h>

using namespace std;

 

int main() {

        //cout << "Hello World" << endl; // prints Hello World

        printf("Hello!!!\n");

 

    MyClass a;

    a.myfunc();

    a.myStaticFunc();

    MyClass::myStaticFunc();

 

 

        FApi agent1;

        agent1.sayHello();

 

        FApi2 agent2;

        agent2.sayHello();

 

 

        return 0;

}

 

###

### But I get the following error when I compile the above cpp file in Cygwin g++ enviroment:

###

/cygdrive/d/MyCProjects/T3/Debug/../T3.cpp:25: undefined reference to `__imp___ZN4FApiC1Ev'

/cygdrive/d/MyCProjects/T3/Debug/../T3.cpp:26 : undefined reference to `FApi::sayHello()'

/cygdrive/d/MyCProjects/T3/Debug/../T3.cpp:32: undefined reference to `FApi::~FApi()'

makefile:44: recipe for target `T3.exe' failed

/cygdrive/d/MyCProjects/T3/Debug/../T3.cpp:32: undefined reference to `FApi::~FApi()'

collect2: ld returned 1 exit status

 

###

### How do I generate the libX1.a file?

###