473,386 Members | 1,673 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,386 software developers and data experts.

Add a VC 6 library in a VC8 project

Hi,
Is it possible to add a VC++ 6 library ot a VC++ 8 application ? if yes
how ? is it possible to link a DLL ? how ?

-- Dani

Nov 30 '05 #1
4 1389
Hi danip!
Is it possible to add a VC++ 6 library ot a VC++ 8 application ? if yes
how ? is it possible to link a DLL ? how ?


In general you can say:
It is *only* possible if it only exports C functions (and has not a
shared CRT).

In all other cases it is almost impossible to use an older LIB with a
newer VC-Version.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 30 '05 #2
"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote
Is it possible to add a VC++ 6 library ot a VC++ 8 application ? if yes
how ? is it possible to link a DLL ? how ?
In general you can say:
It is *only* possible if it only exports C functions (and has not a shared
CRT).

Um, why? Since all references from the VC6 code are resolved
when linking the full image, I don't see how it could work if you
use things like CString internally, but export C functions only.

What's wrong with the shared CRT? In all other cases it is almost impossible to use an older LIB with a
newer VC-Version.


Elaborting on that, the ABI is supposed to be stable. I.e. the exact
same source code should be binary compatible. The real problem
is the runtime library.

The MFC, ATL, STL (CRT is safe in most cases) implementations
of different VC versions are not necessarily compatible at the binary
or object level.

So, as long as you don't use any of these (regardless of whether
it's in the interface or the implementation) you have good
chances that it just works.

Also note, that the defaults for some switches, which have an
impact on the ABI, have changed (e.g. /Zc:wchar_t).

Sometimes things can be greatly simplified by wrapping the lib
in a VC6 DLL. In that case all symbols in the .lib are resolved
against the VC6 libraries. You only have to make sure, that
your interface contract does not rely on any incompatible
types.

For example:
// OK; only fundamental types
class X { public:
void foo( const char* p );
private:
int i;
};
CString bar(); // BAD: CString binary layout & mangled
// name different in VC6 & 8

-hg
Nov 30 '05 #3
Hi Holger!
Is it possible to add a VC++ 6 library ot a VC++ 8 application ? if yes
how ? is it possible to link a DLL ? how ?
In general you can say:
It is *only* possible if it only exports C functions (and has not a shared
CRT).


Um, why? Since all references from the VC6 code are resolved
when linking the full image, I don't see how it could work if you
use things like CString internally, but export C functions only.

What's wrong with the shared CRT?


This signatures of some CRT-function has changed... so the linker will
not be able to find it in the VC8 CRT...

In all other cases it is almost impossible to use an older LIB with a
newer VC-Version.


Elaborting on that, the ABI is supposed to be stable.


Do you mean "Win32-API"? The Win32-API does not use the CRT.

I.e. the exact
same source code should be binary compatible. The real problem
is the runtime library.

The MFC, ATL, STL (CRT is safe in most cases) implementations
of different VC versions are not necessarily compatible at the binary
or object level.
If the CRT is safe in most cases, then it cannot be used. (it must be
safe in ALL cases to be used).

So, as long as you don't use any of these (regardless of whether
it's in the interface or the implementation) you have good
chances that it just works.
Yes, but I do not want to check if a CRT-function is safe for VC6-8!
Therefor we have a LIB for every compiler-version!
Also note, that the defaults for some switches, which have an
impact on the ABI, have changed (e.g. /Zc:wchar_t).

Sometimes things can be greatly simplified by wrapping the lib
in a VC6 DLL. In that case all symbols in the .lib are resolved
against the VC6 libraries. You only have to make sure, that
your interface contract does not rely on any incompatible
types.


And you have to be sure that you do not reply on the shared-CRT.
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 30 '05 #4
"Jochen Kalmbach [MVP]" <no********************@holzma.de> wrote
What's wrong with the shared CRT?
This signatures of some CRT-function has changed... so the linker will not
be able to find it in the VC8 CRT...

Ok, I see. I believe that's just one of the things I've mentioned below.
But what is different about the _shared_ CRT here? Wouldn't you
see the same issue for the static CRT?
In all other cases it is almost impossible to use an older LIB with a
newer VC-Version.
Elaborting on that, the ABI is supposed to be stable.


Do you mean "Win32-API"? The Win32-API does not use the CRT.

I'm actually talking about the "Application Binary Interface", which
amongst other things specifies calling conventions, binary layout
of non-POD types and name mangling.
If the CRT is safe in most cases, then it cannot be used. (it must be safe
in ALL cases to be used).
I'm fairly certain you can just give it try. If the linker doesn't complain,
everything's fine. Also, there are far reaching provisions in the C
Standard that effectively guruantee object-level symbol names.
Yes, I know it's not 100% safe.
So, as long as you don't use any of these (regardless of whether
it's in the interface or the implementation) you have good
chances that it just works.
Yes, but I do not want to check if a CRT-function is safe for VC6-8!

Me neither.
Therefor we have a LIB for every compiler-version!

Yes sure, ideally you'd rebuild the .libs with VC8.
Also note, that the defaults for some switches, which have an
impact on the ABI, have changed (e.g. /Zc:wchar_t).

Sometimes things can be greatly simplified by wrapping the lib
in a VC6 DLL. In that case all symbols in the .lib are resolved
against the VC6 libraries. You only have to make sure, that
your interface contract does not rely on any incompatible
types.


And you have to be sure that you do not reply on the shared-CRT.

Now, you lost me again. Since the DLL is fully (statically) linked and
remaining references are resolved against the VC6 CRT, I fail to see
any problem with the _shared_ CRT (oc, you need to respect the normal
rules such as, calling free from the same module as calling malloc etc.)

-hg
Nov 30 '05 #5

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

Similar topics

1
by: mccoyn | last post by:
I'm porting an old project to use .NET. When I try to link in a static library (.lib) that has a single managed class in it. I get the following errors: LINK : error LNK2020: unresolved token...
4
by: Brian Shannon | last post by:
I am playing around with class libraries trying to understand how they work. I created a class library, library.vb. I placed the library.dll into the bin directory and set my reference. If I...
3
by: Rena | last post by:
Hi all, I have created a app. project and a library which will be used by the main project, however i do not know how to get into debug mode inside the library, although break point is set. is...
15
by: Notre Poubelle | last post by:
Hello, I have a large legacy MFC application. As is typical, there is an executable along with several MFC DLLs. One of these DLLs is created by staticly linking in many libraries resulting in...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
0
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. In this user control we have a class...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
16
by: Rainer Queck | last post by:
Hi, What would be the best way to develop a class library? I am planing to develop a couple of classes, needed in our company enviroment. These classe will be later used in several projects. ...
6
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.