472,784 Members | 1,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 software developers and data experts.

Using a CString-derived class from a DLL file (LNK2019 &Q309801)

Hi NG,

I've copied this from the article Q309801

---- schnipp ---------
You may receive an LNK2019 error message when you build a Visual C++ 2005 or
Visual C++ .NET application that uses a CString-derived class from a DLL
---- schnapp ---------

I've a similar problem by exporting a CArray derived class. In the article
the wrote the solution is to add

template class __declspec(dllimport) CStringT<TCHAR, StrTraitMFC<TCHAR,
ChTraitsCRT<TCHAR >;
template class __declspec(dllimport) CSimpleStringT<TCHAR>;

to your stdafx.h in your exe project.

I've tried to migrate the statement to my class by wrtiting:
// Forward declaration,
// @note The class CArgument is declared in the exe itself
class CArgument;

// TArray is my template derived from CArray
// template <typename _Ty, typename _A = const _Ty&>
// class AFX_EXT_CLASS TArray
// : public CArray<_Ty, _A>
// {
// :
// :

template class __declspec(dllimport) TArray<CArgument, const CArgument&>;
template class __declspec(dllimport) CArray<CArgument, const CArgument&>;

but i get also the LNK2019 error.

Does any one have an idea for this?

Kind regards, Michael Buechel

Jul 3 '06 #1
1 3561
I found a solution:

do not use __declspec(dllexport) for the templates in the dll!

in my example this will done by AFX_EXT_CLASS.
remove the AFX_EXT_CLASS or __declspec(dllexport) and
it will work.

Note: You cannot export another class inheritated by the template

Kind regards, Michael Buechel

Jul 4 '06 #2

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

Similar topics

by: Markus Hämmerli | last post by:
I ' ll tra to convert a Cstring to char* without success. I working in a Unicode enabled environment this is working in Unicode CString source = _T("TestString"); TCHAR *szSource =...
by: Terry chan | last post by:
Hi, How to convert String object to MFC CString? and from CString to String? Thanks! chan
by: Tim Wong | last post by:
All: I am trying to convert a CString value to an unsigned char array. I found some code online that will allow me to compile, but when I try to print out...i get a whole mess. /*Begin Code*/...
by: Gareth | last post by:
I want to do the following to strings: 1) Check if first four characters are "DATA" 2) Get the middle 'word' from the following string "DATA 123 xyz" (the middle word is variable length) -...
by: Hai Ly Hoang [MT00KSTN] | last post by:
CString.FormatMessage and CString.Format has the same parameters and they seems to have to outcome. However, they coexist !. There must be some subtle different between they. Can you tell me the...
by: garrry | last post by:
Here is the situation (in VisualC++6 environment): 1. some number is enterd into a CEdit window by user 2. the application has to obtain that number and do some calculations with it (just...
by: Igor Natachanny | last post by:
Wich way I can to take the BYTE*-pointer to a string of characters that contain into CString-object?
by: Cactus | last post by:
How to convert unsigned char* to CString: I wrote some function: u_char_ =55; u_char_ =66; u_char_ =77; .........=ii...... Convert_to_CS(u_char_);
by: YouPoP | last post by:
For a reason i don't know, if i convert a float to a cstring, it does not convert to an exact value for all values except round numbers or 1/2 numbers; the following code (used to convert and...
by: Carl Forsman | last post by:
how to compare a CString? the following does not seem to work. CString id = PictureEntries.attribute("id").value(); if (id.Compare("2222") == 1){ cout << id << endl; }
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.