I am compiling c++-14 code using std::thread class with mingw w64 (gcc 9.3) and the posix threading model (not win32). The linker links with -lpthread -lwinpthread but I nevertheless get:
undefined reference to `std::thread::_State::~_State()'
undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
undefined reference to `std::thread::detach()'
The host is Ubuntu 20.04 and the MinGW version is the default packaged version (7.0.0); I also tested with backported 8.0.0 (gcc . There does not seem to be a more recent packaged toolchain available, so I did not try an upgrade of mingw (the latest is 9.0.0).
Any hints?
EDIT: I switched to https://github.com/meganz/mingw-std-threads header-only implementation of std::thread and win32 thread model. CLosing the question.
Related
I tried to compile an openCV application for RapsberryPi 2 with Lazarus-IDE(Pascal compiler) on Ubuntu x64 PC.
But, the compiler shows error :
ERROR IMAGE
Pre-compiled openCV library version : 2.4.8
Pre-compiled glibc library version : 2.19
Any idea?
The most likely explanation is that you are trying to link against a glibc version older than 2.15, while the library was compiled against glibc 2.15 or later.
If your target does not support glibc 2.15, you will have to recompile the library instead.
What I have:
I am writing Qt application for Linux (I work in Linx Mint 17.3 64-bit)
I use C++11 features in my Qt project (Qt ver 5.5)
I want to add libslave to my Qt project.
libslave uses deprecated (for C++11) boost::function, boost::shared_ptr, boost::bind and boost::any.
My trouble:
When I compile with gcc (v the whole project or only library with -std=c++11 flag boost crashes with many errors. Qt Creator shows about 4000 errors, but they are pretty similar and look like:
typedef boost::function< void( RecordSet& )> callback;
is not complete type
BOOST_NOEXCEPT'does not name a type
~any() BOOST_NOEXCEPT
etc...
I have tried to rewrite library with C++11 std library, but std does not containg boost::any analog, so that was bad idea.
Question:
How to compile boost (or at least libslave) with c++11?
Boost Version: 1.54 (from repo)
g++ version: 4.8.4 (from repo)
Qt version: 5.5 (downloaded from Official Site)
Linux Mint: 17.3 Rosa
UPDATE:
Example:
You can download code what I try to compile by this link.
Instruction:
Download tarball
Extract
Go to folder and just type make (all works fine)
Open MakeFile and replace CXX variable to
CXX = g++ -std=c++11
Try to make again and you'll get errors.
P.S.
To compile library you'll need libmysqld-dev, libboost-all-dev, libmysqlclient-dev.
Probably you'll need something else, but I don't remeber. Sorry.
I found the hack and it works for me.
I replace boost::bind usage in file nanomysql.h to std::bind by such strings:
...
typedef std::map<std::string, field> value_t;
typedef std::vector< value_t > result_t;
void store(result_t& out)
{
//You need specify template because of push_back has overloads
auto hack = std::bind<void(result_t::*)(const value_t&)>(&result_t::push_back, &out, _1);
use(hack);
}
...
And replace all boost::shared_ptr, boost::function to std::shared_ptr and std::function in all files in library.
After this everything compiles and work fine with -std=c++11 flag.
Whole code of nanomysql.h you can see here:
Link to code
Use actual fork of libslave - https://github.com/vozbu/libslave with support c++11. Support for mysql 5.6 and 5.7 will be soon
Where is the canonical place on Linux to install a library, that was not compiled with the standard system compiler? /us/local/lib or /usr/local/mylib-1.0-gcc.version? Some place else? The same library compiled with the system gcc may be installed and used, too.
Background:
I am on CentOS 6.5. The standard compiler is gcc 4.4. I have a closed source program, that is compiled on CentOS 6.0 with gcc 4.1.2 (strange enough, gcc is also 4.4 there). I want to build a plugin for the program that uses a (open source) library. So I compile gcc 4.1.2 and the library with gcc 4.1.2. Where does the library go?
I try to crosscompile some c++11 source with mingw on linux for windows. The code uses std::thread.
When i compile i always get some errors:
$ ../mingw/cross/bin/i686-w64-mingw32-g++ -std=c++11 -I include/ test.cpp -lstdthread -otest
In file included from test.cpp:4:0:
...
error: 'thread' in namespace 'std' does not name a type
...
I it possible to enable c++11 threads in mingw? The code compiles without any problems with the local g++.
Thank you,
regars
Kevin
-edit-
I just downloaded the mingw somewhere in the internet, because i tried to get an as new as possible version:
../mingw/cross/bin/i686-w64-mingw32-g++ -v
Using built-in specs.
COLLECT_GCC=../mingw/cross/bin/i686-w64-mingw32-g++
COLLECT_LTO_WRAPPER=/home/bmeier/source/mingw/cross/bin/../libexec/gcc/i686-w64-mingw32/4.8.1/lto-wrapper
Target: i686-w64-mingw32
Configured with: /home/drangon/work/mingw-w64-dgn_32/source/gcc-4.8.1/configure --target=i686-w64-mingw32 --disable-nls --disable-multilib --with-gmp=/home/drangon/work/mingw-w64-dgn_32/build/for_cross --with-mpfr=/home/drangon/work/mingw-w64-dgn_32/build/for_cross --with-mpc=/home/drangon/work/mingw-w64-dgn_32/build/for_cross --with-isl=/home/drangon/work/mingw-w64-dgn_32/build/for_cross --with-cloog=/home/drangon/work/mingw-w64-dgn_32/build/for_cross --enable-languages=c,c++,objc,obj-c++ --disable-libstdcxx-pch --prefix=/home/drangon/work/mingw-w64-dgn_32/cross --with-sysroot=/home/drangon/work/mingw-w64-dgn_32/cross
Thread model: win32
gcc version 4.8.1 (GCC)
regards
Kevin
There is already a native implementation of std::thread and sync primitives, that works with any C++11 version of MinGW:
https://github.com/meganz/mingw-std-threads
Basically MinGW does not support threads on windows see the following link: http://www.cplusplus.com/forum/windows/82461/
Specifically _GLIBCXX_HAS_GTHREADS is not defined and the class thread in the header thread requires it. (It is built on gthreads).
You should try and use boost::thread for a win/linux compatible thread class
Most probably you might have forgot to include thread header #include <thread>
We have linked PHP Code with C++ code using PHP Extension code (written in C++ only)... which all were working fine in 32bit OS.
Now we changed the version of many s/w as the OS version is changed to 64bit. We Compiled the C++ code which was previously running fine using 64bit gcc to 32bit ".so" file it shown many errors and we cleared all those and finally compiled successfully. But during linking with PHP it's showing:
undefined symbol: _ZTV5Temps" error
Use c++filt to demangle the name:
$ c++filt -n _ZTV5Temps
vtable for Temps
My guess (given the lack of context) is you have a reference to Temps (class) in a module that has not been recompiled/relinked.