Setup Ptex with D3D11 and Visual Studio

484 views
Skip to first unread message

Elberion

unread,
Aug 12, 2011, 2:20:48 PM8/12/11
to ptex
Hi everyone!
I am very new to this i am trying work with ptex with D3d11 and Visual
Studio.
The thing is i have included the Ptex files downloaded from "ptex.us"
into my project. So far so good, but when i compile i get:

f:\kit\ma\renderpacktests\sdkmeshdemo\ptex\ptexreader.h(39): fatal
error C1083: Cannot open include file: 'zlib.h': No such file or
directory
1> PtexHalf.cpp
1>f:\kit\ma\renderpacktests\sdkmeshdemo\ptex\ptexhalf.cpp(39): warning
C4273: 'f2hTable' : inconsistent dll linkage
1> f:\kit\ma\renderpacktests\sdkmeshdemo\ptex
\ptexhalf.h(117) : see previous definition of 'public: static unsigned
short * PtexHalf::f2hTable'
1>f:\kit\ma\renderpacktests\sdkmeshdemo\ptex\ptexhalf.cpp(39): error
C2491: 'PtexHalf::f2hTable' : definition of dllimport static data
member not allowed
1>f:\kit\ma\renderpacktests\sdkmeshdemo\ptex\ptexhalf.cpp(40): warning
C4273: 'h2fTable' : inconsistent dll linkage

etc.

I can't find the zlib.h anywhere in the source code i downloaded from
ptex.us.

So summarizing:
Can someone tell me what i need to do to run PTex with Visual Studio?

Thank u very much in advance
Elberion.

brentb

unread,
Aug 12, 2011, 5:51:02 PM8/12/11
to ptex
On Aug 12, 11:20 am, Elberion <elber...@gmail.com> wrote:
> error C1083: Cannot open include file: 'zlib.h': No such file or directory

zlib is a separate library available at zlib.net. This is a widely
used data compression library and is unrelated to Ptex. You can
download it as source code or as a precompiled dll.

> 1>f:\kit\ma\renderpacktests\sdkmeshdemo\ptex\ptexhalf.cpp(39): warning
> C4273: 'f2hTable' : inconsistent dll linkage

I've heard of this issue but I don't know enough about Windows DLLs to
know how people are getting around it (we only use Linux at Disney).
One option might be to compile Ptex directly into your application
insetad of trying to make it into a DLL. Another might be to just
compile the PtexHalf class directly into your application (if you even
need it) and change the declaration of PtexHalf to not export those
symbols. Btw, if someone wants to submit a patch that makes this
problem go away, I'd happily accept it ;-) You might also try using
CMake. There are Ptex forks on github that have been able to build
Ptex for windows using CMake.

Cheers,

Brent

Ron Griswold

unread,
Aug 12, 2011, 6:01:07 PM8/12/11
to pt...@googlegroups.com, ptex
The dll linkage thing usually has to do with trying to link a multi-threaded app to a single-threaded dll (or vice versa). Should just be a setting in your linker options.

Ron

Elberion

unread,
Aug 13, 2011, 7:52:06 AM8/13/11
to ptex
First of all thank you very much for your answers.

I have used cmake to make a visual studio project out of the ptex,
downloaded from (ptex.us). Executing this, i've got a lot of compiling
errors that prevented the program from creating the Ptex.lib file.
I could correct a lot of them(thx @brentb) but the dll linkage errors
still remain.

F:\KIT\MA\wdas-ptex-fd75b1b\src\ptex\PtexHalf.cpp(39): warning C4273:
'f2hTable' : inconsistent dll linkage
3> f:\kit\ma\wdas-ptex-fd75b1b\src\ptex\PtexHalf.h(117) : see
previous definition of 'public: static unsigned short *
PtexHalf::f2hTable'
3>F:\KIT\MA\wdas-ptex-fd75b1b\src\ptex\PtexHalf.cpp(39): error C2491:
'PtexHalf::f2hTable' : definition of dllimport static data member not
allowed
3>F:\KIT\MA\wdas-ptex-fd75b1b\src\ptex\PtexHalf.cpp(40): warning
C4273: 'h2fTable' : inconsistent dll linkage
3> f:\kit\ma\wdas-ptex-fd75b1b\src\ptex\PtexHalf.h(116) : see
previous definition of 'public: static unsigned int *
PtexHalf::h2fTable'
3>F:\KIT\MA\wdas-ptex-fd75b1b\src\ptex\PtexHalf.cpp(40): error C2491:
'PtexHalf::h2fTable' : definition of dllimport static data member not
allowed
3>F:\KIT\MA\wdas-ptex-fd75b1b\src\ptex\PtexHalf.cpp(88): warning
C4273: 'PtexHalf::fromFloat_except' : inconsistent dll linkage
3> f:\kit\ma\wdas-ptex-fd75b1b\src\ptex\PtexHalf.h(112) : see
previous definition of 'fromFloat_except'
2>F:\KIT\MA\wdas-ptex-fd75b1b\src\ptex\PtexHalf.cpp(39): warning
C4273: 'f2hTable' : inconsistent dll linkage
2> f:\kit\ma\wdas-ptex-fd75b1b\src\ptex\PtexHalf.h(117) : see
previous definition of 'public: static unsigned short *
PtexHalf::f2hTable'
2>F:\KIT\MA\wdas-ptex-fd75b1b\src\ptex\PtexHalf.cpp(39): error C2491:
'PtexHalf::f2hTable' : definition of dllimport static data member not
allowed
2>F:\KIT\MA\wdas-ptex-fd75b1b\src\ptex\PtexHalf.cpp(40): warning
C4273: 'h2fTable' : inconsistent dll linkage
2> f:\kit\ma\wdas-ptex-fd75b1b\src\ptex\PtexHalf.h(116) : see
previous definition of 'public: static unsigned int *
PtexHalf::h2fTable'
2>F:\KIT\MA\wdas-ptex-fd75b1b\src\ptex\PtexHalf.cpp(40): error C2491:
'PtexHalf::h2fTable' : definition of dllimport static data member not
allowed
2>F:\KIT\MA\wdas-ptex-fd75b1b\src\ptex\PtexHalf.cpp(88): warning
C4273: 'PtexHalf::fromFloat_except' : inconsistent dll linkage
2> f:\kit\ma\wdas-ptex-fd75b1b\src\ptex\PtexHalf.h(112) : see
previous definition of 'fromFloat_except'

@Ron: I have searched in visual studio's project linker options, but i
haven found anything that looks like "Don't link multithreaded to
single-threaded dll"

Does someone know hot to get pass these errors?
Thank you again for the fast reply
Elberion

On 13 ago, 00:01, Ron Griswold <ron.grisw...@gmail.com> wrote:
> The dll linkage thing usually has to do with trying to link a multi-threaded app to a single-threaded dll (or vice versa). Should just be a setting in your linker options.
>
> Ron
>

Elberion

unread,
Aug 15, 2011, 6:40:03 AM8/15/11
to ptex
I have been looking how to solve this and i have changed this piece of
code on PTexHalf.h:

# ifdef PTEX_EXPORTS
# define PTEXAPI __declspec(dllimport)
# else
# define PTEXAPI __declspec(dllexport)

So that "define PTEXAPI __declspec(dllexport)" is executed. The
inconsistent ddl linkage warning is gone as for the "definition of
dllimport static data member not
allowed " error. But now i have unresolved externals which i dont know
how to solve:

PtexCache.obj : warning LNK4217: locally defined symbol ??
4String@Ptex@@QAEAAV01@PBD@Z (public: class Ptex::String & __thiscall
Ptex::String::operator=(char const *)) imported in function "public:
virtual class PtexTexture * __thiscall PtexReaderCache::get(char const
*,class Ptex::String &)" (?
get@PtexReaderCache@@UAEPAVPtexTexture@@PBDAAVString@Ptex@@@Z)
2>PtexReader.obj : warning LNK4049: locally defined symbol ??
4String@Ptex@@QAEAAV01@PBD@Z (public: class Ptex::String & __thiscall
Ptex::String::operator=(char const *)) imported
2>PtexWriter.obj : warning LNK4217: locally defined symbol ??
4String@Ptex@@QAEAAV01@PBD@Z (public: class Ptex::String & __thiscall
Ptex::String::operator=(char const *)) imported in function
"protected: __thiscall PtexWriterBase::PtexWriterBase(char const
*,enum Ptex::MeshType,enum Ptex::DataType,int,int,int,bool)" (??
0PtexWriterBase@@IAE@PBDW4MeshType@Ptex@@W4DataType@2@HHH_N@Z)
2>PtexReader.obj : warning LNK4217: locally defined symbol ?
create@PtexCache@@SAPAV1@HH_NPAVPtexInputHandler@@@Z (public: static
class PtexCache * __cdecl PtexCache::create(int,int,bool,class
PtexInputHandler *)) imported in function "public: static class
PtexTexture * __cdecl PtexTexture::open(char const *,class
Ptex::String &,bool)" (?
open@PtexTexture@@SAPAV1@PBDAAVString@Ptex@@_N@Z)
2>PtexReader.obj : warning LNK4217: locally defined symbol ?
ConvertToFloat@Ptex@@SAXPAMPBXW4DataType@1@H@Z (public: static void
__cdecl Ptex::ConvertToFloat(float *,void const *,enum
Ptex::DataType,int)) imported in function "public: virtual void
__thiscall PtexReader::getPixel(int,int,int,float *,int,int)" (?
getPixel@PtexReader@@UAEXHHHPAMHH@Z)
2>PtexSeparableFilter.obj : warning LNK4049: locally defined symbol ?
ConvertToFloat@Ptex@@SAXPAMPBXW4DataType@1@H@Z (public: static void
__cdecl Ptex::ConvertToFloat(float *,void const *,enum
Ptex::DataType,int)) imported
2>PtexTriangleFilter.obj : warning LNK4049: locally defined symbol ?
ConvertToFloat@Ptex@@SAXPAMPBXW4DataType@1@H@Z (public: static void
__cdecl Ptex::ConvertToFloat(float *,void const *,enum
Ptex::DataType,int)) imported
2>PtexSeparableKernel.obj : warning LNK4049: locally defined symbol ?
h2fTable@PtexHalf@@2PAIA (public: static unsigned int *
PtexHalf::h2fTable) imported
2>PtexTriangleKernel.obj : warning LNK4049: locally defined symbol ?
h2fTable@PtexHalf@@2PAIA (public: static unsigned int *
PtexHalf::h2fTable) imported
2>PtexWriter.obj : warning LNK4217: locally defined symbol ?
open@PtexTexture@@SAPAV1@PBDAAVString@Ptex@@_N@Z (public: static class
PtexTexture * __cdecl PtexTexture::open(char const *,class
Ptex::String &,bool)) imported in function "public: static class
PtexWriter * __cdecl PtexWriter::edit(char const *,bool,enum
Ptex::MeshType,enum Ptex::DataType,int,int,int,class Ptex::String
&,bool)" (?
edit@PtexWriter@@SAPAV1@PBD_NW4MeshType@Ptex@@W4DataType@3@HHHAAVString@3@1@Z)
2>PtexWriter.obj : warning LNK4217: locally defined symbol ??
1String@Ptex@@QAE@XZ (public: __thiscall Ptex::String::~String(void))
imported in function "public: virtual void __thiscall
PtexWriterBase::release(void)" (?release@PtexWriterBase@@UAEXXZ)
2>PtexReader.obj : error LNK2019: unresolved external symbol
_inflateInit_ referenced in function "public: __thiscall
PtexReader::PtexReader(void * *,class PtexCacheImpl *,bool,class
PtexInputHandler *)" (??
0PtexReader@@QAE@PAPAXPAVPtexCacheImpl@@_NPAVPtexInputHandler@@@Z)
2>PtexReader.obj : error LNK2019: unresolved external symbol
_inflateEnd referenced in function "protected: virtual __thiscall
PtexReader::~PtexReader(void)" (??1PtexReader@@MAE@XZ)
2>PtexReader.obj : error LNK2019: unresolved external symbol
_inflateReset referenced in function "protected: bool __thiscall
PtexReader::readZipBlock(void *,int,int)" (?
readZipBlock@PtexReader@@IAE_NPAXHH@Z)
2>PtexReader.obj : error LNK2019: unresolved external symbol _inflate
referenced in function "protected: bool __thiscall
PtexReader::readZipBlock(void *,int,int)" (?
readZipBlock@PtexReader@@IAE_NPAXHH@Z)
2>PtexWriter.obj : error LNK2019: unresolved external symbol
_deflateInit_ referenced in function "protected: __thiscall
PtexWriterBase::PtexWriterBase(char const *,enum Ptex::MeshType,enum
Ptex::DataType,int,int,int,bool)" (??
0PtexWriterBase@@IAE@PBDW4MeshType@Ptex@@W4DataType@2@HHH_N@Z)
2>PtexWriter.obj : error LNK2019: unresolved external symbol
_deflateEnd referenced in function "protected: virtual __thiscall
PtexWriterBase::~PtexWriterBase(void)" (??1PtexWriterBase@@MAE@XZ)
2>PtexWriter.obj : error LNK2019: unresolved external symbol
_deflateReset referenced in function "protected: int __thiscall
PtexWriterBase::writeZipBlock(struct _iobuf *,void const
*,int,bool)" (?writeZipBlock@PtexWriterBase@@IAEHPAU_iobuf@@PBXH_N@Z)
2>PtexWriter.obj : error LNK2019: unresolved external symbol _deflate
referenced in function "protected: int __thiscall
PtexWriterBase::writeZipBlock(struct _iobuf *,void const
*,int,bool)" (?writeZipBlock@PtexWriterBase@@IAEHPAU_iobuf@@PBXH_N@Z)
2>F:\KIT\MA\wdas-ptex-fd75b1b\src\Debug\Ptex.dll : fatal error
LNK1120: 8 unresolved externals

halftest.obj : error LNK2001: unresolved external symbol "public:
static unsigned int * PtexHalf::h2fTable" (?h2fTable@PtexHalf@@2PAIA)
halftest.obj : error LNK2001: unresolved external symbol "public:
static unsigned short * PtexHalf::f2hTable" (?
f2hTable@PtexHalf@@2PAGA)

I hope someone can help me, i am pretty excited about starting with
Ptex.

Thanks in advance,
Elberion
Reply all
Reply to author
Forward
0 new messages