473,288 Members | 1,750 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,288 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 1904
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.