Recent

Author Topic: Problems with dylib and ld: symbol(s) not found  (Read 11491 times)

blueprint

  • New member
  • *
  • Posts: 7
Problems with dylib and ld: symbol(s) not found
« on: June 27, 2011, 09:16:20 pm »
Hi All!

I'm running a plain Lazarus 0.9.30 and FPC 2.4.2 install on a Mac OS X Leopard 10.5.8 desktop.
While trying to build an application that requires an external *.dylib, I'm experiencing some problems. Even though I've placed the necessary libraries in /sw/lib (and even in /usr/lib), I still get the error: Undefined symbols: ... ld: symbol(s) not found

I'm doing cross-compiling, and if I change Target OS to Linux and have the relevant *.so and *.a libraries in /sw/lib/i386-linux/i386-linux/lib everything works just fine.

What am I missing here? Did I place the libraries in the wrong dir?

Thank you so much in advance!

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1071
Re: Problems with dylib and ld: symbol(s) not found
« Reply #1 on: June 27, 2011, 09:22:29 pm »
Hi All!

I'm running a plain Lazarus 0.9.30 and FPC 2.4.2 install on a Mac OS X Leopard 10.5.8 desktop.
While trying to build an application that requires an external *.dylib, I'm experiencing some problems. Even though I've placed the necessary libraries in /sw/lib (and even in /usr/lib), I still get the error: Undefined symbols: ... ld: symbol(s) not found

I'm doing cross-compiling, and if I change Target OS to Linux and have the relevant *.so and *.a libraries in /sw/lib/i386-linux/i386-linux/lib everything works just fine.

What am I missing here? Did I place the libraries in the wrong dir?

The install path of the libraries is hardcoded in the libraries themselves (and it is copied by the linker into your program at compilation time, to make sure that the program will link to the library at the intended location at run time). See e.g. http://doc.qt.nokia.com/qq/qq09-mac-deployment.html and http://qin.laya.com/tech_coding_help/dylib_linking.html for more information, including how to see and change that install path.

kamischi

  • Full Member
  • ***
  • Posts: 177
Re: Problems with dylib and ld: symbol(s) not found
« Reply #2 on: June 27, 2011, 11:24:03 pm »
Are the libraries not available through fink? That way, they would have the correct install_name. using dylibs for a standalone application without fink is a bit more involved.

Michael Schindler
fpc 2.6.4, lazarus 1.4.0, Mac OS X, fink

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1071
Re: Problems with dylib and ld: symbol(s) not found
« Reply #3 on: June 27, 2011, 11:26:17 pm »
Are the libraries not available through fink? That way, they would have the correct install_name.
Only if you require your users to also install them via fink.

blueprint

  • New member
  • *
  • Posts: 7
Re: Problems with dylib and ld: symbol(s) not found
« Reply #4 on: June 28, 2011, 08:35:44 am »
Thank you so much – all of you!
Unfortunately the libraries aren't available through fink.

I took a look at the suggested documents, but I can't seem to figure out just how to go about doing this.
If I run otool (with -D or -L) I just get the filename as output meaning there's no absolute path to the library.
And also, I don't have an application build already to test anything, using for example install_name_tool. I'm still at the build phase.
I've been looking through Lazarus, trying to specify a path to the libraries, but without success. Still get the ld: symbol(s) not found?

Kind regards

kamischi

  • Full Member
  • ***
  • Posts: 177
Re: Problems with dylib and ld: symbol(s) not found
« Reply #5 on: June 28, 2011, 09:18:39 am »
Only if you require your users to also install them via fink.
correct.

blueprint: Could you supply some more informations?

Is your dylib publicly available and how involved is it to build it? Depending on that adding it to fink might not be a big problem.

Is your program a commandline tool or a double clickable Mac application?

How should your program be available? Is fink enough or do you want a "normal" standalone Mac application, which does not need the installation of fink? The latter is also possible starting with fink, but requires some additional steps.

Where should the dylib finally be placed?

Michael Schindler
fpc 2.6.4, lazarus 1.4.0, Mac OS X, fink

blueprint

  • New member
  • *
  • Posts: 7
Re: Problems with dylib and ld: symbol(s) not found
« Reply #6 on: June 28, 2011, 09:38:19 am »
Absolutely!

The dylib comes with the Sentinel HASP suite. Or rather, is generated using a unique vendor code. Although demo-libraries are available.
I have to add an extra layer of security to an application (double clickable Mac app).
It is distributed as a normal standalone Mac app, no fink.

Well, having the dylib placed inside the final *.app would be smart.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1071
Re: Problems with dylib and ld: symbol(s) not found
« Reply #7 on: June 28, 2011, 01:53:17 pm »
I took a look at the suggested documents, but I can't seem to figure out just how to go about doing this.
If I run otool (with -D or -L) I just get the filename as output meaning there's no absolute path to the library.
And also, I don't have an application build already to test anything, using for example install_name_tool.
You also have to change the install name of the library itself (that's the one that will be copied into the application at compile/link time).

Quote
Still get the ld: symbol(s) not found?

How are you importing the functions into your Pascal program?

kamischi

  • Full Member
  • ***
  • Posts: 177
Re: Problems with dylib and ld: symbol(s) not found
« Reply #8 on: June 28, 2011, 11:14:23 pm »
The dylib comes with the Sentinel HASP suite. Or rather, is generated using a unique vendor code. Although demo-libraries are available.
After having a quick look at it, i don't think that building a fink package is easy, probably not even possible. Since your final aim is a regular Mac application, it would not save you from placing the dylib in the application bundle and changing the install_names.

So, put your dylib in the Frameworks folder (you may have to create that) of your bundle and change the install_name and also replace the link to the binary by the actual binary. The references above from jmaebe explain all the details.

MiSchi
fpc 2.6.4, lazarus 1.4.0, Mac OS X, fink

 

TinyPortal © 2005-2018