FAQ FAQ   Search Search   Memberlist Memberlist   Usergroups Usergroups   Register Register 
3Dconnexion.com
3Dconnexion Forum 
  Profile Profile   Log in to check your private messages Log in to check your private messages  Log inLog in 

 3Dconnexion.com Forum Index » Developer's Forum for Mac OS X » Weak Link on MacOS X
  The time now is Thu Sep 02, 2010 6:34 am 

 Post new topic   Reply to topic View previous topic :: View next topic  
Author Message
PostPosted: Fri Jun 22, 2007 1:56 pm    Post subject: Weak Link on MacOS X  Reply with quote  

lorenzo



Joined: 06 Jun 2007
Posts: 2
Location: Italy

Hi,
I have bought the Space Navigator and implemented the 3dConnexion sample code in my Universal Binary application for MacOS X. It works. As I have seen, the installer of the driver automatically installs the framework at
/Library/Frameworks/3DconnexionClient.framework
And as the Apple guideline says about the weak links, I have removed the direct link to the 3DconnexionClient.framework and added a line
Other Linker Flags: -weak_framework 3DconnexionClient
It doesn't compile. The compiler says that it cannot locate that framework.
So I have tried the following paths, unsuccessfully:
"3DconnexionClient"
"3DconnexionClient.framework"
<3DconnexionClient>
<3DconnexionClient>
/Library/Framework/3DconnexionClient
/Library/Framework/3DconnexionClient.framework
"/Library/Framework/3DconnexionClient"
"/Library/Framework/3DconnexionClient.framework"
</Library>
</Library>
The compiler still says that it cannot compile because it cannot locate that framework.
So I have added the line
Framework Search Paths: /Library/Frameworks
and now I can quite use successfully
Other Linker Flags: -weak_framework 3DconnexionClient
It compiles and launch. The problem is now when I try to simulate the case of an user who has not that framework at
/Library/Framework/3DconnexionClient.framework
I removed the framework folder from there and launched my application. It runs, but the Console reports this error:
2007-06-22 23:27:43.303 MyOwnApp[8935] CFLog (21): Error loading /Library/QuickTime/3DxQuickTime.component/Contents/MacOS/3DxQuickTime: error code 4, error number 0 (Library not loaded: /Users/alm/Library/Frameworks/3DconnexionClient.framework/Versions/A/3DconnexionClient

I suppose that the 3DConnexion developer "alm" has left some trace of himself on the framework.
Anyway, did I miss something? How to fix this problem?

Thank you and regards
Lorenzo

TOP View user's profileSend private message  BOTTOM
PostPosted: Mon Jun 25, 2007 7:59 am    Post subject:  Reply with quote  

flomotan
Moderator
Moderator


Joined: 08 Jan 2007
Posts: 251

The user "alm" was present in earlier versions of the 3DconnexionClient framework. This has been removed in v1.2.0 of the driver

TOP View user's profileSend private message  BOTTOM
PostPosted: Thu Aug 09, 2007 12:46 pm    Post subject:  Reply with quote  

ettore
Moderator
Moderator


Joined: 14 Mar 2007
Posts: 127
Location: SF Bay Area, CA

Moved this topic from the generic Mac OS X Discussion Forum.
_________________
ettore pasquini
software engineer
3Dconnexion, inc.

TOP View user's profileSend private messageAIM Address  BOTTOM
PostPosted: Thu Apr 03, 2008 7:54 am    Post subject: Weak Linking Framework  Reply with quote  

Richard Wright



Joined: 03 Apr 2008
Posts: 3
Location: Lake Mary, FL

Weak linking the 3DConnexion framework was a piece of cake... however the instructions for testing to see if the framework is present does not work. I'm running Leopard, and XCode 3.0.

I have the following declaration at the top of my source file:

extern OSErr InstallConnexionHandlers() __attribute__((weak_import));

Then later, I have

if(InstallConnexionHandlers != NULL) {
...

This produces a compiler error: invalid operands of types '<unknown>' and 'int' to binary 'operator!='

Is there a compiler option somewhere, or something obvious (to everyone else) that I missed?

Richard

TOP View user's profileSend private messageSend e-mail  BOTTOM
PostPosted: Thu Apr 03, 2008 8:21 am    Post subject: Re: Weak Linking Framework  Reply with quote  

ettore
Moderator
Moderator


Joined: 14 Mar 2007
Posts: 127
Location: SF Bay Area, CA

Richard Wright wrote:
Weak linking the 3DConnexion framework was a piece of cake... however the instructions for testing to see if the framework is present does not work. I'm running Leopard, and XCode 3.0.

I have the following declaration at the top of my source file:

extern OSErr InstallConnexionHandlers() __attribute__((weak_import));

Then later, I have

if(InstallConnexionHandlers != NULL) {
...

This produces a compiler error: invalid operands of types '<unknown>' and 'int' to binary 'operator!='

Is there a compiler option somewhere, or something obvious (to everyone else) that I missed?

Richard

I don't have Leopard right here, but it seems like the InstallConnexionHandlers function is unknown to the compiler. I assume you included our header file before the weak link directive?

Code:
#include "3DConnexionClient/ConnexionClientAPI.h"


After that, the actual link command is to be added in the target Build options, under Other Linker Flags:

-weak_framework 3DconnexionClient
_________________
ettore pasquini
software engineer
3Dconnexion, inc.

TOP View user's profileSend private messageAIM Address  BOTTOM
PostPosted: Thu Apr 03, 2008 11:41 am    Post subject: Weak Linking  Reply with quote  

Richard Wright



Joined: 03 Apr 2008
Posts: 3
Location: Lake Mary, FL

Yes, I have your include file included (it will not compile without it). I found I can get the code

if(InstallConnexionHandlers != NULL) {
...

to compile if I do _not_ put the

extern OSErr InstallConnexionHandlers() __attribute....

after the include file. So it appears to work... until I run it on another machine. My program launches, but then crashes because InstallConnexionHandlers is not NULL... that makes no sense. After some fiddling, I finally got this to compile and work correctly:

unsigned int address = (unsigned int)(InstallConnexionHandlers);
if(address != 0u) {
result = InstallConnectionHandlers(...

Very weird. I would not have believed it if I hadn't seen it myself. Comparing address to 0 would not work either, I had to put the u suffix on the literal. I don't know if this is an XCode 3.0 or Leopard Quirk... I even tried printing out the value of address on the console (as hex, signed and unsigned ints), it always came back as zero... but the statements:

if(address != 0) or
if(address != NULL)

always evaluated true.

Anyway, it works fine now and I've tested it on a couple machines with and without the framework installed. Perhaps this post will help someone else later if they have the same problem.

Richard

TOP View user's profileSend private messageSend e-mail  BOTTOM
PostPosted: Fri Aug 21, 2009 10:18 pm    Post subject: hey  Reply with quote  

popular123



Joined: 20 Aug 2009
Posts: 2

2007-06-22 23:27:43.303 MyOwnApp[8935] CFLog (21): Error loading /Library/QuickTime/3DxQuickTime.component/Contents/MacOS/3DxQuickTime: error code 4, error number 0 (Library not loaded: /Users/alm/Library/Frameworks/3DconnexionClient.framework/Versions/A/3DconnexionClient
_________________
Entourage dvd
24 Hours Seasons 1-7 DVD Boxset

TOP View user's profileSend private message  BOTTOM
PostPosted: Tue Aug 25, 2009 10:54 am    Post subject:  Reply with quote  

flomotan
Moderator
Moderator


Joined: 08 Jan 2007
Posts: 251

Please ensure you have the latest 1.5.7 driver installed. That comes with an updated framework.

TOP View user's profileSend private message  BOTTOM
PostPosted: Mon Jul 19, 2010 10:47 pm    Post subject: Re: Weak Linking Framework  Reply with quote  

significant-bit



Joined: 19 Jul 2010
Posts: 4
Location: Hattiesburg, United States

Richard Wright wrote:

I have the following declaration at the top of my source file:

extern OSErr InstallConnexionHandlers() __attribute__((weak_import));

Then later, I have

if(InstallConnexionHandlers != NULL) {
...

This produces a compiler error: invalid operands of types '<unknown>' and 'int' to binary 'operator!='

Is there a compiler option somewhere, or something obvious (to everyone else) that I missed?


I had this same problem in June 2010, and the culprit on my end was Objective-C++! This did not work in my .mm file, so I moved the test to a separate C file and exposed it to the rest of the code as a "bool available()" function.

TOP View user's profileSend private message  BOTTOM
 Post new topic   Reply to topic All times are GMT - 8 Hours

Display posts from previous:   
 3Dconnexion.com Forum Index » Developer's Forum for Mac OS X » Weak Link on MacOS X
 Page 1 of 1
 
 
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Jump to:  


     Powered by phpBB © 2001, 2005 phpBB Group | Template Neon v1.3 | Crystal