I am trying to build a test example with 2 DLL. Is it possible to built DLL that depend from each others.
Belove is my test. It doesn't work. (undefined reference to `_imp__cheamaf1@4')
What I do wrong?
Thanks for any help.
Mircea



// example_dll.h
// =================================
#ifndef EXAMPLE_DLL_H
#define EXAMPLE_DLL_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef BUILDING_EXAMPLE_DLL
#define EXAMPLE_DLL __declspec(dllexport)
#else
#define EXAMPLE_DLL __declspec(dllimport)
#endif

void __stdcall EXAMPLE_DLL hello(const char *s);

int EXAMPLE_DLL Double(int x);

#ifdef BUILDING_EXAMPLE_DLL1
#define EXAMPLE_DLL1 __declspec(dllexport)
#else
#define EXAMPLE_DLL1 __declspec(dllimport)
#endif

int  __stdcall EXAMPLE_DLL1 cheamaf1(int a);


#ifdef __cplusplus
}
#endif


#endif  // EXAMPLE_DLL_H

//example_dll.cpp
// ============================================
#include <stdio.h>
#include "example_dll.h"


__stdcall void hello(const char *s)
{
        printf("Hello %s\n", s);
    cheamaf1(2);
}
int Double(int x)
{
        return 2 * x;
}

//  example_dll1.cpp
// ================================
#include <stdio.h>
#include "example_dll.h"


__stdcall int cheamaf1(int a) {
   printf("a=[%i]\r\n", a);
}

// exemple_exe.cpp
// ==============================
#include <stdio.h>
#include "example_dll.h"

int main(void)
{
        hello("World\r\n");
        printf("%d\n", Double(333));


        return 0;
}


//
// ===================
cd C:\doc\T\01

g++ -c -DBUILDING_EXAMPLE_DLL example_dll.cpp
g++ -shared -o example_dll.dll example_dll.o -Wl,--out-implib,libexample_dll.a

g++ -c -DBUILDING_EXAMPLE_DLL1 example_dll1.cpp
g++ -shared -o example_dll1.dll example_dll1.o -Wl,--out-implib,libexample_dll1.a


g++ -c example_exe.cpp
g++ -o example_exe.exe example_exe.o -L. -lexample_dll  -lexample_dll1

example_exe > example_exe_rez.txt


===========================================
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd C:\doc\T\01

C:\doc\T\01>
C:\doc\T\01>g++ -c -DBUILDING_EXAMPLE_DLL example_dll.cpp

C:\doc\T\01>g++ -shared -o example_dll.dll example_dll.o -Wl,--out-implib,libexa
mple_dll.a
Creating library file: libexample_dll.a
example_dll.o:example_dll.cpp:(.text+0x21): undefined reference to `_imp__cheama
f1@4'
collect2: ld returned 1 exit status

C:\doc\T\01>
C:\doc\T\01>g++ -c -DBUILDING_EXAMPLE_DLL1 example_dll1.cpp

C:\doc\T\01>g++ -shared -o example_dll1.dll example_dll1.o -Wl,--out-implib,libe
xample_dll1.a
Creating library file: libexample_dll1.a

C:\doc\T\01>
C:\doc\T\01>
C:\doc\T\01>g++ -c example_exe.cpp

C:\doc\T\01>g++ -o example_exe.exe example_exe.o -L. -lexample_dll  -lexample_dl
l1

C:\doc\T\01>
C:\doc\T\01>example_exe > example_exe_rez.txt

C:\doc\T\01>