Usually when the linker doesn't find a library that actually exists in the path it's because some binary incompatibilities (i.e. about 32/64 bit).
In my situation it seems different and I didn't find a question that answer the issue.
Rapsberry Pi 3B+, Raspbian Stretch Lite, trying to compile the Microchip SDK for 3DTouchPad.
The compilation fails in this way:
mkdir -p build/bin
gcc -o build/bin/2draw build/2draw/2draw.o -Lbuild/bin -lmchp_hmi -L/lib/arm-linux-gnueabihf/ -lusb -Wl,-rpath,\$ORIGIN -lcurses
/usr/bin/ld: cannot find -lusb
collect2: error: ld returned 1 exit status
Makefile:125: recipe for target 'build/bin/2draw' failed
make: *** [build/bin/2draw] Error 1
and here the details about the "missing" library:
$ ldconfig -p | grep libusb
libusb-1.0.so.0 (libc6,hard-float) => /lib/arm-linux-gnueabihf/libusb-1.0.so.0
libusb-1.0.so (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libusb-1.0.so
libusb-0.1.so.4 (libc6,hard-float) => /lib/arm-linux-gnueabihf/libusb-0.1.so.4
$ file /lib/arm-linux-gnueabihf/libusb-1.0.so.0.1.0
/lib/arm-linux-gnueabihf/libusb-1.0.so.0.1.0: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=a93e56d2846806b7adc76e674493c76e54e3ca9e, stripped
That seems ok to me. I installed it with sudo apt-get install libusb-1.0-0-dev.
Are there any other causes that would prevent the linker to find an existing library?
EDIT
Interesting enough... even I cannot infer the cause.
$ ld -lusb --verbose
GNU ld (GNU Binutils for Raspbian) 2.28
Supported emulations:
armelf_linux_eabi
armelfb_linux_eabi
==================================================
attempt to open //usr/local/lib/arm-linux-gnueabihf/libusb.so failed
attempt to open //usr/local/lib/arm-linux-gnueabihf/libusb.a failed
attempt to open //lib/arm-linux-gnueabihf/libusb.so failed
attempt to open //lib/arm-linux-gnueabihf/libusb.a failed
attempt to open //usr/lib/arm-linux-gnueabihf/libusb.so failed
attempt to open //usr/lib/arm-linux-gnueabihf/libusb.a failed
attempt to open //usr/local/lib/libusb.so failed
attempt to open //usr/local/lib/libusb.a failed
attempt to open //lib/libusb.so failed
attempt to open //lib/libusb.a failed
attempt to open //usr/lib/libusb.so failed
attempt to open //usr/lib/libusb.a failed
attempt to open //usr/arm-linux-gnueabihf/lib/libusb.so failed
attempt to open //usr/arm-linux-gnueabihf/lib/libusb.a failed
ld: cannot find -lusb
For an argument of the form -lLIB, the link editor looks for input files named libLIB.so or libLIB.a. If there is a version number in the library name LIB, you must supply it, otherwise the link editor will not find it. If the version is in the soname after the .so, it is customary to add a dynamic link ending in .so without the version, so that the link editor can find it. (This symbolic link is usually packaged in the -dev or -devel packages by distributions.) But in your case, this symbolic link includes the version number before the .so (although it would not have to).
One advantage of putting the version number in the library name (the LIB part above) is that it is possible to easily switch between linking against different versions of the library.
Related
I've tried following the intel instructions to install sgx, but it requires the sgx_linux_x64_psw_.bin file, which i cannot find anywhere. I've got the driver installer (sgx_linux_x64_driver_1.35.bin) and the sdk installer(sgx_linux_x64_sdk_2.10.100.2.bin), intel seems not to have a psw for linux? If so, how do i properly work with sgx? I tried simply executing the driver and sdk .bin files, but the sample code in the sdk would not compile (after make SGX_MODE=SIM), even after setting the sgxsdk directory to /opt/intel/sgxsdk. I'd get the following compile error:
/usr/bin/ld: warning: libsgx_uae_service_sim.so, needed by /opt/intel/sgxsdk/lib64/libsgx_urts_sim.so, not found (try using -rpath or -rpath-link)
/opt/intel/sgxsdk/lib64/libsgx_urts_sim.so: undefined reference to `get_launch_token'
collect2: error: ld returned 1 exit status
Makefile:235: recipe for target 'app' failed
make[1]: * [app] Error 1
make[1]: Leaving directory '/opt/intel/sgxsdk/SampleCode/SampleEnclave'
Makefile:180: recipe for target 'all' failed
make: * [all] Error 2
Any help with either issue would be much appreciated!
So at least in my case, it seems the issue was that I was A, using a virtual machine, which can ONLY run in simulation mode, so getting a fully working version of sgx is impossible. Secondly, I was using an outdated installation guide, for anyone else trying to use this stuff, make sure to get the installation guide from the intel download page along with the version you are downloading.
download source code from https://github.com/intel/linux-sgx, compile according to the instructions and then install psw.
Getting “ld: library not found for -llibopencv_dnn.3.3.1.dylib:
11:27:44: Running steps for project Hello_OpenCV...
11:27:44: Configuration unchanged, skipping qmake step.
11:27:44: Starting: "/usr/bin/make"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.10 -Wl,-rpath,#executable_path/Frameworks -o Hello_OpenCV main.o -L/usr/local/lib -llibopencv_dnn.3.3.1.dylib -llibopencv_ml.3.3.1.dylib -llibopencv_objdetect.3.3.1.dylib -llibopencv_shape.3.3.1.dylib -llibopencv_stitching.3.3.1.dylib -llibopencv_superres.3.3.1.dylib -llibopencv_videostab.3.3.1.dylib -llibopencv_calib3d.3.3.1.dylib -llibopencv_features2d.3.3.1.dylib -llibopencv_highgui.3.3.1.dylib -llibopencv_videoio.3.3.1.dylib -llibopencv_imgcodecs.3.3.1.dylib -llibopencv_video.3.3.1.dylib -llibopencv_photo.3.3.1.dylib -llibopencv_imgproc.3.3.1.dylib -llibopencv_flann.3.3.1.dylib -llibopencv_core.3.3.1.dylib
ld: library not found for -llibopencv_dnn.3.3.1.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Hello_OpenCV] Error 1
11:27:44: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project Hello_OpenCV (kit: Desktop Qt 5.9.0 clang 64bit)
When executing step "Make"
11:27:44: Elapsed time: 00:00.
Do you actually have OpenCV installed on your system? If you run the following command, do you get any output?
find / -name "*libopencv*" 2>/dev/null
If not, you probably need to ensure you install it first. Follow instructions such as the ones found here.
If the above does return something (example: /path/to/lib/libopencv_dnn.3.3.1dylib), then try adding -L/path/to/lib into your compile line
It looks like you're including the entire suite of OpenCV modules, some of which are very feature-specific and likely not needed if you have a simple application. The DNN module in particular is not included in binary form with OpenCV (see this page on the matter). If you're sure you need it, you need to compile it yourself.
If you aren't doing any machine learning, you likely don't need the library and you can remove -llibopencv_dnn.3.3.1.dylib from your compile line.
I am currently trying to set up a Go project, and considering I am running Windows, while the other 2 developers are working on a Mac, I have some trouble with installing a few packages.
After trying to install the packages with cmd, I was only able to install 2 out of 4. The other two needed gcc.
Therefore, I installed MinGW. I was able to install a third package that way, but now I am stuck on https://github.com/mikkyang/id3-go.
It seems to depend on another underlying project, https://github.com/djimenez/iconv-go. The moment I try to go install id3-go, I am always left with this error:
src\github.com\djimenez\iconv-go\converter.go:8:19: fatal error: iconv.h: No such file or directory
Somehow, I need to use libiconv with MinGW, but I have no idea how to connect both parts. I'm not really an expert in that field, so any help would be appreciated a lot. I already downloaded libiconv for Windows.
Related issue for additional information I found on the github project:
https://github.com/mikkyang/id3-go/issues/21
EDIT: I made some progress on the whole problem. I now got all the files I need, but now I am stuck with this warning:
# github.com/djimenez/iconv-go
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -liconv
collect2.exe: error: ld returned 1 exit status
I tried to add the libiconv2.a from my libiconv installation to the mingw32 lib folder, but then this is what I end up with:
# github.com/djimenez/iconv-go
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/../lib\libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib\libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/lib/libiconv.a when searching for -liconv
E:/Tools/TDM-GCC/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -liconv
collect2.exe: error: ld returned 1 exit status
I have no idea how to proceed from here.
I've met the same problem when I want to go install github.com/google/gopacket which need CGO. It's because your libiconv2.a is generated by other compiler, so it's incompatible with mingw32 compiler as the error message says. We need generate the static lib with the mingw32 toolset:
find libiconv-2.dll(the coresonding dynamic library) in your PC
run gendef(located in C:\TDM-GCC-64\x86_64-w64-mingw32\bin in my 64-bit Windows ) on those files gendef libiconv-2.dll, this will generate libiconv2.def file
Then generate the static library:
dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libiconv2.a --input-def libiconv2.def
copy libiconv2.a to proper location.
I am trying to build a program that relies on wxWidgets to run properly. I have the latest version of Xcode installed. I have tried building wxWidgets (both wxWidgets-3.0.2 and wxWidgets-2.9.4, the version originally used by the main program). However, in both cases, running the makefile for the main program gives the following error:
make: /Users/path to wxWidgets/wxWidgets-2.9.4/build-cocoa-release/utils/wxrc/wxrc: No such file or directory
As I understand it, I need to build wxrc to get my main program to build properly (I have tried this, but apparently some header files are missing). Is there any way to configure wxWidgets before this step that will automatically build wxrc as well? Or is that something I need to build separately? If it is separate, how would that be done?
I've pasted the code I originally used to configure wxWidgets below, with line breaks to make it easier to read:
../configure --with-osx_cocoa --with-macosx-version-min=10.7
--with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
--prefix="$(pwd)" --with-opengl CC=clang CXX=clang++ CXXFLAGS="-stdlib=libc++ -std=c++11"
OBJCXXFLAGS="-stdlib=libc++ -std=c++11" LDFLAGS=-stdlib=libc++
There is one error while building wxWidgets:
../src/osx/cocoa/utils.mm:250:28: error: cannot initialize a parameter of type 'id' with an lvalue of type
'wxNSAppController *'
[NSApp setDelegate:appcontroller];
When I go into the samples directory and enter "make", I get: ld: library not found for -lwx_osx_cocoau_xrc-2.9 clang: error: linker command failed with exit code 1 (use -v to see invocation) When entering "make" in demos, I get: ld: library not found for -lwx_osx_cocoau_core-2.9 clang: error: linker command failed with exit code 1 (use -v to see invocation)
If I missed any steps I should have taken before these (something with Xcode maybe?) please let me know. Thank you very much in advance.
Similar question. I have sugested a workaround proposed on a forum as follows: you can use --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/".
After I download UnitTest++ version 1.4 (from http://sourceforge.net/projects/unittest-cpp/) and do a make, I get:
$ make
src/AssertException.cpp
src/Test.cpp
src/Checks.cpp
src/TestRunner.cpp
src/TestResults.cpp
src/TestReporter.cpp
src/TestReporterStdout.cpp
src/ReportAssert.cpp
src/TestList.cpp
src/TimeConstraint.cpp
src/TestDetails.cpp
src/MemoryOutStream.cpp
src/DeferredTestReporter.cpp
src/DeferredTestResult.cpp
src/XmlTestReporter.cpp
src/CurrentTest.cpp
src/Posix/SignalTranslator.cpp
src/Posix/TimeHelpers.cpp
Creating libUnitTest++.a library...
src/tests/Main.cpp
src/tests/TestAssertHandler.cpp
src/tests/TestChecks.cpp
src/tests/TestUnitTest++.cpp
src/tests/TestTest.cpp
src/tests/TestTestResults.cpp
src/tests/TestTestRunner.cpp
src/tests/TestCheckMacros.cpp
src/tests/TestTestList.cpp
src/tests/TestTestMacros.cpp
src/tests/TestTimeConstraint.cpp
src/tests/TestTimeConstraintMacro.cpp
src/tests/TestMemoryOutStream.cpp
src/tests/TestDeferredTestReporter.cpp
src/tests/TestXmlTestReporter.cpp
src/tests/TestCurrentTest.cpp
Linking TestUnitTest++...
ld: in libUnitTest++.a, archive has no table of contents
collect2: ld returned 1 exit status
make: *** [TestUnitTest++] Error 1
A co-worker doesn't get this error on his Mac, with the same version of gcc (4.2.1). (Note: I can use the libUnitTest++.a built by my co-worker, so I'm not blocked, but I would like to troubleshoot this problem nonetheless.)
I did a Google search, and it sounds like ranlib has solved others' similar problems, but libUnitTest++.a isn't getting created so I can't run ranlib on it.
I've run into this problem myself, you need to run ranlib on the .a file before passing it along to g++. I've patched this in a homebrew recipe, enjoy:
https://github.com/pdex/homebrew/blob/master/Library/Formula/unittest-cpp.rb