Obscure changes in Ubuntu 11.10

I came to resurrect a year old project last week, which previously worked fine, under Ubuntu 11.10. BOOM! nothing works. The project is a CLI TCP server to control a USB opendmx widget using FTD2XX with an Android app client.

First a random g++ fail.

g++ -I. -lpthread -lstdc++ -lftd2xx  *.cpp -o opendmxserver
DmxTransmit.cpp:(.text+0x38): undefined reference to `FT_ListDevices'
DmxTransmit.cpp:(.text+0xdb): undefined reference to `FT_Open'
/tmp/cccTckgn.o: In function `Mutex::Mutex()':
Mutex.cpp:(.text+0x1e): undefined reference to `pthread_mutexattr_init'
/tmp/ccs5TdOM.o: In function `System::currentTimeMillis()':
System.cpp:(.text+0x15): undefined reference to `clock_gettime'
/tmp/ccCEDMng.o: In function `Thread::start()':
Thread.cpp:(.text+0x6c): undefined reference to `pthread_create'

So what’s that all about, well it turns out now you have to put the linker switches after the *.cpp. So this works.

g++ -I. *.cpp -o opendmxserver -lpthread -lstdc++ -lftd2xx 

Next fail. Runtime weirdness, assert fail.

opendmxserver: tpp.c:63: __pthread_tpp_change_priority: Assertion `new_prio == -1 || (new_prio >= __sched_fifo_min_prio && new_prio <= __sched_fifo_max_prio)' failed.

YFKM, it turns out that out that you need to call pthread_mutexattr_init on the pthread_muxexattr_t structure. This did not used to be the case, although it makes sense to initialize all your structs…

pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr); // not previously required                     
pthread_mutex_init (&this->mutex, &attr);
Categorized as geek

Leave a comment

Your email address will not be published.