Computer Science Canada Compiling Open Source Projects |
Author: | mirhagk [ Fri Nov 12, 2010 11:53 pm ] |
Post subject: | Compiling Open Source Projects |
I have never really used C before, I've used C++ and C# and everything, but it's always been with the clean microsoft way of handling things, rather than open source, cross platform ways. Now I found an open source project I really want to check out, and utilize possibly. I have no idea how to compile it however. Attached is a copy of the source code downloaded from the site. It has four folders: examples-includes glview.c (im assuming main code), and a cmakelist.txt include- includes libfreenect.h (the header file for the libraries, im assuming) lib- includes cameras.c and cameras.h (the library code im assuming) cmakelists.txt, geninits.py, inits.txt Modules- FindUSB.cmake, LibFindMacros.cmake (external libraries it depends on maybe??) and then it also has a cmakelist.txt, the readme.txt and .gitignore My question is.... What do I do? I've tried just creating a project with these files but i dont think im doing it right, i think its trying to get a library from the FindUSB.cmake... I dunno. Just so you all know I'm doing this on windows, and I would prefer doing it the clean way with projects and an IDE rather than notepad and command prompt, however I can do that if I absolutely have to. Any help at all you could input would be amazing. (btw the project is an interface for the Xbox 360's Kinect to run on PC) :edit I'm using Visual C++ 2008, that shouldn't be a problem right? |
Author: | TheGuardian001 [ Sat Nov 13, 2010 12:19 am ] |
Post subject: | Re: Compiling Open Source Projects |
From the looks of it, they used CMake so you can use whatever toolchain you want. Download CMake, run it in the project directory, and select your toolchain (In your case Visual C++.) CMake will generate the relevant project files so you should be able to build normally. |
Author: | mirhagk [ Sat Nov 13, 2010 12:48 am ] |
Post subject: | RE:Compiling Open Source Projects |
thank you I got cmake, got it working with C++ visual 2008, but now I get the following error: USB_INCLUDE_DIR=USB_INCLUDE_DIR-NOTFOUND USB_LIBRARY=USB_LIBRARY-NOTFOUND CMake Error at Modules/LibFindMacros.cmake:74 (message): Required library USB NOT FOUND. Install the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually. Call Stack (most recent call first): Modules/FindUSB.cmake:31 (libfind_process) lib/CMakeLists.txt:5 (find_package) So I'm obviously missing a library or something, my only question is how do I get it and where do I put it once I get it so that it can work. |
Author: | TheGuardian001 [ Sat Nov 13, 2010 1:03 am ] |
Post subject: | Re: Compiling Open Source Projects |
I'd assume it's talking about Libusb |
Author: | mirhagk [ Sat Nov 13, 2010 9:15 am ] |
Post subject: | RE:Compiling Open Source Projects |
I'm sorry guys, I've tried and tried and I just can't get it working. Can someone please just get this all set up as a visual studio C++ 2008 project? I would seriously love you for the rest of my life. |
Author: | Insectoid [ Sat Nov 13, 2010 10:16 am ] |
Post subject: | RE:Compiling Open Source Projects |
I'll be honest, this driver is worthless. All it does is control the motor in the neck of the peripheral and maybe read the camera. It will not magically make your computer a touch-free device. It isn't really worth taking the time to compile, unless you just want to learn about compiling C projects. |
Author: | mirhagk [ Sat Nov 13, 2010 3:39 pm ] |
Post subject: | RE:Compiling Open Source Projects |
Yeah i know it won't, however I really want to fool around with controling the motor and it apparently recieves both RGB and depth data so I could theoritically reconstruct the same sort of thing (most likely not, but I want to fool arouind with it anyways) |
Author: | TheGuardian001 [ Sat Nov 13, 2010 6:41 pm ] |
Post subject: | Re: Compiling Open Source Projects |
it does indeed send back both Depth and RGB data (It does lack the body-detecting software that makes it useful.) Left is an output of depth data, right is (obviously) the RGB data. Edit:And no, I can't generate your VC project files for you. Those things are a mess, and almost certainly will not survive the transition from one computer to another. What exactly isn't working? I managed to generate VC++ project files without trouble. |
Author: | mirhagk [ Sat Nov 13, 2010 10:28 pm ] |
Post subject: | RE:Compiling Open Source Projects |
well I couldn't get it to work with my libusb, so I had to manually create my own project, and it's failing on a wierd line In depth_process (in camera.c) the following lines generate errors struct frame_hdr *hdr = (void*)buf; uint8_t *data = buf + sizeof(*hdr); int datalen = len - sizeof(*hdr); It says "syntax error missing";" before type" at the first line, "uint8_t illegal use of this type as an expresiion" on the second (and also another error on the typedef of uint8_t) along with like 30 others Edit: And I transfer projects all the time, as long as you include all of the files into a folder rather than linked all over the place it seems to work fine. Could you let me know of any code edits you did. |
Author: | TheGuardian001 [ Sat Nov 13, 2010 11:01 pm ] |
Post subject: | Re: Compiling Open Source Projects |
I'm assuming this is with Libusb? There's a pre-compiled win32 version over here After you've downloaded and extracted that (specifically the lib file in "msvc" and the include file, usb.h), run CMake, and pick your compiler (don't use the x64 version though, it seems broken.) You should get two errors, both relating to libusb. Click to the far right of each error, and you'll be able to set the path for both the libusb include and library files. Reconfigure, click generate, and you'll have a working MSVC project. Edit: It's worth noting that there is no guarantee this will actually compile. CMake will generate everything the compiler needs to build the project, but Microsoft has been known to ignore standards/implement nonstandard behaviour in their toolchain, so it's very possible to encounter errors simply by using MSVC if this project happens to encounter one of these situations. |
Author: | mirhagk [ Sun Nov 14, 2010 12:18 am ] |
Post subject: | RE:Compiling Open Source Projects |
i think im running into one of those errors, everything is linked up (manually done, created project), but the code won''t compile edit: what did you use to compile the progam? I downloaded codeblocks, but im still having difficulties. EDIT2: Figured out something that caused my visual studio program to fail to compile. When compiling C code, it is strict to standard C, which means all variable must be declared at the top of their scope. However it doesn't tell you that that is the problem, but bing told me! Edit3: Down to 3 errors now (one of them is an include of a library, I can easily fix that) The other two are more troublesome. 1>c:\users\nathan\lotro\attempt at compiling\cameras.c(282) : error C2440: 'function' : cannot convert from 'void (__cdecl *)(libusb_transfer *)' to 'libusb_transfer_cb_fn' 1>c:\users\nathan\lotro\attempt at compiling\cameras.c(282) : warning C4024: 'libusb_fill_iso_transfer' : different types for formal and actual parameter 7 1>c:\users\nathan\lotro\attempt at compiling\cameras.c(283) : error C2440: 'function' : cannot convert from 'void (__cdecl *)(libusb_transfer *)' to 'libusb_transfer_cb_fn' 1>c:\users\nathan\lotro\attempt at compiling\cameras.c(283) : warning C4024: 'libusb_fill_iso_transfer' : different types for formal and actual parameter 7 I have no idea what these even mean (well I get that it says the parameters aren't valid). Does anyone know how to fix it? |
Author: | mirhagk [ Mon Nov 15, 2010 1:40 pm ] |
Post subject: | RE:Compiling Open Source Projects |
Sorry, I fixed the above problems (simply cast them to the required type) Now the only problems left were in the program utilizing the library, so I scrapped that and started my own. No more compiler errors, but now I have these linker errors 1>cameras.obj : error LNK2019: unresolved external symbol _libusb_control_transfer@32 referenced in function _send_init 1>cameras.obj : error LNK2019: unresolved external symbol _libusb_submit_transfer@4 referenced in function _cams_init 1>cameras.obj : error LNK2019: unresolved external symbol _libusb_alloc_transfer@4 referenced in function _cams_init 1>C:\Users\nathan\lotro\oldnect\libfreenect-4094151\OldNect\Debug\OldNect.exe : fatal error LNK1120: 3 unresolved externals I really don't know how to fix them, can someone please help me? |
Author: | TheGuardian001 [ Mon Nov 15, 2010 4:01 pm ] |
Post subject: | Re: Compiling Open Source Projects |
are you linking against libusb? |
Author: | mirhagk [ Mon Nov 15, 2010 9:50 pm ] |
Post subject: | RE:Compiling Open Source Projects |
I'm pretty sure I am, I don't even know, everything is kinda compilcated. What do I have to do to link it? |
Author: | TheGuardian001 [ Mon Nov 15, 2010 10:17 pm ] |
Post subject: | Re: Compiling Open Source Projects |
In the project properties window, select the "Linker" category, then choose "input" and add the library name to the list. But for some reason the "Linker" category is not always available, and I see now indication as to why it isn't (it isn't there for the "libfreenect" project for me, but shows up for the "glview" project.) Well here's another nice reason to like GCC. Linking with libusb is as simple as typing -lusb. |
Author: | mirhagk [ Tue Nov 16, 2010 12:57 am ] |
Post subject: | RE:Compiling Open Source Projects |
okay I added the .lib file to the linker's additional dependencies list... but the above problems still exist. Edit: There was actually two library files to include, and I forgot I was working with a different project than normal. But now it actually compiled and ran (although since I cut out the code that displays the video and stuff it's not very useful.) Time to test it out a little, then next step, compile all this as a .dll so I can utilize it with C# Edit2: So now I don't know how to actually create any sort of graphical ouput in C. Here's the function I need to replicate (this uses glut and pthread, both of which are really awkward and dificult to use on windows). Is there some sort of way to just draw a screen with the data sent to this function, it doesnt have to be fancy, doesnt have to be fast, doesnt have to be cross-platform or extendable, I just need to get something working like right now to make sure that the device is working correctly. void rgbimg(uint8_t *buf, int width, int height) { int i; pthread_mutex_lock(&gl_backbuf_mutex); memcpy(gl_rgb_back, buf, width*height*3); pthread_mutex_unlock(&gl_backbuf_mutex); } |
Author: | TheGuardian001 [ Tue Nov 16, 2010 2:08 am ] | ||||
Post subject: | Re: Compiling Open Source Projects | ||||
If I'm correct in assuming that the function is copying the the raw pixel data to opengl's rgb buffer, you can probably just replace it with a glDrawPixels call.
If you get output, but the colours are incorrect, try changing the 4th parameter to _3_3_2 instead of _2_3_3. Of course, I could be completely misreading that function (I have no idea how pthread works or what it does,) but I see no reason why the library should be using a memcpy for video output. As for actually getting yourself a rendering context (assuming you don't already have a window to render to,) I recommend SDL, since it's simple, effective, and best of all has a pre-compiled library, meaning it isn't any hassle to get it running. Getting yourself an opengl window is as simple as
|