Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Exodriver example.xcodeproj


  • Please log in to reply
6 replies to this topic

#1 ScottC

ScottC
  • Members
  • 10 posts

Posted 09 May 2013 - 05:04 PM

I downloaded this Xcode project (thank you) and was able to get it to build and run after setting Library Search Paths to /usr/local/lib in the Build Settings. But it's so simple that I can't understand how it works. I tried doing a similar thing (counting U12's in this case) in an existing project but I keep getting "Undefined symbols for architecture i386: "_LJUSB_GetDevCount" The other project is an application plugin, so I can't really start by expanding the Exodriver example. I've noticed that LJUSB_GetDevCount is defined in labjackusb.c, but when I add that to my project it multiplies the number of unknown symbols, like LIBUSB_SUCCESS. In Exodriver example, where is LJUSB_GetDevCount defined? I'm on OS X 10.8.3, Xcode 4.6.2. Please be gentle if you reply, as I'm no C or Xcode programmer. Thanks

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 10 May 2013 - 10:47 AM

It looks like your XCode project is trying to build a application with i386 architecture (32-bit Intel processor), but the Exodriver and probably libusb that were built and installed are not i386 architecture. You will want to change your XCode settings so that it builds for the correct architecture. It is probably x86_64 (64-bit Intel), To check the architectures of the Exodriver and libusb library binaries, in a terminal you can use the "file" command on a file. For example: file /usr/local/lib/liblabjackusb.dylib Alternatively, to support both 32 and 64-bit applications you can use the Mac installer which installs Universal binary versions of Exodriver and libusb or you can build it on your own. Look on the Exodriver page for both the installer and build instructions. I will also point out that you will need to use the installer at least once for the U12 as it needs LabJackHID kernel extension installed.

#3 ScottC

ScottC
  • Members
  • 10 posts

Posted 10 May 2013 - 12:52 PM

Thanks for the info, but I don't think 32-bit is the problem. I changed the Exodriver example to build as 32 bits and it still works. And when I change my project to be 64 bits the "undefined" Linker message changes to say x86_64 instead of x386.

Also, both /usr/local/lib/liblabjackusb.dylib and /usr/local/lib/libusb-1.0.dylib are "Mach-O universal binary with 3 architectures".

I have to build my plugin as 32-bit because it gets loaded by a 32-bit application. It's Carbon, by the way. I added the #include for labjackusb.h and the call to LJUSB_GetDevCount(U12_PRODUCT_ID) as in the example project. The call is in an existing function because there's no "main", since the plugin just defines functions callable by the application.

I have installed LabJackHID.

Can you tell me where the executable code for LJUSB_GetDevCount is? Xcode can't seem to find it.

Thanks again- Scott

It looks like your XCode project is trying to build a application with i386 architecture (32-bit Intel processor), but the Exodriver and probably libusb that were built and installed are not i386 architecture. You will want to change your XCode settings so that it builds for the correct architecture. It is probably x86_64 (64-bit Intel), To check the architectures of the Exodriver and libusb library binaries, in a terminal you can use the "file" command on a file. For example:

file /usr/local/lib/liblabjackusb.dylib

Alternatively, to support both 32 and 64-bit applications you can use the Mac installer which installs Universal binary versions of Exodriver and libusb or you can build it on your own. Look on the Exodriver page for both the installer and build instructions.

I will also point out that you will need to use the installer at least once for the U12 as it needs LabJackHID kernel extension installed.



#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 10 May 2013 - 03:11 PM

In that case your program isn't finding the liblabjackusb library and its functions (for ex. LJUSB_GetDevCount) probably because you didn't link to it in your project. In your project settings go to the build tab and under Linking->Other Linker Flags add "-llabjackusb" (without quotation marks). You'll probably want to do this for all configurations.

#5 ScottC

ScottC
  • Members
  • 10 posts

Posted 13 May 2013 - 08:51 AM

Thank you so much- that fixed the problem. For future reference, what I actually did in Xcode 4.6.2 was
-select Project Navigator icon on the far left
-select the project (just below)
-move to the right and select a target
-select the Build Settings tab near the top (Basic, Combined)
-scroll down to Linking if necessary
-click the disclosure triangle next to Other Linker Flags
-set Debug and Release to -llabjackusb -lusb-1.0

and my project built successfully.

In that case your program isn't finding the liblabjackusb library and its functions (for ex. LJUSB_GetDevCount) probably because you didn't link to it in your project. In your project settings go to the build tab and under Linking->Other Linker Flags add "-llabjackusb" (without quotation marks). You'll probably want to do this for all configurations.



#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 13 May 2013 - 11:31 AM

I'm glad that helped. I would like to point out that "-lusb-1.0" is not needed unless you are going to use libusb functions in your program. liblabjackusb will handle the libusb linking it needs.

#7 ScottC

ScottC
  • Members
  • 10 posts

Posted 13 May 2013 - 05:25 PM

I'm glad that helped. I would like to point out that "-lusb-1.0" is not needed unless you are going to use libusb functions in your program. liblabjackusb will handle the libusb linking it needs.


OK, thanks. I only included lusb-1.0 because it was in the Exodriver example. I've now removed it and the project still builds and runs fine.

Thanks again for your help.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users