|
We have upgraded a big pure MFC project from VC6 to VC7 last week and after little changes everything seems OK except that we have 50 or so LNK2005 error regarding CString which loo like that :
------------------------------------------------------------
DUtils.lib(DUtils.dll) : error LNK2005: "public: __thiscall ATL::CStringT<char,class strtraitmfc<char,class="" atl::chtraitscrt<char=""> > >::CStringT<char,class strtraitmfc<char,class="" atl::chtraitscrt<char=""> > >(class ATL::CStringT<char,class strtraitmfc<char,class="" atl::chtraitscrt<char=""> > > const &)"
-------------------------------------------------------------
DUtils.lib(DUtils.dll) : error LNK2005: "public: __thiscall ATL::CSimpleStringT<char>::operator char const *(void)const " (??B?$CSimpleStringT@D@ATL@@QBEPBDXZ) already defined in DCAnaDisplayInfo.obj
--------------------------------------------------------------
FYI , Dutils.dll is library with generic MFC classes (derived from CEdit, Cstring ...).
Any help would be really appreciated.
Best regards,
Olivier REIX
|
|
|
|
|
Has nobody any idea why I have these link (LNK2005) errors ?
I have been searching a solution for 5 days now and I can not find anything
|
|
|
|
|
Even that I found no < > in your post, the type names seems to imply you are using template classes. Make sure your code gets instantiations of these class templates.
|
|
|
|
|
Mike Nordell wrote:
Even that I found no < > in your post, the type names seems to imply you are using template classes. Make sure your code gets instantiations of these class templates.
You are right, I use templates (mostly CList and CArray) as member variables of my classes or as parameters. Also CString is now a template in MFC 7. The code can be built with no pb on VC6 but I have the erreor on VC7.
I do not understand what you mean here : "Make sure your code gets instantiations of these class templates".
Thanks for your help
|
|
|
|
|
Also CString is now a template in MFC 7.
Oh, I didn't know that. It wouldn't surprise me if this will be a source of many problems like this.
Olivier REIX wrote:
I do not understand what you mean here : "Make sure your code gets instantiations of these class templates".
I mean exactly what I wrote.
However, your problem seems to be the completely opposite. You are from your code trying to export instantiations of the member function
operator char const *(void)const;
from the template class ATL::CSimpleStringT<char>
that is instantiated in at least DCAnaDisplayInfo.obj, but it's also instantiated somewhere else.
This obviously upsets the linker since it can't possibly know which of the two instantiations it should use.
Are you using static CRT? Then that's your problem and your code will crash if you pass your derived string class in and out of your DLL.
If you are using the DLL version of the CRT, at least (I hope) you now know what you should be looking for. If you want a more complete answer, I suggest you post more complete code.
|
|
|
|
|
Thank you for your help. I have trouble understanding what you explain but I think you guide me in the good direction.
For the version of the CRT, I think I use the DLL version but how can I be sure (I was not the one who did the configuration for this software).
Let's show some code which seems to be linked to my problem.
First in the DUtils.dll. We have a file "DUtils.h" which look like this :
(I do not know how to format the code for the forum )
*********************************
// Include file for DUTILS DLL
#pragma once
#pragma message(" --> Including "__FILE__)
// this is done so that classes are exported when building the
// DLL but imported when referencing the DLL
// class defined to be exported should have the CLASS_DUTILS
// inserted in their class definition
#ifdef DUTILS_IMPL
#define CLASS_DUTILS __declspec(dllexport)
#ifdef _DEBUG
#pragma message("Building DUtilsd.dll")
#else
#pragma message("Building DUtils.dll")
#endif
#else
#define CLASS_DUTILS __declspec(dllimport)
#ifdef _DEBUG
#pragma comment(lib, "DUtilsd")
#pragma message("Referencing DUtilsd.dll")
#else
#pragma comment(lib, "DUtils")
#pragma message("Referencing DUtils.dll")
#endif
#endif
************************
This file is included in the "stdafx.h" of the project (exe or dll) that which to use classes defined in DUtils.dll"
In the "StdAfx.h" of DUtils.dll, we have the 2 following lines :
***************************
#define DUTILS_IMPL
#include "dUtils.h"
***************************
And part of the DUtils.dll we have for example a class called DCStringArray, which looks like this (DCStringArray.h) :
***************************
#pragma once
#pragma message(" --> Including "__FILE__)
class CLASS_DUTILS DCStringArray : public CStringArray
{
public:
// construction / destruction ----------------------------------
DCStringArray();
DCStringArray(const DCStringArray& other);
virtual ~DCStringArray();
DCStringArray& operator =(const DCStringArray &other);
void BuildFrom(LPSTR lpBuffer,LPSTR seps) ;
void BuildFromCommaSeparated(CString str);
void BuildFromItemsSeparatedBy(CString sListItem, CString sSeps);
BOOL AddIfNotExists(const CString& s);
BOOL Contains(const CString& s) const;
int ContainsNoCase(const CString& s) const;
void FillWithSeparation(CString &s, const CString& strSeparator) const;
};
***************************
NB : We also have one called DCString derived from CString.
Now in DCData.dll, a DLL which uses DUtils.dll (#include "DUtils.h" in "stdafx.h"), we have for example a class called DCAcquisitionHolder (defined in DCAcquisitionHolder.h") which looks like this (DCStringArray is only used in this constructor) :
******************************
#pragma once
#include "DCStringArray.h" // for channel names
class CLASS_DCDATA DCAcquisitionHolder : public CObject
{
public:
// -----------------------------------------------------------------------
DCAcquisitionHolder();
DCAcquisitionHolder(const DCAcquisitionHolder& other);
DCAcquisitionHolder(const DCStringArray& channelNames);
virtual ~DCAcquisitionHolder();
(...some other functions ...)
};
******************************
And now "DCAcquisitionHolder.cpp" :
**********************************************
DCAcquisitionHolder::DCAcquisitionHolder(const DCStringArray& channelNames)
{
Init();
for (int i=0; i < channelNames.GetSize(); i++)
{
DCChannelHolder* pChannel = new DCChannelHolder(channelNames[i]);
m_channels.Add(pChannel);
}
}
**********************************************
And so when compiling, here is one of the 50 errors that we have :
************************************
************************************
------ Build started: Project: DCData, Configuration: Release Win32 ------
Linking...
DUtils.lib(DUtils.dll) : error LNK2005: "public: __thiscall ATL::CStringT<char,class strtraitmfc<char,class=""
atl::chtraitscrt<char=""> > >::CStringT<char,class strtraitmfc<char,class="" atl::chtraitscrt<char=""> > >(class
ATL::CStringT<char,class strtraitmfc<char,class="" atl::chtraitscrt<char=""> > > const &)"
(??0?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@QAE@ABV01@@Z) already defined in
DCAcquisitionHolder.obj
Can you see more what happens now ?
|
|
|
|
|
I can not believe I am the only one who gets these errors. Its been 3 weeks now and I still can not use VC7.
Heeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeelp
|
|
|
|
|
Can someone direct me to a good place for information about DeskBands? I have looked at all of the articles on this site, and they don't give me the information I need. There are a few things I am trying to figure out and any help would be greatly appreciated.
1) I'm not sure how to trigger a call to GetBandInfo or if there is a way to call a SetBandInfo method. I need this to happen because my window min, max etc change but the only way to get the deskband to notice is to resize the taskbar manually.
2) I need to know how to tell Explorer to release the deskband because it never does.
3) I need to know if there is a way to start a deskband programatically ( ie without using the mouse to select it )
Thanks
|
|
|
|
|
Hello, Did you ever find a way to programatically start/open/close/reposition, etc the deskband? I also need to do so...
Thanks, Demián.
|
|
|
|
|
Did you ever get any answers?
|
|
|
|
|
I wanna use WINDOWINFO and GetWindowInfo in my applican but the compiler can not identify them.Any idea?
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
That function requires windows98 or later, ans WindowsNT4.0 with the SP3.
The compiler will not let you see this function because you probably have this definition in your "stadafx.h" file:
#define WINVER 0x0400
That basically says use version 4.0 and below API functions. You will need to change this definition to this:
#define WINVER 0x0500
The only drawback to doing this is that you will have to check the version of the OS that your app is running on before you call the version 5.0 API functions if you want your app to run on Windows 95.
Good Luck.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanksssssss,I change it and it works now.
How do you know these things kilo?
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
I worked for a company that had to analyze every aspect of the Windows API in order for their product to work properly. Needless to say I learned things that you wouldn't believe about the Windows API, and I learned how to read the documentation very well in order to find the details that I needed.
I would like to add one thing, I think that the MSDN documentation is excellent. So many times I see people complain that Microsoft's documentation sucks, and they complain that this feature is not documented. I find that if I spend a few extra minutes reading all of the remarks and information for each function you can usually solve your problems.
Anyway, the way that I knew how to solve this problem is that at the bottom of the docuementation for each function in the SDK docuemntation you will see this:
Requirements
Windows NT/2000 or later: Requires Windows NT 4.0 SP3 or later.
Windows 95/98/Me: Requires Windows 98 or later.
Header: Declared in Winuser.h; include Windows.h.
This will help you decide if you can use it or not, and which version headers that you need to use in order
to get the compiler to give you access to the functions.
If you have any more questions ask away.
Good Luck.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
If you have windows.h included and User32.lib it should work... and what I know these are already included?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C# and C++!
|
|
|
|
|
Thanks Rickard,the problem was what kilo said.
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
Is this the correct way to set a CView's background?
CView::OnEraseBkgnd(pDC);
CRect r;
CBrush b;
b.CreateSolidBrush(RGB(200,200,200));
GetClientRect(&r);
pDC->FillRect(r,&b);
return true;
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I would say yes, except that you probably do not want to send a call to the base class since you are redrawing over the entire screen anyway. You may end up with a flicker if white, then your gray color that you define.
Are there any problems that you are seeing?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
kilowatt wrote:
I would say yes, except that you probably do not want to send a call to the base class since you are redrawing over the entire screen anyway. You may end up with a flicker if white, then your gray color that you define.
Are there any problems that you are seeing?
Thanks Kilo. I am not facing any probs. The reason I had to do this was that I assumed that the background of the view would be RGB(255,255,255) but it was not that
So I thought what the heck and made the background and my image background my own slightly grayish color.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
but please be warned..
it is not not not nice at all to set a window's background not in the color the user defined in his / hers settings..
e.g. i have got a slight grayish background for all windows (otherwise my eyes burnt after staring 8 hours++ at the monitor)
<rant>
and i hate all programmer and want to rip out their nuts *you can add any hate - fantasy you like, e.g. slipknot lyrics*, who override my settings with stupid settings (e.g. white)..
like lotus notes does.. (at least the client i have to use)
if you don't want to use windows settings use another platform...
and if you are a smart programmer you would use a transparent bitmap, altough it could look totally crappy if the background could be too dark...
but.. you are a smart programmer, aren't you? so you are paid to find a solution..
maybe it is not a too good idea to override windows settings.. not?
bernhard
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Well in this case I am the single end-user. This is a test program where I am trying to decode an unknown image format. I like grays. I want a gray background since I am going to be running this program close to 600 times today and tomorrow before I manage to crack the image format
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Should work. You can use CDC::FillSolidRect which could be marginally faster - it uses a trick with ::ExtTextOut and doesn't create brush.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Hi,
For some bizzare reason I can't run any of my GDI+ projects in Debug mode. Keep getting compile-errors when i try to dynamically instantiate a Bitmap object. Also the IDE doesn't list the members of GDI+ objects as I code.
Anyone any clues?
Cheers
Richard
|
|
|
|
|
You don't mention what compile-errors you're getting.
If you're getting Error C2660: 'new' : function does not take three parameters, then an MFC generated define, DEBUG_NEW, defines a "new" operator that takes three parameters. It only applies to debug builds. You can undefine DEBUG_NEW so that debug builds also work or use the scope resolution operator ( :: ) before new to use the default C++ version, like this:
bitmap = ::new bitmap
|
|
|
|
|
Hi,
I have been looking at the GDI+ BitmapData Class for direct pixel data access. In MSDN it mentions you can get "bottom up" bitmap as well as "top down", when do you get bottom-up, is this present in any particular standards?
Cheers
Rich
|
|
|
|