473,320 Members | 1,732 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,320 software developers and data experts.

Using unmanaged C++ in C++.NET

Hi,

I am novice in C++ and am more of a C# guy. I have a third party C++
code which I want to create and use as a managed assembly. I have
created a .NET win32 application and have copied this C++ code here and
made changes according to my needs. However I am always getting this
linker error when compiling. I looked a lot n the web and followed all
instructions so far of adding msvcrt.lib, glu32.lib, opengl32.lib to
the project dependencies. The error description is below. Any help is
highly appreciated.

Linking...
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liEndDocument(void *,struct LanguageIDListT *,long *)"
(?liEndDocument@@$$FYGXPAXPAULanguageIDListT@@PAJ@ Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liAnalyzeDocumentText(void *,char *,unsigned int,long *)"
(?liAnalyzeDocumentText@@$$FYGXPAXPADIPAJ@Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liStartDocument(void *,long *)"
(?liStartDocument@@$$FYGXPAXPAJ@Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liSetCharacterSetFlags(void *,enum BooleanT,enum
BooleanT,enum BooleanT,enum BooleanT,enum BooleanT,long *)"
(?liSetCharacterSetFlags@@$$FYGXPAXW4BooleanT@@111 1PAJ@Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liOpenLanguage(void *,char *,char *,int *,long *)"
(?liOpenLanguage@@$$FYGXPAXPAD1PAHPAJ@Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liDeleteLanguageIdentifier(void *,long *)"
(?liDeleteLanguageIdentifier@@$$FYGXPAXPAJ@Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void *
__stdcall liCreateLanguageIdentifier(unsigned long,unsigned long,long
*)" (?liCreateLanguageIdentifier@@$$FYGPAXKKPAJ@Z)
D:\Praveen\Work\LanguageIdentifiertest\TestProj\Te stProjDll\Debug\TestProjDll.dll
: fatal error LNK1120: 7 unresolved externals

I am using the following code in my header file:

// TestProjDll.h

#pragma once

using namespace System;
#include "stdlib.h"

#include "string.h"
#include "stdio.h"

namespace TestProjDll
{

#ifndef __LANGUAGE_ID_
#define __LANGUAGE_ID_

#include <stdlib.h>

//#define __LEXTEK_MACINTOSH__
//#define __LEXTEK_SOLARIS__
//#define __LEXTEK_LINUX32__
//#define __LEXTEK_BEOS__
#define __LEXTEK_WINDOWS_DLL__
#define __LEXTEK_MICROSOFT__
//#define __LEXTEK_BORLAND__

#ifdef __LEXTEK_MACINTOSH__
# define WinStuff
# define FuncType
#endif

#ifdef __LEXTEK_BORLAND__
# ifdef __LEXTEK_WINDOWS_DLL__
# define FuncType __export __stdcall
# endif
# define WinStuff
#endif

#ifdef __LEXTEK_MICROSOFT__
# define FuncType __stdcall
# ifdef __LEXTEK_WINDOWS_DLL__
# define WinStuff __declspec(dllexport)
# endif
#endif

#ifdef __LEXTEK_SOLARIS__
# define FuncType
# define WinStuff
#endif

#ifdef __LEXTEK_LINUX32__
# define FuncType
# define WinStuff
#endif
#ifdef __LEXTEK_BEOS__
# define FuncType
# define WinStuff
#endif

typedef void * LextekLanguageIdentiferT;
typedef unsigned long ULongT;
typedef long int StatusCodeT;

#ifndef __BOOLEANT__
#define __BOOLEANT__
typedef enum {
BooleanTrue = 1,
BooleanFalse = 0
} BooleanT;
#endif
#ifndef __LEXTEK_STATUS_CODE__
#define __LEXTEK_STATUS_CODE__
typedef long StatusCodeT;
#endif


#ifndef __LEXTEK_STATUS_CODES__
#define __LEXTEK_STATUS_CODES__

// Note, the error code values have been brought in line with the
error
// code values from other Lextek products. This is the reason why the
// values are not sequential.

const long eNoError = 0; // NoError;
const long eNoMemory = -1; // Not enough memory
const long eReading = -3; // Error reading from file
const long eWriting = -4; // Error writing to file
const long eSeeking = -5; // We were not able to seek
where we wanted
const long eFileNotFound = -6; // Not able to find the file
const long eOpeningFile = -11;// Can't open the file specified
const long eGeneralError = -37; // Beats me what the error is
const long eLibraryTimedOut = -39; // This library has timed out.
Contact Support (su*****@lextek.com)
const long eInvalidPasscode = -42; // An invalid license passcode
was entered. Recheck passcode or contact Lextek International
(http://www.lextek.com) for a valid passcode.

#endif
#define UNICODE_FLAG_BIG_ENDIAN (0x00000001)
#define UNICODE_FLAG_LITTLE_ENDIAN (0x00000002)
#define UNICODE_FLAG_UTF8 (0x00000004)
#define UNICODE_FLAG_UTF7 (0x00000008) // Not supported.
#define UNICODE_FLAG_UTF75 (0x00000010) // Not supported.

struct LanguageIdentificationT {
char LanguageIDString[80];
int LanguageIDNum;
unsigned int UnicodeFlags;
float Weight;
};

struct LanguageIDListT {
BooleanT LanguageFound;
LanguageIdentificationT Language[4];
int LanguageIDCount;
};

WinStuff LextekLanguageIdentiferT FuncType
liCreateLanguageIdentifier(ULongT Passcode1, ULongT Passcode2,
StatusCodeT *Status);
WinStuff void FuncType
liDeleteLanguageIdentifier(LextekLanguageIdentifer T LanguageIdentifer,
StatusCodeT *Status);
WinStuff void FuncType liSetCharacterSetFlags(LextekLanguageIdentiferT
LanguageIdentifer, BooleanT TestUnicodeBigEndianFlag, BooleanT
TestUnicodeLittleEndianFlag, BooleanT TestUTF8Flag, BooleanT
Check8BitCharSets, BooleanT CheckMultiByteCharSets, StatusCodeT
*Status);

WinStuff void FuncType liOpenLanguage(LextekLanguageIdentiferT
LanguageIdentifer, char *FileName, char *LangIDString, int *LangIDNum,
StatusCodeT *Status);
WinStuff void FuncType liCloseLanguage(LextekLanguageIdentiferT
LanguageIdentifer, char *LanguageName, int LangIDNum, StatusCodeT
*Status);

WinStuff void FuncType liStartDocument(LextekLanguageIdentiferT
LanguageIdentifer, StatusCodeT *Status);
//WinStuff void FuncType
liAnalyzeDocumentText(LextekLanguageIdentiferT LanguageIdentifer, char
*Text, size_t NumCharacters, size_t CharacterSize, StatusCodeT
*Status);
WinStuff void FuncType liAnalyzeDocumentText(LextekLanguageIdentiferT
LanguageIdentifer, char *Text, size_t NumBytes, StatusCodeT *Status);
WinStuff void FuncType liEndDocument(LextekLanguageIdentiferT
LanguageIdentifer, LanguageIDListT* IDList, StatusCodeT *Status);
#endif

public __gc class Class1
{
// TODO: Add your methods for this class here.
int identLG(char *SampleText)
{
StatusCodeT Status = eNoError;
LextekLanguageIdentiferT LanguageIdentifier = NULL;
LanguageIDListT LanguageIDList;
char LanguageIDString[80];
int LanguageIDNum;

LanguageIdentifier = liCreateLanguageIdentifier(0x7F8BC654,
0x54A43ADD, &Status);
if(LanguageIdentifier == NULL) {
return -1;
}

if(Status < 0) {
liDeleteLanguageIdentifier(LanguageIdentifier, &Status);
return -1;
}

liOpenLanguage(LanguageIdentifier,
"language_modules\\english_8bit.lid", LanguageIDString, &LanguageIDNum,
&Status);
liOpenLanguage(LanguageIdentifier,
"language_modules\\french_8bit.lid", LanguageIDString, &LanguageIDNum,
&Status);

liSetCharacterSetFlags(LanguageIdentifier,
BooleanFalse, // Test For Unicode Big Endian Text Flag
BooleanFalse, // Test For Unicode Little Endian Text Flag
BooleanFalse, // Test For Unicode UTF-8 Text Flag
BooleanTrue, // Test 8 Bit Character Sets.
BooleanFalse, // Test Multibyte Character Sets.
&Status);

liStartDocument(LanguageIdentifier, &Status);
if(Status < 0) {
liDeleteLanguageIdentifier(LanguageIdentifier, &Status);
return -1;
}

liAnalyzeDocumentText(LanguageIdentifier, (char *) SampleText,
strlen(SampleText), &Status);
if(Status < 0) {
liDeleteLanguageIdentifier(LanguageIdentifier, &Status);
return -1;
}

liEndDocument(LanguageIdentifier, &LanguageIDList, &Status);
if(Status < 0) {
liDeleteLanguageIdentifier(LanguageIdentifier, &Status);
return -1;
}
//return LanguageIDNum;
return 1;
}
};

}
Thanks
Praveen Ojha

Nov 17 '05 #1
2 1495
pr**********@rediffmail.com wrote:
Hi,

I am novice in C++ and am more of a C# guy. I have a third party C++
code which I want to create and use as a managed assembly. I have
created a .NET win32 application and have copied this C++ code here
and
made changes according to my needs. However I am always getting this
linker error when compiling. I looked a lot n the web and followed all
instructions so far of adding msvcrt.lib, glu32.lib, opengl32.lib to
the project dependencies. The error description is below. Any help is
highly appreciated.

Linking...
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liEndDocument(void *,struct LanguageIDListT *,long *)"
(?liEndDocument@@$$FYGXPAXPAULanguageIDListT@@PAJ@ Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liAnalyzeDocumentText(void *,char *,unsigned int,long *)"
(?liAnalyzeDocumentText@@$$FYGXPAXPADIPAJ@Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liStartDocument(void *,long *)"
(?liStartDocument@@$$FYGXPAXPAJ@Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liSetCharacterSetFlags(void *,enum BooleanT,enum
BooleanT,enum BooleanT,enum BooleanT,enum BooleanT,long *)"
(?liSetCharacterSetFlags@@$$FYGXPAXW4BooleanT@@111 1PAJ@Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liOpenLanguage(void *,char *,char *,int *,long *)"
(?liOpenLanguage@@$$FYGXPAXPAD1PAHPAJ@Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void
__stdcall liDeleteLanguageIdentifier(void *,long *)"
(?liDeleteLanguageIdentifier@@$$FYGXPAXPAJ@Z)
TestProjDll.obj : error LNK2001: unresolved external symbol "void *
__stdcall liCreateLanguageIdentifier(unsigned long,unsigned long,long
*)" (?liCreateLanguageIdentifier@@$$FYGPAXKKPAJ@Z)
D:\Praveen\Work\LanguageIdentifiertest\TestProj\Te stProjDll\Debug\TestProjDll.dll
fatal error LNK1120: 7 unresolved externals


You miss the source code file (or library) that defines the functions
liEndDocument, liAnalyzeDocument, etc... Isnt't that part of the Latex
library you seems to use?

Arnaud
MVP - VC
Nov 17 '05 #2
Hi,

Thanx for your response. It worked for me. I had to addd a reference to
the lib file of the external functionas and was not able to locate
where in project properties I could do that. Have got it resolved now.
Thanks for your help.

-Praveen Ojha

Nov 17 '05 #3

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

Similar topics

16
by: Cybertof | last post by:
Hi ! I'm wondering about the use of the 'using' statement. In a procedure, should i declare all instance variables in a using clause ? In the below code, what would happen if MyFont & MyFont2...
47
by: Bonj | last post by:
I downloaded the gzlib library from zlib in order to do compression. (http://www.gzip.org/zlib) The prototype of the compression function seems to be int compress (Bytef *dest, uLongf *destLen,...
8
by: Mas L via DotNetMonster.com | last post by:
Hi, I have a c++ source code which I can compile to be a DLL (in VS.NET 2003). And I need to use it in a C# program. After I compiled/build the C++ code to a DLL, I add it as a Reference in my...
7
by: Ritu | last post by:
Hi All, Can any body please tell me how i can write a device driver using CSharp. Thanks, Ritu
3
by: mirek | last post by:
Hi, I've got problem building managed class library to wrap unmanaged code. I created managed class library using standard patten: #include "../Unmanaged/Class1.h" //Class1 unmanaged ...
5
by: Andrew | last post by:
I want to use a managed c++ class from an unmanaged class. Here is my code: // *** Unmanaged Code // .h file class UnmanagedClass { public: // Other stuff here
1
by: RaKKeR | last post by:
Hi, I'm trying to wrap my unmanaged c++ code into a managed c++ wrapper. The problem is VC .NET doesn't seem to find the namespaces defined in my unmanaged code. Let's say I have a file...
8
by: Ravneet | last post by:
I am trying to do some calls to unmanaged DLL that I have written. I am doing it in the Session_Start of my Global.asax.cs. The first time I call a function in my DLL it returns correct string...
5
by: Michael D. Reed | last post by:
I have legacy DLL code written in C++ that is essentially C code, an implementation of a set of formulas used in our industry. There are no DB or GUI interfaces, just exposed methods. I would...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: 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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.