Community
cancel
Showing results for 
Search instead for 
Did you mean: 
lou-muccioli
Beginner
208 Views

ldexpf already defined linker error

Hi,

I'm compiling a particular C++ file (Math.cpp) with /Od and I'm getting the following linker error.  It links successfully with /O1 or /O2.

I don't see any specific reference to "ldexpf" in the source so I'm not sure where it's coming from.  The source is confidential and proprietary so I cannot display it here, sorry.

libmmd.lib(libmmd.dll) : error LNK2005: ldexpf already defined in mylib.lib(Math.obj)

Doing a dumpbin of the object file, I notice this.

SECTION HEADER #1
   .text name
       0 physical address
       0 virtual address
      70 size of raw data
  119A54 file pointer to raw data (00119A54 to 00119AC3)
  6CF9F9 file pointer to relocation table
       0 file pointer to line numbers
       1 number of relocations
       0 number of line numbers
60301020 flags
         Code
         COMDAT; sym= ldexpf
         4 byte align
         Execute Read

My environment is Windows 10 and Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.6.285 Build 20151119

Thanks,

Lou

0 Kudos
4 Replies
Melanie_B_Intel
Employee
208 Views

Can you preprocess (use the -E switch) and check if ldexpf is in the preprocessed output? What include file is it coming from?  Can you paste the preprocessed output which contains the definition/declaration of ldexpf?

Can you paste the link line which gives the error?

You might start by looking up the linker error code on the Microsoft site and read about comdat sections.

lou-muccioli
Beginner
208 Views

Sorry for my delayed response.  I pre-processed the file using the /P switch and it looks like it's coming from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\math.h

inline float ldexpf( float _X,  int _Y)

        {return ((float)ldexp((double)_X, _Y)); }

 

Here's the link line:

2>Link:
2>  Microsoft (R) Incremental Linker Version 11.00.61030.0
2>  Copyright (C) Microsoft Corporation.  All rights reserved.
2>  
2>  /OUT:E:\ANSYSDev\Projects\v180\Build\x64\Debug\ANSYS.exe 
2>  /INCREMENTAL:NO 
2>  /LIBPATH:E:\ANSYSDev\Projects\v180\Build\x64\Debug\ 
2>  /LIBPATH:.\Lib 
2>  "/LIBPATH:C:\ANSYSDev\Program Files\Ansys Inc\v180\ansys\custom\lib\winx64" 
2>  "/LIBPATH:C:\Program Files (x86)\Intel\Composer XE 2015\compiler\lib\intel64" 
2>  "/LIBPATH:C:\Program Files (x86)\Intel\Composer XE 2015\mkl\lib\intel64" 
2>  ANSYSFLIB.lib 
2>  ansyslib1.lib 
2>  ansyslib2.lib 
2>  ansyslib3.lib 
2>  ansyslib4.lib 
2>  ansysb.lib 
2>  ansysdspar.lib 
2>  ansyschap.lib 
2>  anslibx.lib 
2>  UserMatLib.lib 
2>  UserCreepLib.lib 
2>  UserFricLib.lib 
2>  UserHyperLib.lib 
2>  USolBegLib.lib 
2>  USolFinLib.lib 
2>  UserElemLib.lib 
2>  UsrShiftLib.lib 
2>  UsrSurf116Lib.lib 
2>  UAnBegLib.lib 
2>  UAnFinLib.lib 
2>  UElMatxLib.lib 
2>  UItBegLib.lib 
2>  UItFinLib.lib 
2>  ULdBegLib.lib 
2>  ULdFinLib.lib 
2>  USSBegLib.lib 
2>  USSFinLib.lib 
2>  user01Lib.lib 
2>  user02Lib.lib 
2>  user03Lib.lib 
2>  user04Lib.lib 
2>  user05Lib.lib 
2>  user06Lib.lib 
2>  user07Lib.lib 
2>  user08Lib.lib 
2>  user09Lib.lib 
2>  user10Lib.lib 
2>  usercvLib.lib 
2>  userfxLib.lib 
2>  userouLib.lib 
2>  usreflLib.lib 
2>  usercrLib.lib 
2>  userswstrainLib.lib 
2>  userinterLib.lib 
2>  usercnpropLib.lib 
2>  user_tbelasticLib.lib 
2>  UCnvrgLib.lib 
2>  UTimeIncLib.lib 
2>  userfldLib.lib 
2>  userwearLib.Lib 
2>  userCZMLib.Lib 
2>  usermatthLib.lib 
2>  userthstrainLib.lib 
2>  userinistateLib.lib 
2>  mnflib.lib 
2>  mpcci.lib 
2>  cadoe_core.lib 
2>  cadoe_algorithms.lib 
2>  DBInterface.lib 
2>  AnsRpc.lib 
2>  AnsMPI.lib 
2>  AnsGPU.lib 
2>  EXBlib.lib 
2>  WTBFunctions.lib 
2>  MapdlExceptionClient.lib 
2>  ans_gil.lib 
2>  cgns.lib 
2>  zlibstat.lib 
2>  user32.lib 
2>  gdi32.lib 
2>  comctl32.lib 
2>  netapi32.lib 
2>  comdlg32.lib 
2>  winspool.lib 
2>  opengl32.lib 
2>  ADVAPI32.lib 
2>  vfw32.lib 
2>  glu32.lib 
2>  shell32.lib 
2>  ws2_32.lib 
2>  jpeg62.lib 
2>  htmlhelp.lib 
2>  libtiff.lib 
2>  png.lib 
2>  mkl_rt.lib 
2>  libiomp5md.lib 
2>  Psapi.lib 
2>  DbgHelp.lib 
2>  WER.lib 
2>  Delayimp.lib 
2>  kernel32.lib 
2>  user32.lib 
2>  gdi32.lib 
2>  winspool.lib 
2>  comdlg32.lib 
2>  advapi32.lib 
2>  shell32.lib 
2>  ole32.lib 
2>  oleaut32.lib 
2>  uuid.lib 
2>  odbc32.lib 
2>  odbccp32.lib 
2>  Delayimp.lib 
2>  /NODEFAULTLIB:vcomp.lib 
2>  /NODEFAULTLIB:libguide40.lib 
2>  /DEF:ansysex.def 
2>  /DELAYLOAD:UserMatLib.dll 
2>  /DELAYLOAD:UserCreepLib.dll 
2>  /DELAYLOAD:UserFricLib.dll 
2>  /DELAYLOAD:UserHyperLib.dll 
2>  /DELAYLOAD:USolBegLib.dll 
2>  /DELAYLOAD:USolFinLib.dll 
2>  /DELAYLOAD:UserElemLib.dll 
2>  /DELAYLOAD:UsrShiftLib.dll 
2>  /DELAYLOAD:UsrSurf116Lib.dll 
2>  /DELAYLOAD:UAnBegLib.dll 
2>  /DELAYLOAD:UAnFinLib.dll 
2>  /DELAYLOAD:UElMatxLib.dll 
2>  /DELAYLOAD:UItBegLib.dll 
2>  /DELAYLOAD:UItFinLib.dll 
2>  /DELAYLOAD:ULdBegLib.dll 
2>  /DELAYLOAD:ULdFinLib.dll 
2>  /DELAYLOAD:USSBegLib.dll 
2>  /DELAYLOAD:USSFinLib.dll 
2>  /DELAYLOAD:user01Lib.dll 
2>  /DELAYLOAD:user02Lib.dll 
2>  /DELAYLOAD:user03Lib.dll 
2>  /DELAYLOAD:user04Lib.dll 
2>  /DELAYLOAD:user05Lib.dll 
2>  /DELAYLOAD:user06Lib.dll 
2>  /DELAYLOAD:user07Lib.dll 
2>  /DELAYLOAD:user08Lib.dll 
2>  /DELAYLOAD:user09Lib.dll 
2>  /DELAYLOAD:user10Lib.dll 
2>  /DELAYLOAD:usercvLib.dll 
2>  /DELAYLOAD:userfxLib.dll 
2>  /DELAYLOAD:userouLib.dll 
2>  /DELAYLOAD:usreflLib.dll 
2>  /DELAYLOAD:usercrLib.dll 
2>  /DELAYLOAD:userswstrainLib.dll 
2>  /DELAYLOAD:userinterLib.dll 
2>  /DELAYLOAD:usercnpropLib.dll 
2>  /DELAYLOAD:user_tbelasticLib.dll 
2>  /DELAYLOAD:UCnvrgLib.dll 
2>  /DELAYLOAD:UTimeIncLib.dll 
2>  /DELAYLOAD:userfldLib.dll 
2>  /DELAYLOAD:userwearLib.dll 
2>  /DELAYLOAD:userCZMLib.lib 
2>  /DELAYLOAD:usermatthLib.lib 
2>  /DELAYLOAD:userthstrainLib.dll 
2>  /DELAYLOAD:userinistateLib.dll 
2>  /DELAYLOAD:WER.dll 
2>  /MANIFEST 
2>  "/MANIFESTUAC:level='asInvoker' uiAccess='false'" 
2>  /DEBUG 
2>  /PDB:E:\ANSYSDev\Projects\v180\Build\x64\Debug\ANSYS.pdb 
2>  /MAP:E:\ANSYSDev\Projects\v180\Build\x64\Debug\ANSYS.map 
2>  /SUBSYSTEM:WINDOWS 
2>  /STACK:33554432 
2>  /LARGEADDRESSAWARE 
2>  /OPT:REF 
2>  /TLBID:1 
2>  /DYNAMICBASE 
2>  /FIXED:NO 
2>  /IMPLIB:E:\ANSYSDev\Projects\v180\Build\x64\Debug\ANSYS.lib 
2>  /MACHINE:X64 
2>  x64\Debug\MyCtoFDummy.obj 
2>  x64\Debug\nt_WinAnsys.obj 
2>  Lib\amgsolver.obj 
2>  Lib\amg_hard_data.obj 
2>  Lib\amg_init.obj 
2>  Lib\elcjfill.obj 
2>  Lib\elshfn.obj 
2>  Lib\elshfnFr.obj 
2>  Lib\elshfnFrN.obj 
2>  Lib\FEM_faPublic.obj 
2>  Lib\LuDecom.obj 
2>  Lib\magmaini.obj 
2>  Lib\masscoefTri.obj 
2>  Lib\mscoef.obj 
2>  Lib\msgini.obj 
2>  Lib\nodf10.obj 
2>  Lib\nodfTri.obj 
2>  Lib\nshpderv.obj 
2>  Lib\nt_inexnt.obj 
2>  Lib\nt_inexntL.obj 
2>  Lib\nt_uiloop.obj 
2>  Lib\nt_WinGUI.obj 
2>  Lib\nt_WinMain.obj 
2>  Lib\pElData.obj 
2>  Lib\siapp.obj 
2>  Lib\sstiff2d.obj 
2>  Lib\sstiff3d.obj 
2>  Lib\stcoef.obj 
2>  Lib\stcoefTri.obj 
2>  Lib\tess_info.obj 
2>  Lib\thcoef.obj 
2>  Lib\thcoefTri.obj 
2>  Lib\Trinshpderv.obj 
2>  Lib\hShpGauss3.obj 
2>  Lib\UserLink0.obj 
2>  Lib\xfElNdFaceEdgeRel.obj 
2>  Lib\xml_labutils.obj 
2>  "C:\ANSYSDev\Program Files\Ansys Inc\v180\ansys\custom\lib\winx64\WinAnsys.res" 
2>libmmd.lib(libmmd.dll) : error LNK2005: ldexpf already defined in ansyslib1.lib(APDLMath.obj)
2>     Creating library E:\ANSYSDev\Projects\v180\Build\x64\Debug\ANSYS.lib and object E:\ANSYSDev\Projects\v180\Build\x64\Debug\ANSYS.exp
2>LINK : warning LNK4199: /DELAYLOAD:userCZMLib.lib ignored; no imports found from userCZMLib.lib
2>LINK : warning LNK4199: /DELAYLOAD:usermatthLib.lib ignored; no imports found from usermatthLib.lib
2>LINK : warning LNK4199: /DELAYLOAD:WER.dll ignored; no imports found from WER.dll
2>E:\ANSYSDev\Projects\v180\Build\x64\Debug\ANSYS.exe : fatal error LNK1169: one or more multiply defined symbols found
2>
2>Build FAILED.

 

Judith_W_Intel
Employee
208 Views

 

When you compile without optimizations the call to ldexpf in your code is not inlined so you end up with a definition from the Microsoft math library. I think the question is why does the ansyslib1.lib (APDLMath.obj)  also define a symbol that should be a reserved name to the implementation.

Judy

lou-muccioli
Beginner
208 Views

Hi,

I contacted the developer and he had a #include "mathimf.h" in another file which was causing the error.

He as since removed that line and the build is successful.

RESOLVED

Lou

Reply