c++ - ld library path not working under OS X 10.9 -
i've been trying figure out why g++ cannot link program armadillo library. problem simple:
macbook-pro:arma-xc jmlopez$ g++-4.9 inputs-arma.cpp -larmadillo ld: library not found -larmadillo collect2: error: ld returned 1 exit status perhaps did specify library should be
macbook-pro:arma-xc jmlopez$ ls -l /usr/lib/libarma* -rwxr-xr-x 1 root wheel 37928 aug 18 14:30 /usr/lib/libarmadillo.4.32.2.dylib lrwxr-xr-x 1 root wheel 25 aug 18 14:30 /usr/lib/libarmadillo.4.dylib -> libarmadillo.4.32.2.dylib lrwxr-xr-x 1 root wheel 20 aug 18 14:30 /usr/lib/libarmadillo.dylib -> libarmadillo.4.dylib let try again
macbook-pro:arma-xc jmlopez$ g++-4.9 -l/usr/lib inputs-arma.cpp -larmadillo ld: library not found -larmadillo collect2: error: ld returned 1 exit status ok, did not fix it. let see going on, use -v option generate long output.
macbook-pro:arma-xc jmlopez$ g++-4.9 -l/usr/lib inputs-arma.cpp -larmadillo -v using built-in specs. collect_gcc=g++-4.9 collect_lto_wrapper=/usr/local/cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.3.0/4.9.1/lto-wrapper target: x86_64-apple-darwin13.3.0 configured with: ../configure --build=x86_64-apple-darwin13.3.0 --prefix=/usr/local/cellar/gcc/4.9.1 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog --with-isl=/usr/local/opt/isl --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='homebrew gcc 4.9.1' --with-bugurl=https://github.com/homebrew/homebrew/issues --enable-plugin --disable-nls --enable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk thread model: posix gcc version 4.9.1 (homebrew gcc 4.9.1) collect_gcc_options='-mmacosx-version-min=10.9.3' '-l/usr/lib' '-v' '-shared-libgcc' '-mtune=core2' /usr/local/cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.3.0/4.9.1/cc1plus -quiet -v -d__dynamic__ inputs-arma.cpp -fpic -quiet -dumpbase inputs-arma.cpp -mmacosx-version-min=10.9.3 -mtune=core2 -auxbase inputs-arma -version -o /var/folders/6x/ss29s2r51z5cv0_g1ffx0c0c0000gn/t//ccapa95q.s gnu c++ (homebrew gcc 4.9.1) version 4.9.1 (x86_64-apple-darwin13.3.0) compiled gnu c version 4.9.1, gmp version 6.0.0, mpfr version 3.1.2-p8, mpc version 1.0.2 ggc heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/local/include" ignoring nonexistent directory "/usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/../../../../x86_64-apple-darwin13.3.0/include" ignoring nonexistent directory "/applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/library/frameworks" #include "..." search starts here: #include <...> search starts here: /users/jmlopez/github/excentury/excentury/extern/include /usr/include /usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/include/c++ /usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/include/c++/x86_64-apple-darwin13.3.0 /usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/include/c++/backward /usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/include /usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/include-fixed /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/include /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/system/library/frameworks end of search list. gnu c++ (homebrew gcc 4.9.1) version 4.9.1 (x86_64-apple-darwin13.3.0) compiled gnu c version 4.9.1, gmp version 6.0.0, mpfr version 3.1.2-p8, mpc version 1.0.2 ggc heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 compiler executable checksum: 5a051bcf2be886a5c6eb8ba33f338693 collect_gcc_options='-mmacosx-version-min=10.9.3' '-l/usr/lib' '-v' '-shared-libgcc' '-mtune=core2' -arch x86_64 -force_cpusubtype_all -o /var/folders/6x/ss29s2r51z5cv0_g1ffx0c0c0000gn/t//cchm9rvf.o /var/folders/6x/ss29s2r51z5cv0_g1ffx0c0c0000gn/t//ccapa95q.s compiler_path=/usr/local/cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.3.0/4.9.1/:/usr/local/cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.3.0/4.9.1/:/usr/local/cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.3.0/:/usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/:/usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/ library_path=/usr/lib/:/usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/:/usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/../../../:/applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib/ collect_gcc_options='-mmacosx-version-min=10.9.3' '-l/usr/lib' '-v' '-shared-libgcc' '-mtune=core2' /usr/local/cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.3.0/4.9.1/collect2 -dynamic -arch x86_64 -macosx_version_min 10.9.3 -syslibroot /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk -weak_reference_mismatches non-weak -o a.out -l/usr/lib -l/usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1 -l/usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/../../.. -l/applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib /var/folders/6x/ss29s2r51z5cv0_g1ffx0c0c0000gn/t//cchm9rvf.o -larmadillo -lstdc++ -no_compact_unwind -lsystem -lgcc_ext.10.5 -lgcc -lsystem -v collect2 version 4.9.1 /usr/bin/ld -dynamic -arch x86_64 -macosx_version_min 10.9.3 -syslibroot /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk -weak_reference_mismatches non-weak -o a.out -l/usr/lib -l/usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1 -l/usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1/../../.. -l/applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib /var/folders/6x/ss29s2r51z5cv0_g1ffx0c0c0000gn/t//cchm9rvf.o -larmadillo -lstdc++ -no_compact_unwind -lsystem -lgcc_ext.10.5 -lgcc -lsystem -v @(#)program:ld project:ld64-236.4 configured support archs: armv6 armv7 armv7s arm64 i386 x86_64 armv6m armv7m armv7em library search paths: /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib /usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1 /usr/local/cellar/gcc/4.9.1/lib /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib framework search paths: /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/system/library/frameworks/ ld: library not found -larmadillo collect2: error: ld returned 1 exit status the important information here:
library search paths: /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib /usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1 /usr/local/cellar/gcc/4.9.1/lib /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib somehow not looking in /usr/lib. have tried specifying directory first exporting variable ld_library_path
macbook-pro:arma-xc jmlopez$ export ld_library_path=/usr/lib macbook-pro:arma-xc jmlopez$ g++-4.9 -l/usr/lib inputs-arma.cpp -larmadillo ld: library not found -larmadillo collect2: error: ld returned 1 exit status no luck. finally, thinking ld might broken did this:
macbook-pro:arma-xc jmlopez$ ln -s /usr/lib/libarmadillo.dylib /usr/local/cellar/gcc/4.9.1/lib/libarmadillo.dylib macbook-pro:arma-xc jmlopez$ g++-4.9 inputs-arma.cpp -larmadillo now works. i'm not sure if there wrong system seems have no way of specifying other paths ld libraries. instead have use of following:
library search paths: /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib /usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1 /usr/local/cellar/gcc/4.9.1/lib /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib is there way fix this? notice i'm using g++ homebrew since thought 1 came xcode broken. in case, no luck, @ least homebrew g++ told me paths library being searched.
update:
i decided see if add path:
g++-4.9 -l/users/jmlopez/ -l/users/jmlopez/desktop -l/usr/lib inputs-arma.cpp -larmadillo -v now list of paths searches libraries is:
library search paths: /users/jmlopez/ /users/jmlopez/desktop /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib /usr/local/cellar/gcc/4.9.1/lib/gcc/x86_64-apple-darwin13.3.0/4.9.1 /usr/local/cellar/gcc/4.9.1/lib /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.9.sdk/usr/lib where /usr/lib? special directory ld refuses in directory. searches in home directory , in desktop. tried adding /usr/local , adds list of directories. i'm starting wonder permissions on directories... ideas?
it homebrew g++ compiled custom prefix. prefix gcc /usr, meaning binaries in /usr/bin, headers in /usr/include , libraries in /usr/lib. if you've compiled custom prefix (/usr/local/cellar/gcc/4.9.1/ in case, seems) won't in /usr/lib.
ld_library_path how tell runtime linker libraries. if had linked /usr/my/bizarre/lib/path/libmylib.so, run this:
> ld_library_path=/usr/my/bizarre/lib/path myprog to tell g++ find libraries, use -l command-line option. command-line should this:
g++-4.9 inputs-arma.cpp -l/usr/lib -larmadillo
Comments
Post a Comment