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
Related
Is it possible to Link *.lib files with MinGW (I use it with Eclipse)?
I'm fighting with libcurl+OpenSSL and I don't understand if my errors are because I try to use .lib-files in MinGW or something else is wrong:
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0xb): undefined reference to `__security_cookie'
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0x63): undefined reference to `#__security_check_cookie#4'
..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0x19e): undefined reference to `#__security_check_cookie#4'
..\lib/libeay32.lib(tmp32/ech_ossl.obj):(.text[_ecdh_compute_key]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_asn1_bio_set_ex]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_asn1_bio_get_ex]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_BIO_asn1_set_prefix]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_BIO_asn1_get_prefix]+0x6): undefined reference to `_chkstk'
..\lib/libeay32.lib(tmp32/bio_asn1.obj):(.text[_BIO_asn1_set_suffix]+0x6): more undefined references to `_chkstk' follow
..\lib/ssleay32.lib(tmp32/ssl_lib.obj):(.text[_SSL_has_matching_session_id]+0xb): undefined reference to `__security_cookie'
mingw also accepts libraries with a .lib extension.
For instance, a library named
libsample.lib
must be linked as
-L -llibsample
Reference:
http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use
New mingw versions support linking lib files. But I faced issues where .lib is with prefix libxxxx.lib.It ommits the preffix lib in linking. So make it like lib<name>.lib
Also there are ways to convert a .lib to .a ex: lib2a
You can use that as well.
Probably not. mingw's static library format is *.a.
Dynamic libraries for a given platform are standardized by the OS loader that must be able to load them.
Static libraries only have to be understood by the toolchain's linker, and are thus less cross compiler compatible. Afaik *.lib files are not even compatible across all MSVC versions.
Added later due to pestering comments:
Newer versions of mingw also support .lib files, but you asked your question back in '11, and then you probably wouldn't have them then.
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.
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.
(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.
Recently I have asked a question about what I should use to create self-contained executables that would be deployed under a number of Linux distribution. I got very scared at first, but after reading about C++ a little, I managed to get the first version of my executable going.
After a day full of joy, I just hit the wall again with another dilemma. The resulting executable must be installed in a number of Linux distributions (Slackware, Arch, Ubuntu, Debian, CentOS and a few more), and I am completely clueless on how to achieve it. All I know CentOS and Debian-based OSes has package managers, like apt or yum, but I am not sure those apply to my case.
The code I wrote depends on a couple of libraries (more specifically RudeSocket and yaml-cpp. I have been told that I would be able to compile the executable and link it dynamically, so I just needed to distribute the executable.
It happens that I could not find the .a file for the yaml-cpp library (just for RudeSocket). And here's my problem so far:
At first, I went with dynamic linking but (obviously) when I copied the executable to another box:
$ ./main
./main: error while loading shared libraries: libyaml-cpp.so.0.2: cannot open shared object file: No such file or directory
When trying to compile it statically, I get an error too (because I don't have the yaml-cpp .a file as I mentioned):
$ g++ main.cpp parse.cpp parse.h rudesocket-1.3.0/.libs/librudesocket.a -o main -static -L/usr/local/librudesocket-1.3.0/.libs/librudesocket.a(socket_connect_normal.o): In function `rude::sckt::Socket_Connect_Normal::simpleConnect(int&, char const*, int)':
/root/webbyget/sockets/rudesocket-1.3.0/src/socket_connect_normal.cpp:250: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/cc3cEVK1.o: In function `operator>>(YAML::Node const&, Job&)':
parse.cpp:(.text+0x1a83): undefined reference to `YAML::Node::size() const'
/tmp/cc3cEVK1.o: In function `handle_job(rude::Socket, char const*)':
parse.cpp:(.text+0x1b79): undefined reference to `YAML::Parser::Parser(std::basic_istream<char, std::char_traits<char> >&)'
parse.cpp:(.text+0x1bfd): undefined reference to `YAML::Node::Node()'
parse.cpp:(.text+0x1c10): undefined reference to `YAML::Parser::GetNextDocument(YAML::Node&)'
parse.cpp:(.text+0x1dc6): undefined reference to `YAML::Node::size() const'
parse.cpp:(.text+0x1dee): undefined reference to `YAML::Node::~Node()'
parse.cpp:(.text+0x1e18): undefined reference to `YAML::Node::~Node()'
parse.cpp:(.text+0x1e37): undefined reference to `YAML::Parser::~Parser()'
parse.cpp:(.text+0x1e61): undefined reference to `YAML::Parser::~Parser()'
(...)
It's pretty obvious to me that g++ cannot compile it statically without telling it where to find the classes for yaml-cpp.
It is very important that the installation should happen without human interaction, in an automated fashion.
So my question is really twofold:
how can I distribute this compiled program in the least complex way targeting all those distributions?
is there any de facto standard solution for this kind of problem?
Thank you in advance,
Felipe.
You might give this technique a try.
There are many de-facto standards, but none of them are standardized. :( If you want to distribute a compiled binary, you will probably want to make a package for each platform you want to target. Generating an rpm and a deb will probably get you 90% of the way. If you want to automate the build process, autoconf/automake is still (probably) the best way to go.
Maybe The best solution for you is to use CMake.
CMake is cross-platform, open-source build system. It is a family of tools designed to build, test and package software. For Packaging, Mgb is right, CMake can easily be coupled with CPack.
KDE is using this solution and its a very good alternative to automake/autoconf.
If you use the platforms package manager (.rpm or .deb) the system will check for the correct version of the shared library for you and download it if it is needed.
CPack is probably the easiest package generator