Cannot use LibHaru because cannot find the reference of zlib - c++

I am trying to build a program that will hopefully create dynamic .pdf files. I have actually developed a similar project with PHP for web, but now I want to write it with C++.
This resulted me to rebuild those three libraries (zlib, libpng and libharu) more than time times for the last four days. I have read all the relevant entries in the web (including this stack overflow entry) I understood that my problem is that the compiler cannot find zlib (maybe I understood the problem wrongly)
I want to explain what I've done. Please note that I'm using Codeblocks IDE with GNU GCC C++ Compiler (MingGW) in Windows 7. First, I compiled zlib 1.2.7 and created my zlib.a static library file (I'm using static libraries). Secondly, I compiled libpng 1.5.13 and created my libpng.a. Thirdly, I compiled libharu (snapshot) and created my libharu.a static library file. Then I added those library files to my project. (I did everything explained in here). And at last, compiled my project.
Well, I shall say I did those all steps more than ten times, changing some small things, but everytime I am getting an error. I have even tried the official examples in libharu.org.
The most weird thing is that my error is NOT stable. Nearly everytime I got different errors! But mostly it was related with hpdf_streams.c.
My recent log file:
C:\Libs\libharu-201301131604\libharu.a(hpdf_streams.o):hpdf_streams.c:(.text+0xd4a): undefined reference to `deflateInit_'
C:\Libs\libharu-201301131604\libharu.a(hpdf_streams.o):hpdf_streams.c:(.text+0xdfa): undefined reference to `deflate'
C:\Libs\libharu-201301131604\libharu.a(hpdf_streams.o):hpdf_streams.c:(.text+0xe78): undefined reference to `deflateEnd'
C:\Libs\libharu-201301131604\libharu.a(hpdf_streams.o):hpdf_streams.c:(.text+0xee2): undefined reference to `deflate'
C:\Libs\libharu-201301131604\libharu.a(hpdf_streams.o):hpdf_streams.c:(.text+0xf7e): undefined reference to `deflateEnd'
C:\Libs\libharu-201301131604\libharu.a(hpdf_streams.o):hpdf_streams.c:(.text+0xfb7): undefined reference to `deflateEnd'
C:\Libs\libharu-201301131604\libharu.a(hpdf_streams.o):hpdf_streams.c:(.text+0xff1): undefined reference to `deflateEnd'

We just had this issue. You need to recompile zlib with WIN_API off. Or use the dll's and not the static library.

Related

MSVC library linking with MinGW

I have dll libraries from specific SDK compiled with MSVC '08 while using MinGW. And yes, I've got undefined reference.
undefined reference to `Some::NameSpace::Here::Class::method()'
In my project I'm using MinGW comliler with Qt (just because I'm making cross-platform app) and Linux libraries provided with SDK works just fine.
1) I've tried using pexports tool as in mentioned in MinGW FAQ but got no success. Still same undefined reference (no changes in errors masseges).
In my .def file I've got lines like:
?Method#Class#Here#NameSpace#Some##QAE_NIIGW4eReturnType#234##Z
2) Also extern "C" wasn't helpful. I surrounded with it every SDK .h include where it was possible (one header contains template definitions, so I wasn't able to surround it).
Strange thing is, that instead of:
undefined reference to `_imp___ZN6IClass6Methodci'
I got:
undefined reference to `Some::NameSpace::Here::Class::method()'
In function `ZN11MyClass21MethodEv':
So I think I messed up with name mangling.

undefined references cygwin with stdcall-fixup

I'm building something using Cygwin 32 bit. It's quite large so it has a couple of header files defined in their own .cpp files. I'm even using a few c++ boost headers, linking them. I'm doing this on x64 Eclipse Luna. The project is comprised of a mix of C and C++ files. Every time I build the project I keep getting undefined references errors, for all functions in the header files, including those from boost, despite me having linked the boost libraries correctly. Unfortunately, I don't have enough reputation to attach a screenshot(doesn't make any sense). But below is a sample of the errors. I have even tried linking using option enable-stdcall-fixup to no avail.
./caches.o:caches.cpp:(.text+0x1957): undefined reference to `boost::filesystem::detail::directory_iterator_construct(boost::filesystem::directory_iterator&, boost::filesystem::path const&, boost::system::error_code*)'
./caches.o:caches.cpp:(.text$_ZNK5boost10filesystem16filesystem_error4whatEv[__ZNK5boost10filesystem16filesystem_error4whatEv]+0xa2): undefined reference to `boost::filesystem::path::codecvt()'
./fscore.o:fscore.cpp:(.text+0xa1): undefined reference to `btree_init()'
Please help.
Sincerely, batman

MPI undefined object references

I'm trying to install a program (the Parallel Ice Sheet Model, or PISM) which uses MPI. I keep running into the errors
libpismutil.so: undefined reference to `ompi_mpi_cxx_op_intercept'
libpismutil.so: undefined reference to `MPI::Datatype::Free()'
libpismutil.so: undefined reference to `MPI::Comm::Comm()'
libpismutil.so: undefined reference to `MPI::Win::Free()'
when linking a CXX executable. I'm sort of stumped as to why this is occurring; the configuration for the program found where all of the MPI executables and libraries are located.
In another thread, someone suggested that this is due to different naming conventions when MPI is built with Fortran or C, but seeing as I have both mpicc.mpich2 and mpif90.mpich2 in my /usr/bin I would think this wouldn't be a problem.
After much consternation, I've found the culprit. The program I'm trying to install uses a library for scientific computation called PETSc; the standard install of PETSc doesn't generate the shared object files needed by PISM, you have to explicitly tell it to make them. Once this was done, PISM installed correctly.
Of course, I was unable to run it because of some other obscure error with openmpi, but that's a story for another thread.

cross compiling qt (linux/mingw -> windows): various undefined references

(Crosspost from here, since nobody seems to have an idea)
Hello everyone,
I am trying to cross compile qt 4.8.3 from my linux for my windows. The final goal is to build a static qt, but independent of building static or not I always get the same error. Playing around with various flags didn't help either:
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x18dc): undefined reference to `QGb18030Codec::QGb18030Codec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x18ef): undefined reference to `QGbkCodec::QGbkCodec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x1902): undefined reference to `QGb2312Codec::QGb2312Codec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x1915): undefined reference to `QEucJpCodec::QEucJpCodec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x1928): undefined reference to `QJisCodec::QJisCodec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x193b): undefined reference to `QSjisCodec::QSjisCodec()'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x1956): undefined reference to `vtable for QEucKrCodec'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x1971): undefined reference to `vtable for QCP949Codec'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x198c): undefined reference to `vtable for QBig5Codec'
./.obj/release-shared/qtextcodec.o:qtextcodec.cpp:(.text+0x19a7): undefined reference to `vtable for QBig5hkscsCodec'
I'm using the default win32-g++ configuration file in combination with mingw.
I googled quite a bit around, but I have still no idea, where this comes from.. Maybe someone of you has the right hint for me ;-)
You could use MXE to build it. It's quite easy. You simply do:
make qt
It does pretty much everything automatically, including downloading sources, applying needed patches to enable cross compiling (which might be why manually cross compiling Qt on your own is failing), and building all dependencies. You can download MXE from: http://mxe.cc. Read the docs of course on how to cross compile software with it.
The gist of it is that instead of qmake you use i686-pc-mingw32-qmake (after you've changed your PATH to include the MXE directory, as per the docs.)
MXE builds everything as static libraries, so when you cross compile a program, you'll get a single .exe file with no depenendies on any DLLs.

Port from gcc 3.3.3 to 4.1.0, C++ templates, undefined reference to

Our application makes use of C++ templates in a number of places. I am currently attempting to port from gcc 3.3.3 to 4.1.0 and am encountering issues. I have recreated the problem in a small shared library and executable. I am building the share library Ok, but the executable fails to link with the following:
undefined reference to `MyNumber<int>::~MyNumber()'
undefined reference to `MyNumber<int>::MyNumber(int)'
undefined reference to `MyNumber<int>::number()'
I am not using the template classes directly within the executable and would have expected this all to be encapsulated within the implementation within the shared library (probably naively so).
The problem only appears to show when working with a shared library. When I build our application on SLES 11 (gcc 4.3.2) most of my issues appear to be resolved but I still receive a number of the following:
undefined reference to `vtable for MYCLASS<T1, T2>'
This all when linking the executable to the shared libs.
It's a painfully obscure message, but it means you didn't define a virtual function, See here
I had a similar problem, and resolved it by implementating functions in the header file, not in a cpp file.
Salu2.
Without knowing more about your source code this is very hard to answer. However asking this particular question on the gcc mailing list may yield better results, as the people who work on gcc know all the intricacies better than everyone else.
Thanks for the comments. I removed the -frepo and -fno-impicit-templates from my compile/link options and was good to go.