Click here to Skip to main content
15,904,500 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Using a DLL containing MFC functions in a Managed C++ app (Help please) Pin
led mike4-Jun-09 7:30
led mike4-Jun-09 7:30 
GeneralRe: Using a DLL containing MFC functions in a Managed C++ app (Help please) Pin
James19764-Jun-09 5:01
James19764-Jun-09 5:01 
GeneralRe: Using a DLL containing MFC functions in a Managed C++ app (Help please) Pin
led mike4-Jun-09 5:17
led mike4-Jun-09 5:17 
GeneralRe: Using a DLL containing MFC functions in a Managed C++ app (Help please) Pin
James19764-Jun-09 5:21
James19764-Jun-09 5:21 
QuestionDRMInitEnvironment function fails............... :( Pin
deadlyabbas1-Jun-09 21:31
deadlyabbas1-Jun-09 21:31 
QuestionHow to return a multidimensional array with a pointer function in Visual C++? Pin
emira671-Jun-09 4:40
emira671-Jun-09 4:40 
QuestionReturning a multidimensional array from pointer function in Visual C++ Pin
emira671-Jun-09 4:00
emira671-Jun-09 4:00 
QuestionLNK2005 Redefinition Error on using CLI --already defined LNK2005 error Pin
jobin00700730-May-09 21:15
jobin00700730-May-09 21:15 
I have a native-C++header Unmanaged.h and cpp file Unmanaged.cpp that I need to use with C#. So I am using C++ Interop to use the native files in a managed C++.NET project(CLI) and then reusing the C++.Net project in C#. The name of my managed C++ file is Managed.cpp


I am geting about 40 of the below error(similar error) for each function or variable or object I use in the header file.
error LNK2005: "class CHardwareDelegate11 * pDeckLinkInput1" (?pDelegate11@@3PEAVpDeckLinkInput1@@EA) already defined in Project.obj

Here's how my files look like--

***************Unmanaged.h*********I am not including the whole code.**********

#pragma unmanaged
#pragma once //This should work to make it defined only once

#ifndef BLACKMAGIC_H
#define BLACKMAGIC_H //This should also work to make it defined only once

#include "DeckLinkAPI.h" //External file
#include <vector>
#include <fstream>


IDeckLinkInput* pDeckLinkInput1 =NULL; /********************* These variables also generate redefined error***/
IDeckLinkOutput* pDeckLinkOutput1=NULL ; /********************* These variables also generate redefined error***/

class CHardwareDelegate1 : public IDeckLinkVideoOutputCallback, public IDeckLinkInputCallback
{
//variables
//Functions

}
class Data{
int frametoCapture[40];

}
//Class Objects declared here. /********************* These class objects also generate redefined error***/
//Variables Declared here /********************* These variables also generate redefined error***/
#endif

***************Unmanaged.cpp*********I am not including the whole code.**********

#pragma once
#pragma unmanaged
#ifndef Unmanaged_CPP
#define Unmanaged_CPP

//#include "stdafx.h" //Uncommenting commenting makes no difference.
#include "Unmanaged.h"
#include "Unmanaged.h" //Including Unmanaged.h twice gets no error from the compiler. Only including it in the C++.NET file creates error
#include <signal.h>
#include <boost thread.hpp="">
using namespace std;
#pragma unmanaged

static int SettopBoxCount;
Data Box[12];
int Data::frametoCapture[]={1,4,6,10,14,17,20,22,25,27,31,34,6+30,30+10,30+14,30+17,20+30,22+30,25+30,27+30,1+60,4+60,6+60,10+60,14+60,17+60,20+60,22+60,25+60,27+60,1+90,4+90,6+90,10+90,14+90,17+90,20+90,22+90,25+90,27+90,1+120,4+120,6+120,10+120,14+120,17+120,20+120,22+120,25+120,27+120};

//All class functions and variables defined below.

#endif


*************************Managed.cpp**************************This is the file in which error occurs************


#pragma once
#pragma managed //This makes no difference if its set to unmanaged or managed.
//#include "Unmanaged.h" ///////////////////////////////This is the line which causes the redefinition error///////////////

#pragma managed
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
return 0;
}

All these files are in the same CLR project. The Unmanaged.cpp file option is set not to use the CLR runtime. The Managed.cpp file is set to use the CLR runtime. All the files in the project and the project itself is set not to use precompiled headers. I am working in Visual Studio 2008.

What is causing the error. This is so strange. Please help.
AnswerRe: LNK2005 Redefinition Error on using CLI --already defined LNK2005 error Pin
Mark Salsbery31-May-09 9:37
Mark Salsbery31-May-09 9:37 
GeneralRe: LNK2005 Redefinition Error on using CLI --already defined LNK2005 error Pin
jobin00700731-May-09 10:18
jobin00700731-May-09 10:18 
GeneralRe: LNK2005 Redefinition Error on using CLI --already defined LNK2005 error [modified] Pin
Mark Salsbery31-May-09 10:40
Mark Salsbery31-May-09 10:40 
GeneralRe: LNK2005 Redefinition Error on using CLI --already defined LNK2005 error Pin
jobin00700731-May-09 10:48
jobin00700731-May-09 10:48 
GeneralRe: LNK2005 Redefinition Error on using CLI --already defined LNK2005 error Pin
Mark Salsbery31-May-09 10:53
Mark Salsbery31-May-09 10:53 
GeneralRe: LNK2005 Redefinition Error on using CLI --already defined LNK2005 error Pin
jobin00700731-May-09 11:00
jobin00700731-May-09 11:00 
GeneralRe: LNK2005 Redefinition Error on using CLI --already defined LNK2005 error Pin
Mark Salsbery31-May-09 11:08
Mark Salsbery31-May-09 11:08 
GeneralRe: LNK2005 Redefinition Error on using CLI --already defined LNK2005 error Pin
jobin00700731-May-09 12:07
jobin00700731-May-09 12:07 
GeneralRe: LNK2005 Redefinition Error on using CLI --already defined LNK2005 error Pin
Mark Salsbery1-Jun-09 7:09
Mark Salsbery1-Jun-09 7:09 
AnswerAttempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019) Help! Pin
jobin0070071-Jun-09 12:37
jobin0070071-Jun-09 12:37 
GeneralRe: Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019) Help! Pin
Mark Salsbery1-Jun-09 12:42
Mark Salsbery1-Jun-09 12:42 
GeneralRe: Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019) Help! Pin
jobin0070071-Jun-09 13:15
jobin0070071-Jun-09 13:15 
AnswerUnable to access variables. Pin
jobin0070071-Jun-09 13:18
jobin0070071-Jun-09 13:18 
GeneralRe: Unable to access variables. Pin
jobin0070071-Jun-09 13:21
jobin0070071-Jun-09 13:21 
GeneralRe: Unable to access variables. Pin
jobin0070071-Jun-09 13:27
jobin0070071-Jun-09 13:27 
GeneralRe: Unable to access variables. Pin
jobin0070071-Jun-09 13:54
jobin0070071-Jun-09 13:54 
GeneralRe: Unable to access variables. Pin
Mark Salsbery1-Jun-09 17:25
Mark Salsbery1-Jun-09 17:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.