The DWF Toolkit is used by Autodesk developers to read and write DWF files. Other companies also use the toolkit to support DWF in their own products. Software Engineer and DWF Technical Evangelist, Gyorgy Ordody, reports that DWF Toolkits 7.2.1 and 7.3 were tested to compile on various linux distributions using gcc 3.2.3; however the 4.0 version brought some major changes among them updates to the STL implementation. The following changes might be necessary to compile the toolkit and some of the samples using that version:
If you get error messages similar to the following:
/usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/stl_deque.h: In member function ‘void
std::_Deque_base<_Tp, _Alloc>::_M_initialize_map(size_t)’: /usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/stl_deque.h:469: error: expected
unqualified-id before ‘(’ token /usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/deque.tcc: In member function ‘void
std::deque<_Tp, _Alloc>::_M_reallocate_map(size_t, bool)’: /usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/deque.tcc:747: error: expected unqualified-id
before ‘(’ token /usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/stl_bvector.h: In member function
‘void std::vector::_M_insert_range(std::_Bit_iterator, _ForwardIterator,
_ForwardIterator, std::forward_iterator_tag)’: /usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/stl_bvector.h:542: error: expected
unqualified-id before ‘(’ token /usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/stl_bvector.h: In member function ‘void
std::vector::_M_fill_insert(std::_Bit_iterator, size_t, bool)’: /usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/stl_bvector.h:897: error: expected
unqualified-id before ‘(’ token /usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/vector.tcc: In member function ‘void
std::vector<_Tp, _Alloc>::_M_fill_insert(__gnu_cxx::__normal_iterator::
_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, size_t, const _Tp&)’: /usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/vector.tcc:353: error: expected
unqualified-id before ‘(’ token /usr/lib/gcc/i586-your-favorite-distro-linux-gnu/4.1.1/../../../../
include/c++/4.1.1/bits/vector.tcc: In member function ‘void
std::vector<_Tp, _Alloc>::_M_range_insert(__gnu_cxx::__normal_iterator::
_Tp_alloc_type:Try the following: - In lines 225-229 in DWFToolkit/develop/global/src/dwf/Toolkit.h should change to fix the problem the new compiler brings (it differentiates between 'const something' and 'something const'): Change const type1 to type1 const, like this:
# define _DWFTK_STD_VECTOR(type) std::vector
> # define _DWFTK_STD_MAP_COMP(type1, type2, comp) std::map > > # define _DWFTK_STD_MAP(type1, type2) _DWFTK_STD_MAP_COMP(type1, type2, less ) # define _DWFTK_STD_MULTIMAP_COMP(type1, type2, comp) std::multimap > > # define _DWFTK_STD_MULTIMAP(type1, type2) _DWFTK_STD_MULTIMAP_COMP(type1, type2, less ) If you get errors containing problems with min or max, that is caused by the fact that then new STL contains those functions. Min and max should be defines anyway, but sometimes there is no better way... - In lines 219-230 in DWFToolkit/develop/global/src/dwfcore/ansi/Core.h get rid of the following (or change the ifndef max to your own define that is not defined...):
// // max // #ifndef max #define max( a, b ) ((a) < (b) ? (b) : (a)) #endif // // min // #ifndef min #define min( a, b ) ((a) < (b) ? (a) : (b)) #endif
If you're trying to use ./configure --without-jpeg there can be some problems with some defines and Automake configurations. You're likely to get similar error messages to the following:
/home/your-username/your-project/DWFToolkit/develop/global/src/dwf/
w3dtk/BOpcodeHandler.cpp:5843: undefined reference to `jpeg_std_error' /home/your-username/your-project/DWFToolkit/develop/global/src/dwf/
w3dtk/BOpcodeHandler.cpp:5848: undefined reference to `jpeg_destroy_decompress' /home/your-username/your-project/DWFToolkit/develop/global/src/dwf/
w3dtk/BOpcodeHandler.cpp:5852: undefined reference to `jpeg_CreateDecompress' /home/your-username/your-project/DWFToolkit/develop/global/src/dwf/
w3dtk/BOpcodeHandler.cpp:5857: undefined reference to `jpeg_resync_to_restart' ...In this case, try the following: Change DWFToolkit/develop/global/src/dwf/w3dtk/jpeg/Makefile.am - Add this starting at line 6:
noinst_LTLIBRARIES = libdwfw3dtkjpeg.la libdwfw3dtkjpeg_la_LDFLAGS = -avoid-version libdwfw3dtkjpeg_la_SOURCES = jcapimin.c jcdctmgr.c jcmarker.c jcphuff.c /
jdapimin.c jdcoefct.c jdinput.c / jdmerge.c jdtrans.c jfdctint.c jidctred.c /
jmemmgr.c jquant2.c / jcapistd.c jchuff.c jcmaster.c jcprepct.c /
jdapistd.c jdcolor.c / jdmainct.c jdphuff.c jerror.c jidctflt.c /
jmemansi.c / jutils.c jccoefct.c jcinit.c jcomapi.c /
jcsample.c jdatadst.c / jddctmgr.c jdmarker.c jdpostct.c jfdctflt.c /
jidctfst.c / jccolor.c jcmainct.c jcparam.c jctrans.c /
jdatasrc.c / jdhuff.c jdmaster.c jdsample.c jfdctfst.c /
jidctint.c jquant1.cChange Line 11 of DWFToolkit/develop/global/src/dwf/w3dtk/Makefile.am - Add $(top_builddir)/w3dtk/jpeg/libdwfw3dtkjpeg.la to the end:
libdwfw3dtk_la_LIBADD = $(top_builddir)/w3dtk/utility/libdwfw3dtkutility.la
$(top_builddir)/w3dtk/hoops/libdwfw3dtkhoops.la
$(top_builddir)/w3dtk/jpeg/libdwfw3dtkjpeg.laChange DWFToolkit/develop/global/src/dwf/w3dtk/jpeg/jconfig.h - Insert this to your at line 23:
#define HAVE_PROTOTYPES #define HAVE_UNSIGNED_CHAR #define HAVE_UNSIGNED_SHORT #undef CHAR_IS_UNSIGNED #define HAVE_STDDEF_H #define HAVE_STDLIB_H #undef NEED_BSD_STRINGS #undef NEED_SYS_TYPES_H
Note: The formatting of this C++ code has been altered to make it fit this blog page. Thanks Gyorgy!
Still getting this error trying to compile the samples that come with DWF Toolkit 7.3.1 with GCC 4.1.2.
But the Toolkit.h in this version has the updated version of the code (i.e. type1 const)!!! This is driving me nuts. Perhaps there's somewhere else a similar change is needed?
Posted by: Charles Dale | February 12, 2008 at 11:24 PM
Charles,
Can you either post or email me (sriramDOTgopalakrishnanATautodeskDOTcom) the errors you are getting?
Thanks,
-Sriram
Posted by: Sriram Gopalakrishnan - Autodesk | February 14, 2008 at 01:40 PM