Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Errors

Status
Not open for further replies.

davewelsh

Programmer
Jun 26, 2001
71
CA
I have a program that requires a dll called qcode32.dll. The program is just two files: demo.cpp and qcode32.h which has the type definition used for the dll fuction calls. I also have qcode32.lib.

The qcode32.h goes something like this:
>typedef struct { ... } POSTREC;
>void __declspec (dllimport) QCODE32(POSTREC * postrec, int parm);


and the demo.cpp goes something like this:
>#include qcode32.h
>main()
>{
>...
>QCODE32((POSTREC *)&x, y);
>...
>}


Now I can compile this by running from the command line:
>cl demo.cpp qcode32.lib


But I can't make a project that will compile. I open the .cpp in vc++ and tell it to build and then vc++ creates a default project for me. I add the .h. Then I go to project->setting->link and add qcode32.lib, but when I build I get the error:

>error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl QCODE32(struct POSTREC *,int)" (__imp_?QCODE32@@YAXPAUPOSTREC@@H@Z)

:(
Can anyone tell me how to set up a simple project that will compile this? (I have a larger project that I want to integrate with this dll)
 
Update:

I've sucessfully made a console application and a win32 application with the four files. Now my problem is getting it to work in an MFC application.

I used the MFC AppWizard to create a dialog-based application and I want to call the dll procedures in the CWhateverDlg class. I added: #include "qcode32.h"
to WhateverDlg.cpp and in project->settings->link, I added qcode32.lib. But I still get the error when I compile.
 
Ok. I found out that the simple projects compiled because they used .c files. If I rename them to .cpp, they don't link properly. Does anyone know why this is?

My dialog-based app uses .cpp files and I doubt I could just rename all .cpp files to .c files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top