CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    15

    Linker Tools Error LNK2005

    I have been racking my brain trying to figure out how to resolve a duplicate function error (LNK2005) and have been unsuccessful. I have followed direction on the following link as well: http://msdn.microsoft.com/en-us/libr...(v=VS.80).aspx Attached is a printscreen of where the error occurs. The following are issues I have come across:

    1. One thing I noted in the output build report is that after invoking the linker with LINK.exe, one of the linker parameters that prints is /incremental:no, though when I look under Solution Explorer\Properties\Configuration Properties\Linker\General\Enable Incremental Linking the setting is Yes(/Incremental). Is there a setting somewhere that is causing an over-ride of the setting? I have done a build/clean for the project.

    2. I have specified under Solution Explorer\Properties\Configuration Properties\Linker\Input\Ignore Specific Library the mfcs90ud.lib file. I added it back as an additional dependency. Though I still have problems with this lib file.

    Code:
    // MetaDLL_5.cpp : Defines the initialization routines for the DLL.
    //
    #pragma once
     
    #define WIN32_LEAN_AND_MEAN
    //#define _AFXDLL
    
    //#include <windows.h>
    #include "stdafx.h"
    
    #include "MetaDLL_6.h"
    #using <mscorlib.dll>
     
    using namespace System;
    using namespace System::Globalization;
    using namespace System::Runtime::InteropServices;
    using System::String;
     
    #define MT4_EXPFUNC __declspec(dllexport)
     
    #pragma managed
    String *ansi_to_managed(char *date_time)
    	{
    	return Marshal::PtrToStringAnsi(date_time);
    	}
     
    #pragma unmanaged
    BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
    	{
    	return TRUE;
    	}
     
    #pragma managed
    MT4_EXPFUNC void __stdcall gDateTime(char *date_time, int *year, int *month, int *day, int *hour, int *minute, int *second, int *millisecond)
    	{
    	
    	//String *myDateTimeValue = ansi_to_managed(date_time);	
    	String *myDateTimeValue	  = S"02/16/1992 12:15:12.253";
    	String *expectedFormats[] = {S"MM/dd/yyyy HH:mm:ss.FFF"};
    	IFormatProvider* culture = new CultureInfo(S"en_US", true);
    	DateTime myDateTime = DateTime::ParseExact(myDateTimeValue, expectedFormats, culture, DateTimeStyles::AssumeLocal);
    	
    	*year			= myDateTime.Year;
    	*month			= myDateTime.Month;
    	*day			= myDateTime.Day;
    	*hour			= myDateTime.Hour;
    	*minute			= myDateTime.Minute;
    	*second			= myDateTime.Second;
    	*millisecond	= myDateTime.Millisecond;
    	}
    Attached Images Attached Images

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Linker Tools Error LNK2005

    Obviously your own DllMain() doesn't do anything exciting anyway. Have you tried to simply not define one at all to resolve the conflict?

    The fact that the conflicting definition is in one of the MFC DLLs suggests that it may actually be an MFC problem rather than one of managed code or interop. So your question may actually be better asked in the VC++ section. (When they see the managed parts of your code, the guys over there may try to simply send you back here. In that case just reply that you've actually have already been sent to over there explicitly from here. )

    As to DllMain() in managed DLLs: From what I've read it seems to be possible to define one, but mine have always worked fine without it. (Haven't ever written any mixed-mode DLLs yet, though.)
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured