Hello,
I tried to create a very simple application that uses cxx::Thread, but I have some link problems: ... Compiling main.o ==> Linking test_cxx_thread main.o:(.rodata._ZTI10TestThread[_ZTI10TestThread]+0x8): undefined reference to `typeinfo for cxx::Thread'
Also I think it will be cleaner/better for developers if run, execute and shutdown methods will be moved to a protected section.
This is the main.cc content: /////////////////////////////////////////////// #include <iostream> #include <l4/cxx/thread> #include <thread>
class TestThread : public cxx::Thread { public: TestThread():cxx::Thread(true){} private: virtual void run() { std::cout << "TestThread" << std::endl; } };
static void TestStdThread(int param) { std::cout << "TestStdThread param:" << param << std::endl; }
int main(int argc, char ** argv) { (void)argc; (void)argv; TestThread cxxTh; cxxTh.start(); std::thread stdTh(TestStdThread, 1); for (;;) { std::cout << "Hello World!" << std::endl; sleep( 1 ); } stdTh.join(); } ///////////////////////////////////////////////
This is the Makefile content: #################################### PKGDIR ?= ../.. L4DIR ?= $(PKGDIR)/../..
TARGET = test_cxx_thread SRC_CC = main.cc
CXXFLAGS += -std=c++11 REQUIRES_LIBS = cxx_thread cxx_libc_io cxx_io libstdc++ libpthread include $(L4DIR)/mk/prog.mk ####################################
Yours, BogDan.
Am 02.06.2013 10:29, schrieb BogDan:
Hello,
I tried to create a very simple application that uses cxx::Thread, but I have some link problems: ... Compiling main.o ==> Linking test_cxx_thread main.o:(.rodata._ZTI10TestThread[_ZTI10TestThread]+0x8): undefined reference to `typeinfo for cxx::Thread'
Note, cxx::thread != std::thread.
How about simply using pthread_create() and co?
Also, the next release of L4Re is supposed to add support for C++11's std::thread. It's unfortunately broken right now due to tooling issues.
Bjoern
Hello,
I tried to create a very simple application that uses cxx::Thread, but I
have some link problems:
... Compiling main.o ==> Linking test_cxx_thread main.o:(.rodata._ZTI10TestThread[_ZTI10TestThread]+0x8): undefined
reference to `typeinfo for cxx::Thread'
Note, cxx::thread != std::thread.
I know :) I added std::thread as a working example, sorry for confusion.
How about simply using pthread_create() and co?
Now I'm using std::thread, but before that I tried to use cxx::thread, and I thought that you may want to know that is not working anymore ;-). cxx::thread (also std::thread) is more convenient for c++ apps.
Also, the next release of L4Re is supposed to add support for C++11's std::thread. It's unfortunately broken right now due to tooling issues.
std::thread works just fine for me :) !
BogDan.
l4-hackers@os.inf.tu-dresden.de