Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7833901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:57:51+00:00 2026-06-02T12:57:51+00:00

I am having linking error while compiling my C++ project Solution in VS 2005.

  • 0

I am having linking error while compiling my C++ project Solution in VS 2005. Following is the scenario.

I have a solutions lets say MySolution within which there are 2 projects named

MyTestLib is a Static Library type project with Character Set Use Multi-Byte Character Set and with no CLR support

and

MyTestApp is a .exe app using the above lib with Character Set Use Unicode Character Set and with CLR support

in MyTestLib there are two overloaded functions with following definitions

int Class1::test1(int a)
{
    return a+4; 
}

bool Class1::test1(LPCTSTR param)
{
    return true;
}

MyTestApp is calling them from its code like

Class1 objcl1;
int a = objcl1.test1(12); //Works fine

Class1 objcl2;
string abc = "adsad";
bool t = objcl2.test1(abc.c_str()); //Error

calling the test1(LPCTSTR) version gives error

Error 1 error C2664: 'int TestLib::Class1::test1(int)' : cannot convert parameter 1 from 'const char *' to 'int'

if I change the statement as bool t = objcl2.test1((LPCTSTR)abc.c_str()); //Now linking Error
Then I get

Error 2 error LNK2001: unresolved external symbol "public: bool __thiscall TestLib::Class1::test1(wchar_t const *)" (?test1@Class1@TestLib@@$$FQAE_NPB_W@Z) TestProject.obj

but if I change the project MyTestApp Character Set to Use Multi-Byte Character Set then all the errors are resolved. But I can’t change the project Character Set, as there are other dependencies.

Is there any work arround?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T12:57:52+00:00Added an answer on June 2, 2026 at 12:57 pm

    The problem is that when you build MyTestLib this signature:

    bool Class1::test1(LPCTSTR param);
    

    Becomes

    bool Class1::test1(const char * param);
    

    Because LPCTSTR is a macro that is set depending on the “Character Set” configuration in place when the build occurs.

    Now, when you build MyTestApp with the “Character Set” configured for UNICODE, it sees that function signature (from a header file, I assume) as:

    bool Class1::test1(wchar_t const * param);
    

    So the linker has no hope of linking that function to what’s actually in the library.

    The workaround is to simply not use LPTCSTR as the type for the function – the type of that parameter in the implemented function will always be const char*, so just say so in the function declaration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

having trouble getting my directx going I get the following error 1>Linking... 1>main.obj :
I'm having a link error under cmake that I don't have when compiling on
I have been working for a while on a project with the following components:
i am having a very strange problem while linking a webcam i xperience following
I'm having some trouble compiling/linking a set of classes, several of them dealing with
I am having a strange linking error. I followed instructions presented here to avoid
I'm having a problem linking a C++ project in VS2008 when using the /clr
I am having trouble linking to a secondary class in my project - I
Having trouble using libstatgrab -- I receive the following error at compile time: libstatgrabTest.cpp:16:
I'm having quite a bit of trouble linking a test project of FLTK I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.