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

  • SEARCH
  • Home
  • 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 7513325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:08:58+00:00 2026-05-30T00:08:58+00:00

error LNK2019: unresolved external symbol char * __cdecl BytesToString(unsigned char const *,unsigned int) (?BytesToString@@YAPADPBEI@Z)

  • 0

error LNK2019: unresolved external symbol “char * __cdecl
BytesToString(unsigned char const *,unsigned int)”
(?BytesToString@@YAPADPBEI@Z) referenced in function
_wmain C:\Users\anandada\Documents\Visual Studio 2010\Projects\ByteToString\ByteToString\ByteToString.obj ByteToString

above is the error I am getting. code is shown below. ByteToString is a console Win32 application and Utility is Win32 DLL.

Utility.c

#include "stdafx.h"
#include "Utility.h"
#include "stdlib.h"

char* BytesToString( const unsigned char* PpcbBytes, const unsigned int PuiNoOfBytes)
{
    unsigned char bRetVal = 0;
    unsigned int ctr = 0;
    char* PpszString = NULL;
    int len=0;

    do
    {
        PpszString=(char*)calloc(PuiNoOfBytes*3+1,sizeof(char));
        if(NULL==PpszString)
            break;
        len=5;
    } while(0);
    return PpszString;
}

Utility.h

#ifndef _UTILITY_H
#define _UTILITY_H
__declspec(dllexport) char* BytesToString( const unsigned char* PpcbBytes, const unsigned int PuiNoOfBytes);
#endif

ByteToString.cpp

// ByteToString.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "string.h"
#include "stdlib.h"
#include "..\Utility\Utility.h"

int _tmain(int argc, _TCHAR* argv[])
{
    unsigned char pbArray[5]={0x41,0x42,0x43,0x44,0x45};
    char* pbExpArray=NULL;
    unsigned int Flag=1;
    int len=0;

    pbExpArray=BytesToString(pbArray,5);
    free(pbExpArray);
    Flag=strcmp("41 42 43 44 45 ",pbExpArray);
    len=strlen(pbExpArray);

    return 0;
}

I have set project properties like this:

both ByteToString and Utility project calling conventions are: __cdecl

In ByteToString, Linker->General->Additional Directories: $(OutDir)

(I tried this too Linker->General->Additional Directories:$(SolutionDir)$(Configuration)\ )

In ByteToString, Linker->Input->Additional Dependenicies: Utility.lib

I aslo tried this,

#ifndef _UTILITY_H
#define _UTILITY_H
extern "C"
{
__declspec(dllexport) char* BytesToString( const unsigned char* PpcbBytes, const unsigned int PuiNoOfBytes);
}
#endif

This gives error:

error C2059: syntax error : ‘string’

Update:

  1. While creating project, I had added Utility.cpp. I renamed it to Utility.c, set the project properties and compiled. I got the error shown above.
  2. Then I renamed it back to Utility.cpp and compiled. No error.

Why is this? I want Utility file in .c. What is the correct method to add a .c file into project?

  • 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-05-30T00:08:59+00:00Added an answer on May 30, 2026 at 12:08 am

    You need the header file to differentiate between use in the exporting DLL and the consuming other module (DLL or EXE). The project wizard had generated a preprocessor definition for this purpose. If your exporting DLL is called Utility.dll than this definitions is UTILITY_EXPORTS. Check you projects properties for this.

    In your header file you define something like this

    #ifdef UTILITY_EXPORTS
    #define UTILITY_API __declspec(dllexport)
    #else
    #define UTILITY_API __declspec(dllimport)
    #endif
    
    #ifdef __cplusplus
    extern "C" {
    #endif 
    
    UTILITY_API char* BytesToString( const unsigned char* PpcbBytes, const unsigned int PuiNoOfBytes);
    
    #ifdef __cplusplus
    }
    #endif
    

    This causes the consuming project to use the symbol in the import library, that you have added to the consuming module.

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

Sidebar

Related Questions

Trying to track down a LNK2019 Unresolved External Symbol error on a function that
Linking... Directory.obj : error LNK2019: unresolved external symbol public: void __thiscall indexList<class entry,100>::read(class std::basic_istream<char,struct
I get the following error: Error 1 error LNK2019: unresolved external symbol _ imp
Has anyone seen this before: Error 1 error LNK2019: unresolved external symbol __declspec(dllimport) public:
1>main.obj : error LNK2019: unresolved external symbol public: __thiscall MyList<class Event>::~MyList<class Event>(void) (??1?$MyList@VEvent@@@@QAE@XZ) referenced
Possible Duplicate: What is an undefined reference/unresolved external symbol error and how do I
It doesn't compile in Visual Studio, it says 1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external
Compiling FluidSynth 1.1.1 from source. I have unresolved external symbol with glib, using Visual
As the title suggests, I am having the following linker error: error LNK2019: unresolved
#include<iostream> #includeGlew\glew.h #includefreeGlut\freeglut.h using namespace std; int main(int argc, char* argv[]) { GLint ExtensionCount;

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.