Linker cannot find boost::thread references - c++

Background:
I'm porting an huge project to a new toolchain (from gcc 4.7.0 to gcc 8.2.0 and from boost 1.55 to boost 1.68). The whole SDK is generated by Yocto. There are several libraries and applications, all built with cmake.
The problem:
All the libraries just build and link fine, meanwhile some of the applications that use boost::thread does not link properly. Following an example:
The cmake generated command:
cd /home/italia.priv.org/user/workspace-mk5/git/build/apps/ConfigMngr && /opt/cmake-3.13.0-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/ConfigMngr.dir/link.txt --verbose=1
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot=/opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi --std=c++11 -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -fpermissive -O3 -DNDEBUG -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed CMakeFiles/ConfigMngr.dir/src/AppConfig.cpp.o CMakeFiles/ConfigMngr.dir/src/AppMain.cpp.o CMakeFiles/ConfigMngr.dir/src/AppStates.cpp.o CMakeFiles/ConfigMngr.dir/src/ConfigMngr.cpp.o CMakeFiles/ConfigMngr.dir/src/dbus_server/ConfigMngrServerApi.cpp.o -o ConfigMngr -Wl,-rpath,/home/italia.priv.org/user/workspace-mk5/git/targetfs/lib_priv/lib_arm: /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_chrono-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_date_time-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_filesystem-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_system-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_serialization-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_thread-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_timer-mt.so ../../../targetfs/lib_priv/lib_arm/libxxx_autocheck.so ../../../targetfs/lib_priv/lib_arm/libxxx_config.so ../../../targetfs/lib_priv/lib_arm/libxxx_dbusapi.a ../../../targetfs/lib_priv/lib_arm/libxxx_hwifc.a ../../../targetfs/lib_priv/lib_arm/libxxx_log.so ../../../targetfs/lib_priv/lib_arm/libxxx_utils.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libdbus-cxx.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libsigc-2.0.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libodb.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libodb-sqlite.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libodb-boost.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libsqlite3.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libdbus-1.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_date_time-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_atomic-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_chrono-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_filesystem-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_system-mt.so ../../../targetfs/lib_priv/lib_arm/libxxx_core.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libgtest.a -pthread
As you can see in bold libboost_thread is passed to the linker (it is a link to the actual lib). The command above outputs:
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::this_thread::interruption_point()'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::thread::native_handle()'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::thread::do_try_join_until_noexcept(boost::detail::mono_platform_timepoint const&, bool&)'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'typeinfo for boost::detail::thread_data_base'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::detail::get_current_thread_data()'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::this_thread::interruption_requested()'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::detail::thread_data_base::~thread_data_base()'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::thread::detach()'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::chrono::steady_clock::now()'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::thread::join_noexcept()'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::thread::interrupt()'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'boost::thread::start_thread_noexcept()'
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'vtable for boost::detail::thread_data_base'
Looking at the symbols exported by libxxx_core and grepping for one of the undefined reference:
nm -DC libxxx_core.so | grep thread::native_handle
U boost::thread::native_handle()
U => The symbol is undefined.
Then looking for the same symbol in libboost_thread:
nm -DC libboost_thread.so.1.68.0 | grep native_handle
0000c3b1 T boost::thread::native_handle()
T => The symbol is in the text (code) section.
So the linker should be able to solve this dependency (and the others).
What we have tried
Reordering the libraries (libxx_core before and after libboost_thread)
Checking each symbols that is not resolved
Tried different enviroments
Among the undefined reference, the last error given by the linker is
/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so: undefined reference to 'vtable for boost::detail::thread_data_base'
Probably there is something related to undefined references. I'm working on it too.
The question
Any idea about what could cause these errors or a suggestion on how to debug this behavior properly?
Thanks,
Gabriele

Related

Unable to link with undefined reference to VTT for CryptoPP::RSAFunction

I'm using Crypto++ on aarch64, I'm facing a problem when compiling my binary which use cryptopp-7.0.0, the only link problem I face is related to RSAFunction, all the other classes worked perfectly, here is the program itself which is really a basic one that isolate the problem:
#include "cryptopp/rsa.h"
using CryptoPP::RSA;
#include <string.h>
using std::string;
#include <unistd.h>
int main(void)
{
RSA::PublicKey publicKey;
return 0;
}
When trying to compile with this command:
~$ toolchain/bin/aarch64-libreelec-linux-gnueabi-g++ cryptopptestfile.cpp -o crypttest -L/toolchain/usr/lib -lcryptopp
I got those errors:
<artificial>:(.text+0xe7c): undefined reference to `vtable for CryptoPP::RSAFunction'
<artificial>:(.text+0xe80): undefined reference to `vtable for CryptoPP::RSAFunction'
<artificial>:(.text+0xea8): undefined reference to `VTT for CryptoPP::RSAFunction'
<artificial>:(.text+0xeb4): undefined reference to `VTT for CryptoPP::RSAFunction'
/tmp/ccs498WJ.ltrans0.ltrans.o: In function `CryptoPP::InvertibleRSAFunction::~InvertibleRSAFunction()':
<artificial>:(.text+0x10c0): undefined reference to `vtable for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x10c4): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x10c8): undefined reference to `vtable for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x112c): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
/tmp/ccs498WJ.ltrans0.ltrans.o: In function `CryptoPP::InvertibleRSAFunction::InvertibleRSAFunction()':
<artificial>:(.text+0x12e4): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x12f8): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x1324): undefined reference to `vtable for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x132c): undefined reference to `vtable for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x13cc): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
<artificial>:(.text+0x13dc): undefined reference to `VTT for CryptoPP::InvertibleRSAFunction'
This is only related to :
cryptopp::RSAFunction(s)
Thanks for help.
Here is the compilation flags:
arch64-libreelec-linux-gnueabi-g++ -march=armv8-a+crc+fp+simd -mabi=lp64 -Wno-psabi -mcpu=cortex-a53+crc+fp+simd -fomit-frame-pointer -Wall -pipe -Os -flto -ffat-lto-objects -fPIC -pipe -c rsa.cpp
g++ version:
6.2.0
Issue identified, it is because of this compilation flag :
-flto
As soon as I remove this compiling flag, everything works normal, please note that activating this flag which is:
-flto:
This option runs the standard link-time optimizer. When invoked with
source code, it generates GIMPLE (one of GCC’s internal representations)
and writes it to special ELF sections in the object file. When the object
files are linked together, all the function bodies are read from these ELF
sections and instantiated as if they had been part of the same translation
unit.
This flag breaks the linker when using RSAFunction(s), tested from version 6.0.0 to 8.0.0

Can't link C++ project with openssl static libraries

I have some project done on C++ and I need to compile it for Windows XP and later.
This is the header file of my RsaEncryptor class (I think it is no matter to post sources here, because I'm sure on 100% that it works fine, but if it is required I can do it):
#ifndef RSAENCRYPTOR_H_
#define RSAENCRYPTOR_H_
#include <stdexcept>
#include <openssl/rsa.h>
#include <openssl/engine.h>
#include <openssl/pem.h>
// One of this paddings can be used
//#define PADDING RSA_PKCS1_OAEP_PADDING
#define PADDING RSA_PKCS1_PADDING
//#define PADDING RSA_NO_PADDING
class RsaEncryptor {
private:
RSA* publicKey;
RSA* privateKey;
public:
RsaEncryptor() {
publicKey = nullptr;
privateKey = nullptr;
}
~RsaEncryptor() {
if ( this->publicKey )
RSA_free( this->publicKey );
if ( this->privateKey )
RSA_free( this->privateKey );
}
size_t GetCipherBytesCount() {
return 172; //is default for 1024 bit key length
}
void SetPublicKeyFromString(const std::string& content);
void SetPrivateKeyFromString(const std::string& content);
std::string Encrypt(const std::string& plainData);
std::string Decrypt(const std::string& cipherData);
};
#endif /* RSAENCRYPTOR_H_ */
I use latest version of Eclipse Neon for C++ development on Windows 10 x64 machine.
Also I have read this:
(...) you will need to configure with no-async when building OpenSSL 1.1.0 and above for Windows XP or Vista
And I was guided by following instructions.
What did I do:
install Ubuntu 17.04 x64 inside Virtual Box under Windows 10 x64.
download latest version of OpenSSL library from Ubuntu
install mxe and all requirements (but can't compile with it and I decide to use mingw32)
install mingw32 via root#user-pc:/home/user# apt-get install gcc-mingw-w64-i686
unpack OpenSSL library in /home/user/openssl-x32
go to /home/user/openssl-x32
run ./Configure mingw --cross-compile-prefix=i686-w64-mingw32 --prefix=/home/user/builds/openssl-x32-static no-shared no-async
run make
run make install
copy libssl.a and libcrypto.a from /home/user/builds/openssl-x32-static/lib to host machine (Windows 10 x64) to folder E:\MyProjects\my-app\libraries\
copy include directory from Ubuntu to host machine in folder E:\MyProjects\my-app\include
Add libraries folder to linker configurations
Add include folder to compiler configurations
Then, I build my project and got following answer:
11:58:09 **** Rebuild of configuration Debug for project app ****
Info: Configuration "Debug" uses tool-chain "MinGW GCC" that is
unsupported on this system, attempting to build anyway. Info: Internal
Builder is used for build g++
"-IC:\MyProjects\my-app\include" -O0 -g3
-Wall -c -std=c++11 -m32 -o RsaEncryptor.o "..\RsaEncryptor.cpp" g++ "-IC:\MyProjects\my-app\include" -O0 -g3
-Wall -c -std=c++11 -m32 -o main.o "..\main.cpp" In file included from ..\main.cpp:5:0: ..\FilesFinder.h: In member function 'void
FilesFinder::FindRecursively(const string&, const FilesFilter&)':
..\FilesFinder.h:90:56: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
while (destinationContainer.GetElementsCount() >= MAX_ELEMENTS_COUNT) {
^ g++ "-IC:\MyProjects\my-app\include" -O0 -g3
-Wall -c -std=c++11 -m32 -o aes256.o "..\aes256.cpp" g++ "-LC:\MyProjects\my-app\libraries"
-static-libgcc -static-libstdc++ -static -lpthread -m32 -o C:/MyProjects/my-app/bin/Debug/app
RsaEncryptor.o aes256.o main.o -lssl -lcrypto -lgdi32
C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xaa):
undefined reference to _imp__getnameinfo#28'
C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xe0):
undefined reference to_imp__ntohs#4'
C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0x242):
undefined reference to gai_strerrorW'
C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0x820):
undefined reference to_imp__freeaddrinfo#4'
C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xb5d):
undefined reference to _imp__getaddrinfo#16'
C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xba2):
undefined reference togai_strerrorW'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xd7):
undefined reference to _imp__WSAStartup#8'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xe8):
undefined reference to_imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x2c7):
undefined reference to _imp__WSAStartup#8'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x2d8):
undefined reference to_imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x3b1):
undefined reference to _imp__ntohs#4'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x40c):
undefined reference to_imp__getsockopt#20'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x423):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x43c):
undefined reference to_imp__gethostbyname#4'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x48b):
undefined reference to _imp__WSAStartup#8'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x4a2):
undefined reference to_imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x52c):
undefined reference to _imp__WSACleanup#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x54d):
undefined reference to_imp__ioctlsocket#12'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x563):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x6b7):
undefined reference to_imp__WSAStartup#8'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x6c8):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x942):
undefined reference to_imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x9dc):
undefined reference to _imp__setsockopt#20'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xa15):
undefined reference to_imp__ioctlsocket#12'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xa32):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xaa6):
undefined reference to_imp__getsockname#12'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xb22):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x27):
undefined reference to_imp__socket#12'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x4e):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x120):
undefined reference to_imp__setsockopt#20'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x15b):
undefined reference to _imp__connect#12'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x1f5):
undefined reference to_imp__setsockopt#20'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x206):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x265):
undefined reference to_imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x2c6):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x377):
undefined reference to_imp__getsockopt#20'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x38f):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x4a7):
undefined reference to_imp__setsockopt#20'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x4b4):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x53a):
undefined reference to_imp__bind#12'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x55f):
undefined reference to _imp__listen#8'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x5a5):
undefined reference to_imp__setsockopt#20'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x5b6):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x63a):
undefined reference to_imp__setsockopt#20'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x64b):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x6b2):
undefined reference to_imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x713):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x7a6):
undefined reference to_imp__accept#12'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x7e7):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x84b):
undefined reference to_imp__closesocket#4'
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x86c):
undefined reference to _imp__closesocket#4'
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x1b1):
undefined reference to_imp__WSASetLastError#4'
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x1d0):
undefined reference to _imp__send#16'
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x20a):
undefined reference to_imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x272):
undefined reference to _imp__WSASetLastError#4'
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x299):
undefined reference to_imp__send#16'
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x2ca):
undefined reference to _imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x33d):
undefined reference to_imp__WSASetLastError#4'
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x360):
undefined reference to _imp__recv#16'
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x39a):
undefined reference to_imp__WSAGetLastError#0'
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x457):
undefined reference to _imp__WSAGetLastError#0'
c:/programs/mingw_w64_mingw32_gcc_stdthread_win32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld.exe:
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):
bad reloc address 0x24 in section.rdata'
c:/programs/mingw_w64_mingw32_gcc_stdthread_win32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld.exe:
final link failed: Invalid operation collect2.exe: error: ld returned
1 exit status
11:58:21 Build Finished (took 11s.567ms)
I need just link my completed C++ project with correct-compiled (with flag no-async) OpenSSL library to let it work under old versions of Windows.
I will be happy to get any help with this issue.
Most if not all of the undefined symbols in your error log come from Winsock. Try linking with -lws2_32.

Why `sqlpp-mysql` is not properlly linking?

I am trying to establish database connection using sqlpp-connector-mysql. After building this project when i am trying to run SampleTest.cpp it produce error saying
$ g++ -std=c++1y -lsqlpp-mysql SampleTest.cpp
SampleTest.cpp:(.text+0x12f): undefined reference to `sqlpp::mysql::connection::connection(std::shared_ptr<sqlpp::mysql::connection_config> const&)'
SampleTest.cpp:(.text+0x13e): undefined reference to `sqlpp::mysql::connection::~connection()'
SampleTest.cpp:(.text+0x157): undefined reference to `sqlpp::mysql::connection::connection(std::shared_ptr<sqlpp::mysql::connection_config> const&)'
SampleTest.cpp:(.text+0x19d): undefined reference to `sqlpp::mysql::connection::execute(std::string const&)'
SampleTest.cpp:(.text+0x201): undefined reference to `sqlpp::mysql::connection::execute(std::string const&)'
SampleTest.cpp:(.text+0x265): undefined reference to `sqlpp::mysql::connection::execute(std::string const&)'
SampleTest.cpp:(.text+0x2c9): undefined reference to `sqlpp::mysql::connection::execute(std::string const&)'
I think, sqlpp-mysql is not linking properly. Can someone give me some pointer, how to resolve this problem ?
P.S : I have build the requirements.
sqlpp11
date library
I build the both sqlpp11 and sqlpp11-connector-mysql like this
$ cd project_dir
$ cmake CmakeList.txt
$ sudo make install
I needed to link the library properly.
g++ -std=c++11 tests/SampleTest.cpp -I ../../sqlpp11/include -I . -I ../../date -lsqlpp-mysql -lmysqlclient

Unable to link to GraphicsMagik

I'm trying to build a little utility program that relies upon GraphicsMagick C++ library but I got the following error when linking to the library:
make all-recursive
make[1]: Entering directory `/home/ale/sample'
Making all in src
make[2]: Entering directory `/home/ale/sample/src'
g++ -g -O2 -o mysample mysample-a.o -L/usr/local/lib -lexiv2 -L/usr/local/lib -lGraphicsMagick++ -lGraphicsMagick
/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-png.o): In function `png_put_data':
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1171: undefined reference to `png_get_io_ptr'
/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-png.o): In function `PNGWarningHandler':
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1357: undefined reference to `png_error'
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1361: undefined reference to `png_get_error_ptr'
/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-png.o): In function `PNGErrorHandler':
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1338: undefined reference to `png_get_error_ptr'
/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-png.o): In function `png_get_data':
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1060: undefined reference to `png_get_io_ptr'
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1076: undefined reference to `png_warning'
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1077: undefined reference to `png_error'
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1067: undefined reference to `png_warning'
/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-png.o): In function `png_write_raw_profile':
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6243: undefined reference to `png_malloc'
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6253: undefined reference to `png_malloc'
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6254: undefined reference to `png_malloc'
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6281: undefined reference to `png_set_text'
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6282: undefined reference to `png_free'
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6283: undefined reference to `png_free'
Why does the library in /usr/local/lib refers to GraphicsMagick source code (that I've built and installed)?
Errors says that you need to link with libpng too.
You having very descriptive source-code related errors because you've built graphicsmagick with debugging symbols. In release build (or if you'll strip debugging symbols out of debug build) you'll see only undefined function names, without source code references of where they're being used.

Boost static linking issue with G++

I have an application, with dynamic linking all ok, but when i trying to compile with static linking, i have errors below.
My app uses boost thread, asio
Error:
/tmp/ccMj2fHI.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x237): undefined reference to `boost::system::get_system_category()'
test.cpp:(.text+0x243): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x24f): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x25b): undefined reference to `boost::system::get_generic_category()'
test.cpp:(.text+0x267): undefined reference to `boost::system::get_system_category()'
/tmp/ccnCWj1O.o: In function `__static_initialization_and_destruction_0(int, int)':
AccountSe.cpp:(.text+0x507): undefined reference to `boost::system::get_system_category()'
AccountSe.cpp:(.text+0x513): undefined reference to `boost::system::get_generic_category()'
AccountSe.cpp:(.text+0x51f): undefined reference to `boost::system::get_generic_category()'
AccountSe.cpp:(.text+0x52b): undefined reference to `boost::system::get_generic_category()'
AccountSe.cpp:(.text+0x537): undefined reference to `boost::system::get_system_category()'
And similar errors for all source files.
Compile command line:
g++ -L /usr/lib/ -lboost_system -lboost_thread -o newserver -static
/usr/lib/libboost_thread.a /usr/lib/libboost_system.a stdafx.cpp
test.cpp AccountSe.cpp ... -lpthread -std=c++0x
It mostly likely is due to your linking order. Boost libraries appear first in the command line, and after processing them, the linker, will discard unreferenced symbols before proceeding to link other object files and libraries.
Put boost libraries after your sources and before -lpthread.