site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Hi, g++ -dynamiclib -o libB.dylib B.o g++ -dynamiclib -o libA.dylib A.o -L<path to B> -lB Thanks! Benoit. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... I have a library B which wraps functionality from a library A. B is linked with A. Here are the link commands I use to create the libraries: When I link my executable with A, I'm getting the following error from the linker: g++ -o main Main.o -L<path to A> -lA ld: warning can't open dynamic library: libB.dylib (checking for undefined symbols may be affected) (No such file or directory, errno = 2) ld: Undefined symbols: B::dummy() referenced from libA expected to be defined in libB.dylib make: *** [main] Error 1 The linker only looks for libB.dylib at the location where libB.dylib was installed when A was linked with it. If I do either of the following I can get my executable to link: * explicitly link my executable with lib B: g++ -o main Main.o -L<path to A> -lA -L<path to B> -lB * use -dylib_file to change the install location of lib B: g++ -dylib_file libB.dylib:<path to B>/libB.dylib -o main Main.o -L<path to A> -lA But I don't like any of these solutions because they require our users to deal with lib B. Other ways I found to get it to work are: * use "-flat_namespace -undefined suppress" to link library A and the executable. * use -install_name and require end users to install my libraries at a fixed location. Is there a way to specify additional search paths in the link command for such libraries? (on Linux for example, libraries are also searched in LD_LIBRARY_PATH and there's also an option -rpath-link to specify additional search path). Any recommendations? This email sent to site_archiver@lists.apple.com