Main DLL use other DLL's return value

Hi Friends..

Currently i use VC++ 6.0, and Windows XP SP3
I want to know how to use other DLL's return value to be used in my Main DLL,
Is it possible?..

Here's my scenario of what i've done :
Actually, i have already tried to create DLL project. And i'm succeed to create that DLL. (this DLL is used for computations required for my Main DLL)
My Test1.def contains as bellow :
LIBRARY TESTDLL

EXPORTS
method1 @1
method2 @2

In the \Debug Folder of our project there are files such as :
- Test1.DLL
- Test1.Lib

And then i copied Test1.DLL in the C:\Windows folder
After that i tried to create Main DLL project, and i included Test1.Lib in the project's folder and in the project setting, and then in the Main DLL project, i created header file Test1.h for declare function supported by Test1.DLL :

#ifndef TEST_H
#define TEST_H

int method1(int a, int b);
int method2(int a, int b, int c);

#endif

and then i used method1 in my Main DLL, but i got error message :..

Linking...
Creating library Release/MAINDLL.lib and object Release/MAINDLL.exp
MAINDLL.obj : error LNK2001: unresolved external symbol _method1
Release/MAINDLL.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Creating browse info file...

Please help me regarding this..

Thanks
Add 'Test1.Lib' to your linker input. hm, I think you don't need 'Test1.def'
Hi coder777,

Thanks for your reply.
Yes i have already added Test1.Lib in my Linker Input.
But, it's still the same.
I'm still got error as below :
Creating library Release/MAINDLL.lib and object Release/MAINDLL.exp
MAINDLL.obj : error LNK2001: unresolved external symbol _method1
Release/MAINDLL.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Creating browse info file...

But, i don't found problem when i use that Test.Lib in my Main Application, int main(){}..

Still confused :(

Please help me regarding this,

Thanks
That might has something to do with name mangling

try this

1
2
3
4
5
6
7
8
9
10
#ifndef TEST_H
#define TEST_H

extern "C"
{
int method1(int a, int b);
int method2(int a, int b, int c);
}

#endif 
Hi coder777,

sorry for long time reply.. :)

i have tried using that, by adding extern "C" {}, but i got error message :
error C2059: syntax error : 'string'

Actually, in my project, i created DLL using C++ to be used in C DLL, (note : MainDLL is C App)..
I'm curious, can we use any DLLs (C++ or C) to be used in C DLL?..

If i created all DLLs written using C++, and these DLLs are used in MainDLL (which created using C++ DLL also), i didn't get any problems..

Please help me regarding this..

Thanks in advance
Actually, in my project, i created DLL using C++ to be used in C DLL, (note : MainDLL is C App)..
I'm curious, can we use any DLLs (C++ or C) to be used in C DLL?..

Please help me regarding this.. :(

Any help would be appreciated..

Thanks
There's no problem mingling c and c++.

i have tried using that, by adding extern "C" {}, but i got error message :
error C2059: syntax error : 'string'
because 'string' isn't C.

Don't use 'string' across dll boundries. As far as I know memory that is allocated in the dll must not be freed in your application (and vice versa). Just check it.

A while ago I fiddled about with dll. I used something along the line
__declspec(dllexport) void __cdecl Start(CInterface *const iface, const bool auto_start); maybe that's it.

Hi coder777,

by the way, thanks for your replies..
now, i have already solved the problem..
Actually, in my project i have to create supplementary DLLs (written in C++).. To be used by my MainDLL (written in C)..

I follow your suggestion by using this code :
1
2
3
4
5
6
7
8
9
#ifndef TEST_H
#define TEST_H

extern "C"
{
int method1(int a, int b);
int method2(int a, int b, int c);
}
#endif  


Should i use that code in supplementary DLL (written in C++), but i added the code in my MainDLL instead, because of this i got error message : error C2059: syntax error : 'string' .. :(


And then i have a question, whether all of Supplementary DLLs need to be placed in the C:\Windows>?..
Can we place it in the same directory with MainDLL?.. (Assume, my MainDLL's directory is in D:\Test>)..
I have already tried using this way, but it couldn't work.. :(


Thanks..
Topic archived. No new replies allowed.