[cfe-dev] New operator and some others don't have matching symbol names between clang and visual studio?

Astron B boldaster at gmail.com
Wed Dec 25 22:03:23 PST 2013


I have an issue while trying to link some clang compiled code. When I
compile my test dll with clang I get a new operator like this:


I guess this is conformant with GCC's naming.

But when compiling with visual studio the new operator is:

Searching libraries
    Searching C:\Program Files (x86)\Microsoft Visual Studio
      Found __purecall
        Referenced in ConsoleApplication2.obj
        Loaded MSVCRTD.lib(MSVCR110D.dll)
      Found "void * __cdecl operator new(unsigned int)" (??2 at YAPAXI@Z)
        Referenced in ConsoleApplication2.obj
        Loaded MSVCRTD.lib(MSVCR110D.dll)
      Found "void __cdecl operator delete(void *)" (??3 at YAXPAX@Z)
        Referenced in ConsoleApplication2.obj
        Loaded MSVCRTD.lib(MSVCR110D.dll)

I also noticed that with Clang I get a symbol for pure call catches called:

I assume the __purecall above is the visual studio version.

When I try to link the clang compiled object file using link.exe I get
unresolved symbol errors because of this.

F:\LLVM-fresh\vs11\bin\Debug>clang++ -c testdll.cpp -o testdll.o -v
clang version 3.5 (trunk)
Target: i686-pc-win32
Thread model: posix
 "F:\LLVM-fresh\vs11\bin\Debug\clang++.exe" -cc1 -triple i686-pc-win32
 -mrelax-all -disable-free -main-file-name testdll.cpp -mrelocation-model
 -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
pentium4 -v -coverage-file "F:\\LLVM-fresh\\vs11\\bin\\Debug\\testdll.o"
ce-dir "F:\\LLVM-fresh\\vs11\\bin\\Debug\\..\\lib\\clang\\3.5"
tem "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\INCLUDE"
al-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio
NCLUDE" -internal-isystem "C:\\Program Files (x86)\\Microsoft
0A\\include" -std=c++11 -fdeprecated-macro -fdebug-compilation-dir
sh\\vs11\\bin\\Debug" -ferror-limit 19 -fmessage-length 80 -mstackrealign
xtensions -fms-compatibility -fmsc-version=1700 -fdelayed-template-parsing
c-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
agnostics -vectorize-slp -o testdll.o -x c++ testdll.cpp
clang -cc1 version 3.5 based upon LLVM 3.5svn default target i686-pc-win32
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE
 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\INCLUDE
 C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include
End of search list.

F:\LLVM-fresh\vs11\bin\Debug>nm testdll.o
00000000 t .text
00000000 t .text
00000001 a @feat.00
00000000 T __ZN7testOneC2Ev
         U __Znwj
00000000 T _whatever


C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin>link /DLL
stdll.o /VERBOSE
Microsoft (R) Incremental Linker Version 11.00.50727.1
Copyright (C) Microsoft Corporation.  All rights reserved.

Starting pass 1

Searching libraries

Finished searching libraries

Finished pass 1

testdll.o : error LNK2019: unresolved external symbol __Znwj referenced in
ion _whatever
testdll.dll : fatal error LNK1120: 1 unresolved externals

How can I get this to link? Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131226/4367866d/attachment.html>

More information about the cfe-dev mailing list