Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Duplicate Function - Linker Error LNK2005

Duplicate Function - Linker Error LNK2005

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiocomhelptutorial
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike Certini
    wrote on last edited by
    #1

    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/library/72zdcz6f(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.

    // MetaDLL_5.cpp : Defines the initialization routines for the DLL.
    //
    #pragma once

    #define WIN32_LEAN_AND_MEAN
    //#define _AFXDLL

    //#include #include "stdafx.h"

    #include "MetaDLL_6.h"
    #using 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;
    }
    
    L 1 Reply Last reply
    0
    • M Mike Certini

      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/library/72zdcz6f(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.

      // MetaDLL_5.cpp : Defines the initialization routines for the DLL.
      //
      #pragma once

      #define WIN32_LEAN_AND_MEAN
      //#define _AFXDLL

      //#include #include "stdafx.h"

      #include "MetaDLL_6.h"
      #using 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;
      }
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      OK, I give up, what error did you get?

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups