Compile in VS2013

82 views
Skip to first unread message

Ronald Pan

unread,
Jan 19, 2016, 1:41:42 AM1/19/16
to ptex
Hi, I am trying compile Ptex in VS2013. However,errors appeared.
PtexFilters.obj : error LNK2005: "void __cdecl Ptex::v2_2::_mm_mfence(void)" (?_mm_mfence@v2_2@Ptex@@YAXXZ) already defined in PtexCache.obj
PtexReader.obj : error LNK2005: "void __cdecl Ptex::v2_2::_mm_mfence(void)" (?_mm_mfence@v2_2@Ptex@@YAXXZ) already defined in PtexCache.obj
PtexSeparableFilter.obj : error LNK2005: "void __cdecl Ptex::v2_2::_mm_mfence(void)" (?_mm_mfence@v2_2@Ptex@@YAXXZ) already defined in PtexCache.obj
PtexSeparableKernel.obj : error LNK2005: "void __cdecl Ptex::v2_2::_mm_mfence(void)" (?_mm_mfence@v2_2@Ptex@@YAXXZ) already defined in PtexCache.obj
PtexTriangleFilter.obj : error LNK2005: "void __cdecl Ptex::v2_2::_mm_mfence(void)" (?_mm_mfence@v2_2@Ptex@@YAXXZ) already defined in PtexCache.obj
PtexTriangleKernel.obj : error LNK2005: "void __cdecl Ptex::v2_2::_mm_mfence(void)" (?_mm_mfence@v2_2@Ptex@@YAXXZ) already defined in PtexCache.obj
PtexUtils.obj : error LNK2005: "void __cdecl Ptex::v2_2::_mm_mfence(void)" (?_mm_mfence@v2_2@Ptex@@YAXXZ) already defined in PtexCache.obj
PtexWriter.obj : error LNK2005: "void __cdecl Ptex::v2_2::_mm_mfence(void)" (?_mm_mfence@v2_2@Ptex@@YAXXZ) already defined in PtexCache.obj
Could anybody help to find the solution?

Brent Burley

unread,
Jan 19, 2016, 6:39:59 PM1/19/16
to ptex
I don't have easy access to VS2013 to test this, but I'm guessing there's a clash between the Ptex MemoryFence function and the Windows MemoryFence macro.

Can you try renaming the Ptex MemoryFence function ?  E.g.

src/ptex/PtexHashMap.h:236
-                MemoryFence();
+                PtexMemoryFence();

src/ptex/PtexPlatform.h:278
-PTEX_INLINE void MemoryFence()
+PTEX_INLINE void PtexMemoryFence()

If that fixes it, I'll submit a patch.

Ronald Pan

unread,
Jan 19, 2016, 9:20:37 PM1/19/16
to ptex
It does not fix the errors.

Ronald Pan

unread,
Jan 19, 2016, 9:30:54 PM1/19/16
to ptex
When I include MemoryBarrier directly, the errors disappeared.

MemoryBarrier();//MEM_FENCE();

在 2016年1月20日星期三 UTC+8上午10:20:37,Ronald Pan写道:

James

unread,
Feb 8, 2016, 1:24:27 PM2/8/16
to ptex
Hi Brent,
 There are two problems related to this on Windows, it's not anything particular to do with VS2013 (vc12) but it seems the vc12 linker is more fussy than previous linkers. 

First problem: in the Windows SDK (which is separate from Visual Studio) there is this in winnt.h for targeting x64:

#define MemoryFence mm_fence

This is in at least as far back as version 7 of the SDK and my reading of that file it would be true for any vc compiler targeting x64. Renaming MemoryFence to PtexMemoryFence gets us past that problem.

Second problem, this one is much lessor, in non-release mode the PTEX_INLINE on windows becomes a macro to nothing. This is a problem for vc10 through at least vc12 as it will not fold the symbol PtexMemoryFence (which is the only non-templatized function in PtexPlatform.h) and it gets used in multiple .cpp files. The linker in vc12 refuses to accept PtexMemoryFence as a multiply defined symbol. Needs to be "inline void PtexMemoryFence" I suppose.

 
Cheers,
- James

Pixar Animation Studios.

Brent Burley

unread,
Feb 8, 2016, 1:38:51 PM2/8/16
to pt...@googlegroups.com
Thanks James!  It looks like the lack of inline on the WINDOWS debug target was an oversight.  I just pushed the fix you suggested. Any chance you could check it again?

--

---
You received this message because you are subscribed to the Google Groups "ptex" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ptex+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James

unread,
Feb 8, 2016, 2:24:37 PM2/8/16
to ptex
Works under debug/release and I no longer get any warnings/errors on any windows compilers (icc or vc). icc really didn't like the effects of the winnt macro, it would actually throw a LNK1223 error which has got nothing to do with anything going on here, msdn says that's about compiling on RISC architectures with WPO turned on (neither applies to me). Anyway, all good now.

Thanks!
- James
Reply all
Reply to author
Forward
0 new messages