473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

unresolved external symbol/using an external dll

Hello,

I'm new to C++ development and I'm trying out figure out the cause of
an 'unresolved external symbol' error that I'm receiving when
compiling. Here is some history on what I'm doing:

I have an existing VC++ project that mostly just reads a SQL Server
database does some work on the data and insert the results into
another table. I have the need to incorproate some functionality from
a certain dll named cedb300.dll. cedb300.dll is an unsupported
Microsoft dll that allows the reading and writing of Windows CE
databases to a disk (as opposed to an actual device). I have a list of
function signatures that are externally available from this dll.

I only have access to the dll, so I used a program called 'DLL to Lib'
(http://www.binary-soft.com/dll2lib/dll2lib.htm) to generate a .lib
file from the dll. This appeared to be successful. I copied both the
cedb300.dll and cedb300.lib files into my VC++ project directory and
added cedb300.lib to 'Projects->Settings->Link->Object/library
modules'

I add a call in my VC++ project to one of the functions in
cedb300.dll, but when I try to compile I get a 'unresolved external
symbol' error message. Naturally, removing the call to the function
causes the error to go away and my app compiles.

So, being new to VC++, I'm not sure if there's some more code I need
to add to my source to allow me to call functions from an external
dll, or if VC++ is simply not able to access the .lib files or if the
lib file is corrupted, or all of the above.

Is there something else I need to add to my code/project to allow me
to call functions from an external dll? Or is there another tool
someone can recommend to create a lib from a dll?

Thanks very much,
-Scott
Jul 22 '05 #1
8 4135
I suspect that you have a calling convention problem. The linker of course
tells you the complete name of the undefined symbol, what you need to do is
dumpbin /exports on the DLL (or dumpbin /symbols on the lib) and find the
name in the library that you think should match the undefined external.
Once you have those names, post back with both names and someone can figure
out what's wrong (it's probably something like lack of __stdcall on your
function prototypes).

-cd

Scott Allen wrote:
Hello,

I'm new to C++ development and I'm trying out figure out the cause of
an 'unresolved external symbol' error that I'm receiving when
compiling. Here is some history on what I'm doing:

I have an existing VC++ project that mostly just reads a SQL Server
database does some work on the data and insert the results into
another table. I have the need to incorproate some functionality from
a certain dll named cedb300.dll. cedb300.dll is an unsupported
Microsoft dll that allows the reading and writing of Windows CE
databases to a disk (as opposed to an actual device). I have a list of
function signatures that are externally available from this dll.

I only have access to the dll, so I used a program called 'DLL to Lib'
(http://www.binary-soft.com/dll2lib/dll2lib.htm) to generate a .lib
file from the dll. This appeared to be successful. I copied both the
cedb300.dll and cedb300.lib files into my VC++ project directory and
added cedb300.lib to 'Projects->Settings->Link->Object/library
modules'

I add a call in my VC++ project to one of the functions in
cedb300.dll, but when I try to compile I get a 'unresolved external
symbol' error message. Naturally, removing the call to the function
causes the error to go away and my app compiles.

So, being new to VC++, I'm not sure if there's some more code I need
to add to my source to allow me to call functions from an external
dll, or if VC++ is simply not able to access the .lib files or if the
lib file is corrupted, or all of the above.

Is there something else I need to add to my code/project to allow me
to call functions from an external dll? Or is there another tool
someone can recommend to create a lib from a dll?

Thanks very much,
-Scott

Jul 22 '05 #2
Scott Allen wrote:
Hello,

I'm new to C++ development and I'm trying out figure out the cause of
an 'unresolved external symbol' error that I'm receiving when
compiling. Here is some history on what I'm doing:

I have an existing VC++ project that mostly just reads a SQL Server
database does some work on the data and insert the results into
another table. I have the need to incorproate some functionality from
a certain dll named cedb300.dll. cedb300.dll is an unsupported
Microsoft dll that allows the reading and writing of Windows CE
databases to a disk (as opposed to an actual device). I have a list of
function signatures that are externally available from this dll.

I only have access to the dll, so I used a program called 'DLL to Lib'
(http://www.binary-soft.com/dll2lib/dll2lib.htm) to generate a .lib
file from the dll. This appeared to be successful. I copied both the
cedb300.dll and cedb300.lib files into my VC++ project directory and
added cedb300.lib to 'Projects->Settings->Link->Object/library
modules'

I add a call in my VC++ project to one of the functions in
cedb300.dll, but when I try to compile I get a 'unresolved external
symbol' error message. Naturally, removing the call to the function
causes the error to go away and my app compiles.

So, being new to VC++, I'm not sure if there's some more code I need
to add to my source to allow me to call functions from an external
dll, or if VC++ is simply not able to access the .lib files or if the
lib file is corrupted, or all of the above.

Check out project options to the lib file that you are using.
Also make sure that you pass the relevant /libpath switch option with
the directory so that the linker can locate the lib file for linking.

HTH

--
Karthik
Humans please 'removeme_' for my real email.
Jul 22 '05 #3
Actually Windows CE only has cdecl calling convention.

Use dumpbin /exports on the library file. And then dumpbin /relocations on
the .obj file that calls the function.

Most likely you need to have the functions declared with extern "C". You
probably have a problem with name mangling. If so, you would see mangled
names when you dumpbin the .obj file.

--

Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:uH**************@TK2MSFTNGP12.phx.gbl...
I suspect that you have a calling convention problem. The linker of course tells you the complete name of the undefined symbol, what you need to do is dumpbin /exports on the DLL (or dumpbin /symbols on the lib) and find the
name in the library that you think should match the undefined external.
Once you have those names, post back with both names and someone can figure out what's wrong (it's probably something like lack of __stdcall on your
function prototypes).

-cd

Scott Allen wrote:
Hello,

I'm new to C++ development and I'm trying out figure out the cause of
an 'unresolved external symbol' error that I'm receiving when
compiling. Here is some history on what I'm doing:

I have an existing VC++ project that mostly just reads a SQL Server
database does some work on the data and insert the results into
another table. I have the need to incorproate some functionality from
a certain dll named cedb300.dll. cedb300.dll is an unsupported
Microsoft dll that allows the reading and writing of Windows CE
databases to a disk (as opposed to an actual device). I have a list of
function signatures that are externally available from this dll.

I only have access to the dll, so I used a program called 'DLL to Lib'
(http://www.binary-soft.com/dll2lib/dll2lib.htm) to generate a .lib
file from the dll. This appeared to be successful. I copied both the
cedb300.dll and cedb300.lib files into my VC++ project directory and
added cedb300.lib to 'Projects->Settings->Link->Object/library
modules'

I add a call in my VC++ project to one of the functions in
cedb300.dll, but when I try to compile I get a 'unresolved external
symbol' error message. Naturally, removing the call to the function
causes the error to go away and my app compiles.

So, being new to VC++, I'm not sure if there's some more code I need
to add to my source to allow me to call functions from an external
dll, or if VC++ is simply not able to access the .lib files or if the
lib file is corrupted, or all of the above.

Is there something else I need to add to my code/project to allow me
to call functions from an external dll? Or is there another tool
someone can recommend to create a lib from a dll?

Thanks very much,
-Scott


Jul 22 '05 #4
Michael J. Salamone [eMVP] wrote:
Actually Windows CE only has cdecl calling convention.


I got the impression that the OP is using code to read a CE database outside
WinCE. The presence or absense of extern "C" may very well be the problem
as well - good point.

-cd

Jul 22 '05 #5
Thanks for your responses. I found a link on the web that suggested
adding 'extern "C"' to the beginning of the function definitions in my
header file (a windows ce header named WINDBASE.H). This seemed to
solve my problem. I'm now able to compile and access the functions in
the lib file from within my application. Some functions throw a
runtime error, but I think that can be fixed.

The thing I'm confused about is that it seems that I should be able to
use just 'extern' instead of 'extern "C"'... the fact that the
function come from a C/C++ library should be the default, right?

Thanks, -Scott

Karthik <re*******************@yahoo.com> wrote in message news:<4092b10c$1@darkstar>...
Scott Allen wrote:
Hello,

I'm new to C++ development and I'm trying out figure out the cause of
an 'unresolved external symbol' error that I'm receiving when
compiling. Here is some history on what I'm doing:

I have an existing VC++ project that mostly just reads a SQL Server
database does some work on the data and insert the results into
another table. I have the need to incorproate some functionality from
a certain dll named cedb300.dll. cedb300.dll is an unsupported
Microsoft dll that allows the reading and writing of Windows CE
databases to a disk (as opposed to an actual device). I have a list of
function signatures that are externally available from this dll.

I only have access to the dll, so I used a program called 'DLL to Lib'
(http://www.binary-soft.com/dll2lib/dll2lib.htm) to generate a .lib
file from the dll. This appeared to be successful. I copied both the
cedb300.dll and cedb300.lib files into my VC++ project directory and
added cedb300.lib to 'Projects->Settings->Link->Object/library
modules'

I add a call in my VC++ project to one of the functions in
cedb300.dll, but when I try to compile I get a 'unresolved external
symbol' error message. Naturally, removing the call to the function
causes the error to go away and my app compiles.

So, being new to VC++, I'm not sure if there's some more code I need
to add to my source to allow me to call functions from an external
dll, or if VC++ is simply not able to access the .lib files or if the
lib file is corrupted, or all of the above.

Check out project options to the lib file that you are using.
Also make sure that you pass the relevant /libpath switch option with
the directory so that the linker can locate the lib file for linking.

HTH

Jul 22 '05 #6
You're right - I didn't read closely enough.

So, it's one of the two - the calling convention or the name mangling.
Dumpbin will shed light.

If you see _ and something like @8 at the end of a name, it's stdcall,
otherwise cdecl. If it's name mangling, you'll know it when you see it -
lot's of extra characters in front and in back of the name. And, it just
might be both. You'll have to adjust the declarations in your header file
appropriately.

--

Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Michael J. Salamone [eMVP] wrote:
Actually Windows CE only has cdecl calling convention.
I got the impression that the OP is using code to read a CE database

outside WinCE. The presence or absense of extern "C" may very well be the problem
as well - good point.

-cd

Jul 22 '05 #7

"Scott Allen" <sc*********@yahoo.com> wrote in message
news:f0**************************@posting.google.c om...
Thanks for your responses. I found a link on the web that suggested
adding 'extern "C"' to the beginning of the function definitions in my
header file (a windows ce header named WINDBASE.H). This seemed to
solve my problem. I'm now able to compile and access the functions in
the lib file from within my application. Some functions throw a
runtime error, but I think that can be fixed.

The thing I'm confused about is that it seems that I should be able to
use just 'extern' instead of 'extern "C"'... the fact that the
function come from a C/C++ library should be the default, right?

Thanks, -Scott


There is no language called C/C++, AFAIK its an invention of job recruitment
agencies. In reality C and C++ are two different languages and C++ typically
needs to be told that an external function has been compiled as C.

john
Jul 22 '05 #8
Thanks everyone!

"John Harrison" <jo*************@hotmail.com> wrote in message news:<c7************@ID-196037.news.uni-berlin.de>...
"Scott Allen" <sc*********@yahoo.com> wrote in message
news:f0**************************@posting.google.c om...
Thanks for your responses. I found a link on the web that suggested
adding 'extern "C"' to the beginning of the function definitions in my
header file (a windows ce header named WINDBASE.H). This seemed to
solve my problem. I'm now able to compile and access the functions in
the lib file from within my application. Some functions throw a
runtime error, but I think that can be fixed.

The thing I'm confused about is that it seems that I should be able to
use just 'extern' instead of 'extern "C"'... the fact that the
function come from a C/C++ library should be the default, right?

Thanks, -Scott


There is no language called C/C++, AFAIK its an invention of job recruitment
agencies. In reality C and C++ are two different languages and C++ typically
needs to be told that an external function has been compiled as C.

john

Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ida | last post by:
Hi, I am trying to build an dll with Microsoft Visual C++ but during the linking phase I get linking errors. Script.obj : error LNK2019: unresolved external symbol __imp__PyString_AsString...
2
by: Freddy | last post by:
I am not an experienced programmer, but I had a VC++ program I am trying to eliminate all the VC++ commands from it...and keeping it as a normal C/C++ program......I guess I have succeeded so far,...
5
by: cschettle | last post by:
I think you need to link with msvcrt.lib ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
2
by: Maydogg6 | last post by:
I need a hand with some stubborn link errors. I'm trying to recreate and old program from 6.0 into .NET, but for some reason when I try to compile I'm getting linking errors for all my function...
6
by: sadegh | last post by:
Hi I have a problem with my program in VC++6 When I compile it, the following errors are listed. I spend a lot of time on the groups.google.com to find its reason, but none of comments could...
5
by: bonnielym84 | last post by:
Im new here..didnt noe whether is this the rite way to post my problem..Really need help here..i've been stucked in this error from last wk..My problem is like this..Im using VC++ 6.0 to compile my C...
0
by: bonnielym84 | last post by:
Im new here and im not sure whether is this the right place for me to post my question..anyway..hope that you can help me..i have been stucked in this problem since last wk..My problem is..I'm using...
0
by: Ryan Gaffuri | last post by:
hlink72@hotmail.com (Eric) wrote in message news:<ab8d8b14.0308220550.54fb5f22@posting.google.com>... LNK1120 is a standard C++ error. you using Visual C++? Means your references a class that...
2
by: =?Utf-8?B?YmFzaA==?= | last post by:
Hello, I am compiling a CPP code using Visual studion .net 2003. I get the following error, despite having windldap.h and wldap32.dll in my include and lib paths. Here is the error. uuid.lib...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.