Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / fatal error LNK1120: 1 unresolved externals :: what should I do ?

Author
Message
Can I use VC++ 6 with Dark GDK
16
Years of Service
User Offline
Joined: 8th Jan 2008
Location:
Posted: 12th Feb 2008 04:59
I have a library file but I don't know to import it to my project.
In the Import Library field, I put "MathFuncsDll.lib" to import it but after I built the project I have an error

Linking...
Main.obj : error LNK2019: unresolved external symbol "public: static double __cdecl MathFuncs::MyMathFuncs::Add(double,double)" (?Add@MyMathFuncs@MathFuncs@@SANNN@Z) referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
Debug\Call DLL.exe : fatal error LNK1120: 1 unresolved externals

I copy MathFuncsDll.dll, MathFuncsDll.lib, MathFuncsDll.h to the GarkGDK project.

In my program

#include "DarkGDK.h"
#include "MathFuncsDll.h"


void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );

dbLoadDLL( (DWORD) "MathFuncsDll.dll" , 2 );

as I told you I have an linking error

the dll file was created by vc++ 2008, I follow the help that teach how to create dynamic link library

and I want to call the dll by DarkGDK game

what should i do??

thanks so much much much
Can I use VC++ 6 with Dark GDK
16
Years of Service
User Offline
Joined: 8th Jan 2008
Location:
Posted: 12th Feb 2008 08:13
I found the other way in vc++ help

First I should follow the help for creating a new DLL file.

Then I must Config the project.

for my GDK program

#include "DarkGDK.h""
#include "MyDll.h" //include dll header file

using namespace MathFuncs; //use the name space in the dll file

void DarkGDK ( void )
{

dbSyncOn ( );
dbSyncRate ( 60 );

dbPrint( (double) MyMathFuncs::Add( 10, 20) );
dbPrint( (double) MyMathFuncs::Subtract( 10, 20) );
dbPrint( (double) MyMathFuncs::Multiply( 10, 20) );
dbPrint( (double) MyMathFuncs:ivide( 10, 20) );

////
using this methode no need to call dbLoadDLL(...)

but I still don't know how to solve a linking error that I occured

can someone help me please ?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 12th Feb 2008 12:43
Show us the way you declared the function in the DLL and the header file. Both definitions must match completely.

Can I use VC++ 6 with Dark GDK
16
Years of Service
User Offline
Joined: 8th Jan 2008
Location:
Posted: 12th Feb 2008 13:54
No problem sir.

I found it in vc++ 2008 help and you can see it by the following these steps
1. In start Page of VC++2008 --> Getting started --> Learn VC++ and then VC++ help will be loaded and please wait
2. find "Creating Reusable Code (C++)" link and click it
3. fine "Creating and Using a Dynamic Link Library (C++)" link and click it
4. you will see the way that it teaches.


this is a simple dll and I will show you how to create it
//Header file
__declspec(dllexport) int Sum( int a, int b );
__declspec(dllexport) int Subtract( int a, int b );
__declspec(dllexport) int Multiply( int a, int b );
__declspec(dllexport) int Divide( int a, int b );


//Implementation file
#include "MyDLLHeader.h"

int Sum( int a, int b ) return a + b;
int Subtract( int a, int b )return a - b;
int Multiply( int a, int b )return a * b;
int Divide( int a, int b )
{
if ( b == 0 )return -1;
return a / b;
}

//Dark GDK program
#include "DarkGDK.h"
#include "MyDLLHeader.h"

void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );

int result1 = Sum( 20, 20 );
dbPrint( (double) result1 );

//this is a simple way to create a dll file and use it in DarkGDK program but I still don't know how to use dbLoadDLL(...)
can someone help me please ?

thanks so much much much
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 12th Feb 2008 14:44 Edited at: 12th Feb 2008 14:47
You're not quite doing things right. In the main source file for the DLL you place the functions. You then put the definitions (with the __declspec(dllexport) modifier) in a header and include it.

Then you create a separate header with import definitions in (use the __declspec(dllimport) modifier), and include this in projects you want to use the DLL from.

If you want to dynamically load the DLL, use LoadLibrary and get the function addresses with GetProcAddress.

Can I use VC++ 6 with Dark GDK
16
Years of Service
User Offline
Joined: 8th Jan 2008
Location:
Posted: 13th Feb 2008 07:12
can you show me how to use dbLoadDLL and show me how to create a DLL file in the correct way.

I don't know much about DLL but I just use a DLL in a GAME

do you have an example to me?

thanks a lot

Login to post a reply

Server time is: 2024-11-20 01:12:34
Your offset time is: 2024-11-20 01:12:34