ofTheo / ofxKinect

legacy openFrameworks wrapper for the xbox kinect (OF pre-0.8.0+ only) - ofxKinect is now included and is being maintained in OF releases
MIT License
540 stars 105 forks source link

Pthread and Codeblocks 12 on windows (0.7.4) #126

Closed gorkacortazar closed 11 years ago

gorkacortazar commented 11 years ago

With a clean install, example project doesn't compile, because is unable to fin pthread library in the linker phase (ofx 0.7.4).

I didn't notice at first, because BC 10.05 seem to include it in the MinGW.

To solve the issue, you have to manaually do the followig steps:

1) download the compiled version: http://www.sourceware.org/pthreads-win32/index.html

2) rename the file Pre-built.2\lib\x86\libpthreadGC2.a to libpthread.a

3) Copy it in the MinGW folder for your codeblocks installation C:\Program Files (x86)\CodeBlocks\MinGW\lib

danomatika commented 11 years ago

That's weird. I have CB 12.11 installed and it worked fine ...

tecnecollective commented 11 years ago

Yep, was weird, when 0.7.4 came out I installed over CB 10 and worked without problems. But last week with a fresh install (new machine), this issue happened at the same time to me in Madrid and to my partner in Miami; both widows 7, fresh installs without no CB installed previously.

danomatika commented 11 years ago

Did you follow the "Add files to MinGW" step in the CodeBlocks 12.11 setup for OF guide?

gorkacortazar commented 11 years ago

Yep we did it, all the examples compiled without problems. In reviewd the zip file and libpthread.a is not int he zip file.

I just did this in my testing machine, again: 1) Completely uninstall Codeblocks (including deleting the data in the $user\Roaming\codeblocks) folder. 2) download codeblocks 12 from the site, with mingw 3) Install it with the statndar option 8as told in the setup guide) 3) download ofx 074 from the site ofx site 4) Add the codeblocks aditions for ofx

Same error.

Digging deeper, if you comment the pthread call in the linker options in the win cbp file, the example compiles and works (receive data from the kinect), but crash on the exit process. The rest of the thread related examples works fine on my testing machine.

danomatika commented 11 years ago

Which version of ofxKinect are you using? The latest master is tested with OF 0.8.0 which hasn't been released yet.

danomatika commented 11 years ago

@ofTheo & @kylemcdonald Can you guys double check that the ofxKinect example build/run in Win CodeClocks & VS? I want to be sure it's really working and not just on my machine ...

gorkacortazar commented 11 years ago

I am using the 0.7.4 tag. Also for you, the 0.7.1 tag example doesn't work (wrong naming in poco and opencv linkers), against the ofx 071 tag.

gorkacortazar commented 11 years ago

Also try to check with a clean installation, worked for me before when I installed CB 12 over CB 10 (cb 10 mingw seem to include pthread)

danomatika commented 11 years ago

@ofZach Perhaps the best solution is to add pthread-win32 to the CB 12.11 includes/libs download? I'm hesitant to add pthread to this project, when other CB-build libs on Win will require it.

danomatika commented 11 years ago

Ok. So we can safely say this is a CB 12.11 related issue as it worked fine with CB 10.5 before. I think I didn't notice anything since I upgraded CB on the dev machine and pthread must have stuck around.

danomatika commented 11 years ago

the 0.7.1 tag example doesn't work (wrong naming in poco and opencv >linkers), against the ofx 071 tag.

Well it shouldn't work with 0.7.4 anyway. I'm assuming you didn't try it with OF 0.7.1 ...

gorkacortazar commented 11 years ago

c'mon no, I may filed as a sepparate issue, just for compatibility... 071 ofx tag and 071 ofxkinec tagt CB example (windows) example are using a different opencv and poco version (different names).

The main issue is with ofx 0.7.4 and ofxkinect tag, sorry for being confusing with the second issue.

arturoc commented 11 years ago

gorka, just to be sure can you try the kinectExample in examples/addons with the latest nightly build:

http://www.openframeworks.cc/nightlybuilds.html

tecnecollective commented 11 years ago

Arturo, I just saw your message this morning, I'll do it in the afternoon when I arrive home.

gorkacortazar commented 11 years ago

Arturo:

The kinect example in the nightly build works without problems. I completely uninstalled CB 12, and installed again, added codeblocks addition and compiled the kinect example without problem, so the error is only in the 0.7.4 version of the example.

Taking a closer look at the cbp file there is no reference to pthreads in the example linker area. Are you using a different threading library in 0.8.0? I also checked and libpthreads.a is not currently in my mingw install inside codeblocks, but the example works.

danomatika commented 11 years ago

That's what I was thinking. I originally added pthread to the project to get it to build but later removed it because it didn't seem to need it.

The difference is that prior to the current build, freenect is precompiled. Now we build it from source in VS and win CB using a newer version of freenect that doesn't need pthread.

It's safe to say, then, that you need to manually add pthread for 0.7.4 if you're using CB 12.11, but all previous versions will work fine with CB 10.05. I think the best solution is to put a note in the readme about adding it for 0.7.4 or include pthread with the CB include/lib addons download.

danomatika commented 11 years ago

As you can see here: https://github.com/OpenKinect/libfreenect/blob/master/platform/windows/libusb10emu/libusb-1.0/libusbemu_threads_win32.h

Threading is handled using the native Win api in the libusb wrapper on windows.

The precompiled freenect libs that come with earlier versions of ofxKinect rely on pthread which was included with CB 10.5. Somehow that fell through the cracks, probably because most people hadn't updated to 12.11 yet.

gorkacortazar commented 11 years ago

My opinion is that putting a note in the readme is enough, as you aren't using pthreads anywhere else in ofx, and the problem only affects a particular version combination. I posted a note in the ofx forum (in the extend section), but maybe will be better to move it to the codeblocks windows section.

danomatika commented 11 years ago

Thanks for double checking guys.

danomatika commented 11 years ago

Ok. I'm adding info on this with your steps to fix it to the readme. Thanks.