473,386 Members | 1,962 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.

How do you resolve "standard" DLLs?

Help!

I recently upgraded my VS V6 to VS 2005 and was unable to build projects
that were perfectly ok under VS V6. Where VS 2005 fails was in the linker
resolving external DLLs, which are Open Source DLLs like "log4Cxx" and
"Xerces C++" DLL libraries.

VS 2005 converted my projects without any problem. Even the proper lib
includes and lib path were captured. But its linker just unable to resolve
the C++ function references.

I am aware of the mismatched calling convention between C-style and C++
style DLL. I thought I solve that problem when I created working project
under VC 6.0.

Do anyone have a very simple project that show how to configure the VS 2005
C++
project to link to these C++ DLLs?

Is there a simple way to use C++ DLLs, which is "not managed code" under
Microsoft's point of view?

Please help, I am desparate and may have to return the VS 2005 and keep
using the VS V6, which is ancient, I know, but what choice do I have if I
cannot call simple DLLs like "log4Cxx" functions?
JML

Feb 23 '06 #1
7 1910
Help!

I recently upgraded my VS V6 to VS 2005 and was unable to build projects
that were perfectly ok under VS V6. Where VS 2005 fails was in the linker
resolving external DLLs, which are Open Source DLLs like "log4Cxx" and
"Xerces C++" DLL libraries.

VS 2005 converted my projects without any problem. Even the proper lib
includes and lib path were captured. But its linker just unable to resolve
the C++ function references.

I am aware of the mismatched calling convention between C-style and C++
style DLL. I thought I solve that problem when I created working project
under VC 6.0.

Do anyone have a very simple project that show how to configure the VS 2005
C++
project to link to these C++ DLLs?

Is there a simple way to use C++ DLLs, which is "not managed code" under
Microsoft's point of view?

Please help, I am desparate and may have to return the VS 2005 and keep
using the VS V6, which is ancient, I know, but what choice do I have if I
cannot call simple DLLs like "log4Cxx" functions?


Hi,

It would be helpful if you supplied the exact linker error messages.

Is it possible these dlls you speak of export classes that you use in your
app?
if so then you are out of luck. C++ 6.0 produces different code from c++8.0

that is the reason why C style interfaces are the only viable option for
building dlls that have to be used by different compilers.

However, if these dlls are open source you can download the sources, build
them using VC2005 and then link your application against those dlls. that way
the dlls are built with the same compiler version as your application.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Feb 23 '06 #2
Jeff Lynn wrote:
Help!

I recently upgraded my VS V6 to VS 2005 and was unable to build
projects that were perfectly ok under VS V6. Where VS 2005 fails was
in the linker resolving external DLLs, which are Open Source DLLs
like "log4Cxx" and "Xerces C++" DLL libraries.

VS 2005 converted my projects without any problem. Even the proper
lib includes and lib path were captured. But its linker just unable
to resolve the C++ function references.

I am aware of the mismatched calling convention between C-style and
C++ style DLL. I thought I solve that problem when I created working
project under VC 6.0.

Do anyone have a very simple project that show how to configure the
VS 2005 C++
project to link to these C++ DLLs?

Is there a simple way to use C++ DLLs, which is "not managed code"
under Microsoft's point of view?

Please help, I am desparate and may have to return the VS 2005 and
keep using the VS V6, which is ancient, I know, but what choice do I
have if I cannot call simple DLLs like "log4Cxx" functions?


Code produced by VC6 and VC8 is laregly compatible at the binary level
(assuming the same source code is compiled), but there are a couple of
exceptions that may be tripping you up:

1. MFC, ATL or STL classes used in the interface won't work between VC6 and
VC8. I seriously doubt that any of those are used in log4cxx or Xerces C++.

2. The name decoration for template functions changed. VC6 didn't use the
actual template parameters in building the decorated name but rather used
only the argument types. This could result in a template function and a
non-template function with identical parameters having the same decorated
name. More likely in your case, the difference in handling wchar_t is to
blame. Under VC6, wchar_t is a typedef for unsigned short, while under VC8
it's a distinct type. This difference is reflected in differences in the
decorated names of any function that uses wchar_t in it's interface. You
*might* be able to use the VC6-compiled libraries if you compile your VC8
code with /Zc:forScope-, which disables the built-in wchar_t and uses the
typedef instead.

As Bruno already replied, the best solution is to get the source code to
those open source libraries and rebuild it using VC8.

-cd
Feb 23 '06 #3
Thank you for both Bruno's and Carl's response. I will surely tried the /Zc
switch later on.

If this switch doesn't work, then surely Microsoft had made a unwise
decision because Microsoft cannot expect every avaiable library need to be
recompiled under VS 2005. Even in my case, I wouldn't want to recompile the
Open Source just because I want to use VS 2005. The choice is clear, if the
/Zc doesn't work, I will return the VS 2005 and stick with my VS V6.

I aware of the legacy baggage issue, but not having the backward
compaitility issue is a bit mistake.

I will report whether the suggested /Zc work for me or not. Thanks again
for the quick responses!

jml
Feb 23 '06 #4
Yes, I specified the /Zc:wchar_t- option under Properties\Configuration
Properties\C/C++\Language\Treat wchar_t as Built-in Type and it works.

Thanks you fory your great support.

jml
Feb 23 '06 #5
Now that I am able to link to Open Source "log4Cxx" and "Xerces C++" DLLs, I
now run into DLL created by me. I rebuild the DLL under VS C++ 2005, yet
when I build a test program to use a static method that return CString, I got
the following error during linking at the function "CppUtility::AsISODate()"
to return current date in "YYYY-MM-DD" fashion, just a wrapper to the
"formatted string" function:

Linking...
Test2.obj : error LNK2019: unresolved external symbol "__declspec(dllimport)
public: static class ATL::CStringT<unsigned short,class
StrTraitMFC_DLL<unsigned short,class ATL::ChTraitsCRT<unsigned short> > >
__cdecl CppUtility::AsISODate(void)"
(__imp_?AsISODate@CppUtility@@SA?AV?$CStringT@GV?$ StrTraitMFC_DLL@GV?$ChTraitsCRT@G@ATL@@@@@ATL@@XZ) referenced in function _wmain
X:\MLArch\Test2\Debug\Test2.exe : fatal error LNK1120: 1 unresolved externals

I experimented with specifying the ATL option to use (in both CppUtility DLL
and test2) the following options:
- do not use ATL
- use static link ATL
- use dynamic link ATL

get the same error.

Any suggestion here?

jml
Feb 23 '06 #6
Jeff Lynn wrote:
Now that I am able to link to Open Source "log4Cxx" and "Xerces C++"
DLLs, I
now run into DLL created by me. I rebuild the DLL under VS C++ 2005,
yet
when I build a test program to use a static method that return
CString, I got
the following error during linking at the function
"CppUtility::AsISODate()"
to return current date in "YYYY-MM-DD" fashion, just a wrapper to the
"formatted string" function:

Linking...
Test2.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport)
public: static class ATL::CStringT<unsigned short,class
StrTraitMFC_DLL<unsigned short,class ATL::ChTraitsCRT<unsigned short>
__cdecl CppUtility::AsISODate(void)"

(__imp_?AsISODate@CppUtility@@SA?AV?$CStringT@GV?$ StrTraitMFC_DLL@GV?$ChTraitsCRT@G@ATL@@@@@ATL@@XZ)
referenced in function _wmain X:\MLArch\Test2\Debug\Test2.exe : fatal
error LNK1120: 1 unresolved externals

I experimented with specifying the ATL option to use (in both
CppUtility DLL
and test2) the following options:
- do not use ATL
- use static link ATL
- use dynamic link ATL

get the same error.

Any suggestion here?


Unfortunately, that looks like the ATL library was built with /Zc:wchar_t
(not -), so you're getting undefined symbols when trying to use /Zc:wchar_t-
:(

In VS2003 the MFC dlls were built with some special secret sauce to make it
work both ways, I wonder if they didn't do that for 2005...

It looks like what you really want is #pragma conform(wchar_t, ...).
Unfortunately, it looks like #pragma conform can only toggle the for-loop
scope option and not the wchar_t option.

I suspect that in the end your only option to use both ATL/MFC and the
open-source libraries in the same project is to re-build those open source
libraries with VC8.

While it's inconvenient, this is nothing unexpected when moving to a new
compiler. VC++ has done a much better job over the years of maintaining
backwards compatibility than any other C++ compiler out there that I know
of. In this case though, you may have no choice but to recompile.

-cd
Feb 24 '06 #7
If this switch doesn't work, then surely Microsoft had made a unwise
decision because Microsoft cannot expect every avaiable library need to be
recompiled under VS 2005. Even in my case, I wouldn't want to recompile the
Open Source just because I want to use VS 2005. The choice is clear, if the
/Zc doesn't work, I will return the VS 2005 and stick with my VS V6.

I aware of the legacy baggage issue, but not having the backward
compaitility issue is a bit mistake.


to be honest, Microsoft has a much better track record for binary
compatibility than others. probably because their customers depend on it.
msvc is much more backwards compatible than gcc. try using class libraries
compiled with gcc 2.95 in an app that is compiled with gcc 4.0.3.

same story for linux versions.

the whole point of open source is that it gives you the freedom to recompile
and change things whenever needed. most open source project leaders
discourage binary compatibility since this would make things easier for
closed source projects. one could argue that recompiling your open source
libraries is the only 'politically' correct solution.

this is the reason for example that the nvidia display driver installer on
linux compiles wrapper functions for their core driver on the fly during
installation. otherwise they would have to distribute dozens of driver
packages, depending on ditribution and exact kernel versions.

that being said I am a believer in binary compatibility, but the problem is
that there is no definition of what a compiled C++ should look like (this is
one of the reasons COM was invented actually). that is the reason why I
export only C style interfaces in dlls.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Feb 24 '06 #8

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

Similar topics

2
by: Kalle Anke | last post by:
I'm confused of how I should document my code, I've always liked being able to document my code directly in my source file and then to use some tool to extract the documentation to some other...
38
by: Jack Klein | last post by:
Many people, including me, like having hard copy books at hand, along with electronic editions. When I first heard of this book several months ago, I pre-ordered a copy. It arrived from...
4
by: Luke Wu | last post by:
I am just wondering what the following terms usually mean: 1) "Standard C" 2) "K&R C" 3) "ANSI C" I am pretty sure "ANSI C" usually refers to the C89 standard, but what
5
by: VB Programmer | last post by:
If you want to store custom tables in ASP.NET 2.0, such as Products, Companies, Shopping Carts, etc... where is the standard place to put the tables? I want to link it to the user/membership...
5
by: funkyj | last post by:
I love pexpect because it means I may never have to use expect again (I don't do any heavy expect lifting -- I just need simple tty control)! As a python advocate I find it embarassing how...
6
by: Steph. | last post by:
Hi ! How can I play "standard system sounds" in C# ? ( "standard system sounds" = The kind of sound you hear when you use MessageBox.Show() ) Thanks ! steph.
4
by: Daniel Greene | last post by:
Dear Group, I haven't been on this newsgroup in years. Hello again to village elders Lars Eighner, Alan Flavelle, and Jukka Korpela! :-) What brings me back? I was using the W3C QA to validate...
2
by: Royt | last post by:
Have a look at this site: http://blogs.msdn.com/vcblog/archive/2007/11/05/iso-c-standard-update.aspx C is a mature language used everywhere, it doesn't belong to any commercial company, should...
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: 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: 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...

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.