Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6863293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:45:54+00:00 2026-05-27T02:45:54+00:00

Can anybody give me some hints for solving this? I’m trying to compile Kinect

  • 0

Can anybody give me some hints for solving this?

I’m trying to compile “Kinect Matlab” (on Mac OS 10.7), in the compile script is the following line:

mex('-v','-L/usr/lib/','-lOpenNI',[...],Filename);

This is the full command run by mex: (1)

gcc-4.2 -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2011a.app/extern/lib/maci64/mexFunction.map -o  "mxNiChangeDepthViewPoint.mexmaci64"  mxNiChangeDepthViewPoint.o  -L/usr/lib/ -lOpenNI -L/Applications/MATLAB_R2011a.app/bin/maci64 -lmx -lmex -lmat -lstdc++

Then I’m getting the following error:

ld: library not found for -lOpenNI
collect2: ld returned 1 exit status

    mex: link of ' "mxNiChangeDepthViewPoint.mexmaci64"' failed.

There is most definitely a file at /usr/lib/libOpenNI.dylib.

What kinds of things cause ld to throw this error?

What I tried:

  • I have tried creating a symlink called libOpenNI.so, like jmlopez suggested, no effect.
  • Could it be that libOpenNI is a 32bit library, and ld is not seeing it for that reason? Or would the error then be different?
  • Regarding the point above, it says that the build is “universal x86/x64”

Env vars:

I’ve tried to add the library to the environment variables using the following command, from the matlab terminal. No effect.

setenv('DYLD_LIBRARY_PATH', [getenv('DYLD_LIBRARY_PATH') ':/usr/lib/']);

In bash:

Just calling gcc as suggested here https://serverfault.com/questions/54736/how-to-check-if-a-library-is-installed gives no problems.

$ gcc -lOpenNi
Undefined symbols for architecture x86_64:
  "_main", referenced from:
      start in crt1.10.6.o

However, if I run g++ first, then gcc as in (1), same error as before. (library not found). How come gcc can find the library, but when matlab adds the stuff in (1) it messes things up?

So, related to what is said above, I started removing all arguments from (1) until I got a different error. I removed the -Wl,-syslibroot, meaning that -syslibroot would no longer be passed to ld, this seems to have fixed it. So -syslibroot is messing up the library search directory! Now to find a way to remove this argument from the mex() call.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:45:55+00:00Added an answer on May 27, 2026 at 2:45 am

    BOOM! IT WORKS!

    Okay, here it is:

    The -Wl,-syslibroot option in the gcc call (1) is sending a -syslibroot option to the linker, and somehow that gets prepended to the library search path (even though it shouldn’t according to cannot specify root sdk directory with syslibroot when linking)

    So, removing this -syslibroot can solve our problem, this can be done in mexopts.sh. Copying matlab’s version from the default location:

    cp /Applications/MATLAB_R2011a.app/bin/mexopts.sh ~/.matlab/R2011a/
    

    And then changing this line (201):

    LDFLAGS="-Wl,-twolevel_namespace -undefined error -arch $ARCHS -Wl,-syslibroot,$SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
    

    Removing the -Wl,-syslibroot,$SDKROOT argument.

    Additionally, I could remove the -L/usr/lib argument from the call to mex, making it simply:

     mex('-v','-lOpenNI',['-I' OpenNiPathInclude],Filename);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody give me some sample source code showing how to connect to a
Can anybody give me some clue that how to convert binary string into a
Can anybody give me some help for figuring out the problem below. Here are
Can anybody give me an example how to implement AttachedCommands? There are some examples
Can anybody give me some examples of Mach-O files in an Xcode project, or
Can anybody give me some links or explain me how to build an XLL
Can anybody give a clear explanation of how variable assignment really works in Makefiles.
Can anybody give me an example how to use the osgi framework classes? I
Can anybody give a link for a simple explanation on BFS and DFS with
Can anybody give an example of c++ code that can easily convert a decimal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.