473,395 Members | 2,437 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,395 software developers and data experts.

Unresolved Externals errors when using external .lib file

Hi all,

I'm trying to use some functions which are in an external library file called qhdlc.lib from within my C++ .Net program. I have a header file for this library (qhdlc.h) and have set the library as an "additional dependency" in Project Properties->Linker->Input. Even though I have done all of that, I still get unresolved token errors for every function in the library.

Sadly, I do not have access to the source code for the library - but need to access it from my C++ .Net program. The library is written in ANSI C, and works fine when used from a program written in ANSI C and compiled with an ANSI C compiler.

I have no idea what to check next. I have some books on C++ .Net, but they don't seem to have any help, and I haven't been able to find anthing using Google.

Anyone got any ideas?

Robin
---
Posted via DotNetSlackers.com
Nov 7 '06 #1
6 1977
<robintwwrote in message news:ui**************@TK2MSFTNGP02.phx.gbl...
I'm trying to use some functions which are in an external library file
called qhdlc.lib from within my C++ .Net program. I have a header file for
this library (qhdlc.h) and have set the library as an "additional
dependency" in Project Properties->Linker->Input. Even though I have done
all of that, I still get unresolved token errors for every function in the
library.

Sadly, I do not have access to the source code for the library - but need
to access it from my C++ .Net program. The library is written in ANSI C,
and works fine when used from a program written in ANSI C and compiled
with an ANSI C compiler.

I have no idea what to check next. I have some books on C++ .Net, but they
don't seem to have any help, and I haven't been able to find anthing using
Google.

Anyone got any ideas?
It could be a problem of C++ name decoration, aka name mangling

At the top of the header for the library written in C add this (or create a
new header from the old with the modifications)

#ifdef __cplusplus
extern "C" {
#endif

and at the bottom add this

#ifdef __cplusplus
extern }
#endif

And rebuild the entire project.

Regards,
Will

Nov 7 '06 #2
Hi,

Thanks for the response. I've tried doing that and the unresolved externals errors have disappeared (hooray!) but there is a new fatal linker error:

LNK1104: cannot open file "libc.lib"

Any ideas what I should do? I've searched my whole project, and nowhere does it seem to reference libc.lib (obviously I can't check in the lib file because it is compiled and I do not have access to the source code).

Robin
---
Posted via DotNetSlackers.com
Nov 7 '06 #3
<robintwwrote in message news:eP**************@TK2MSFTNGP03.phx.gbl...
Thanks for the response.
You are welcome.
I've tried doing that and the unresolved externals errors
have disappeared (hooray!) but there is a new fatal linker
error:

LNK1104: cannot open file "libc.lib"
I see.
Any ideas what I should do? I've searched my whole project,
and nowhere does it seem to reference libc.lib (obviously I
can't check in the lib file because it is compiled and I do not
have access to the source code).
I think that this means that the static library that you need specifies a
version of the runtime different from the one that you are using in the rest
of the project.

Try this: Go to the Linker Settings in your project's configuration. Choose
Input. In the text box labeled "Ignore Specific Library" enter

libc.lib

Relink.

Regards,
Will
Nov 7 '06 #4
Hi,

Thanks for the suggestion. I have tried that and now get the following linker errors:

LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function _DigiLogicalOpen

LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _DigiLogicalOpen

LNK2019: unresolved external symbol __imp__RegOpenKeyExA@20 referenced in function _DigiLogicalOpen

I am pretty sure that the function DigiLogicalOpen is in the qhdlc.lib file - but is not one of the publically accessible functions from that file.

You say that maybe the library was compiled using a different version of the library - well, as far as I know, the library was compiled with a standard ANSI C compiler, not using anything .Net related at all.

Hope that helps, and thanks for the help,

Robin
---
Posted via DotNetSlackers.com
Nov 7 '06 #5
robintw wrote:
Hi,

Thanks for the suggestion. I have tried that and now get the
following linker errors:

LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced
in function _DigiLogicalOpen

LNK2019: unresolved external symbol __imp__RegQueryValueExA@24
referenced in function _DigiLogicalOpen

LNK2019: unresolved external symbol __imp__RegOpenKeyExA@20
referenced in function _DigiLogicalOpen

I am pretty sure that the function DigiLogicalOpen is in the
qhdlc.lib file - but is not one of the publically accessible
functions from that file.

You say that maybe the library was compiled using a different version
of the library - well, as far as I know, the library was compiled
with a standard ANSI C compiler, not using anything .Net related at
all.
I looks like you need to add ADVAPI32.LIB to your linker inputs. That's
where RegCloseKey et al are decalred.

-cd
Nov 7 '06 #6
<robintwwrote in message news:Or*************@TK2MSFTNGP04.phx.gbl...
I am pretty sure that the function DigiLogicalOpen is in
the qhdlc.lib file - but is not one of the publically accessible
functions from that file.
Carl's suggestion is likely to get you over the last hurdle.
You say that maybe the library was compiled using a different
version of the library - well, as far as I know, the library was
compiled with a standard ANSI C compiler, not using anything
.Net related at all.
Well, there is not a single version of the library. There are several of
them. They differ as to whether they are implemented in a DLL or not,
whether they support multithreading or not, whether they have debug
information or not, etc.

The authors of your static library preferred one runtime, your project
requires another. I helped you tell the linker to ignore the static
library's preferred runtime.
... and thanks for the help,
You are welcome.

Regards,
Will
Nov 7 '06 #7

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

Similar topics

4
by: Rodolphe | last post by:
Hello, I'm French so sorry for my approximate English. When I try to compile a project under Visual C++ 6.0, I've got the following errors : applicap.obj : error LNK2001: unresolved external...
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...
3
by: Kevin Burton | last post by:
I am trying to use managed C++ but I am getting the following link errors: Metadata file 'D:\Projects\Visa\AddressVerification\AddressVerificat...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.