linking error with NDK (r19c): cannot find -lpthread - c++

I have a C++ project with CMake build system. When I compile using GCC it compiles fine. But when I tried to use NDK toolchain, it shows the following error.
Linking CXX executable ../bin/my_app
/opt/r19c/linux-x86_64/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld:
cannot find -lpthread
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
How can I fix this issue?

Related

"error: unable to find library -latomic" when using clang

I am trying to build a project (PDFium) using clang.
It keeps giving me this error
ld.lld: error: unable to find library -latomic
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
I have these installed on my system
libatomic_ops 7.6.14-1
clang 14.0.6-2
lib32-clang 14.0.6-1
libatomic1
And about LD_LIBRARY_PATH
$ export LD_LIBRARY_PATH=/usr/lib64:/usr/lib32:/usr/local/lib:/usr/lib
$ sudo ldconfig
I have tried it on Debian, Arch and Ubuntu.

Linking error with Movesense library 1.9.0.rc3

I get a linking error after updating Movesense library from 1.8.1 to 1.9.0 in my project and even in the hello world sample project. Has anyone else has this problem and can offer a solution?
I am running the SDK on
Ubuntu 18.04.2 LTS
arm-none-eabi-gcc 7.3.1
Same problem with gcc-arm-none-eabi-7-2017-q4
Here is the output of the linking failure after calling ninja:
FAILED: Movesense
: && /usr/bin/arm-none-eabi-gcc -W -Wall -[...] ../platform/nRF5x/linker/gcc/appflash.ld CMakeFiles/Movesense.dir/App.cpp.obj CMakeFiles/Movesense.dir/HelloWorldService.cpp.obj CMakeFiles/Movesense.dir/generated/sbem-code/sbem_definitions.cpp.obj CMakeFiles/Movesense.dir/generated/app-resources/resources.cpp.obj CMakeFiles/Movesense.dir/app-metadata/metadata.cpp.obj -o Movesense /home/lukas/Projects/movesense/movesense-device-lib/MovesenseCoreLib/lib/GCCARM/libmovesense-coreD.a -lm -lstdc++ && :
lto1: internal compiler error: bytecode stream: expected tag round_div_expr instead of reference_type
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
lto-wrapper: fatal error: /usr/bin/arm-none-eabi-gcc returned 1 exit status
compilation terminated.
/usr/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
With Movesense 1.8.1 everything works fine:
git checkout 38be3c2
[...]
cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake ../samples/hello_world_app
[...]
ninja
[...]
[8/8] Linking CXX executable Movesense
Thanks in advance!
From CHANGES.md (& README.md) since 1.9.0
REQUIRED: Use Windows build environment only (due to above GNU OSX bug)
REQUIRED: Use GNU Toolchain for ARM v. 7.2.1 2017q4
This situation is unfortunate and will be rectified in the coming 2.0 release with a new docker based build environment.
Full Disclaimer: I work for the Movesense team

Is it possible to compile c++ using Clang only on windows?

I really tried a lot. Clang does not come with standard C++ includes, and obviously can not find them :
clang++ file.cpp -o file.out
C:\Folder\file.cpp:1:11: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated.
Passing the mingw includes by arguments, it returns another error:
clang++ -target x86_64-w64-mingw32 C:\Folder\file.cpp -IC:\MinGW\mingw64\lib\gcc\x86_64-w64-mingw32\6.3.0\include\c++ -IC:\MinGW\mingw64\lib\gcc\x86_64-w64-mingw32\6.3.0\include\c++\x86_64-w64-mingw32 -IC:\MinGW\mingw64\x86_64-w64-mingw32\include -o C:\Folder\file.out -std=c++11
clang++.exe: error: unable to execute command: program not executable
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
When I use -c it does not use the linker and also not generate an executable file.
Edit : I'm running on windows
Run your commands from "x64 Native Tools Command Prompt for VS 2017", or something similar. It will setup some required env vars for you.

Compiling lsd_slam on OS X throws linking error ld: library not found for -lGL

I am trying to compile lsd_slam on OSX 10.9.5 and I get the build error as
ld: library not found for -lGL
clang: error: linker command failed with exit code 1 (use -v to see invocation)
From what I understand from this SO answer, it needs to compile with the flag-framework OpenGL. What changes are needed and in which Makefile so as this choses the framework instead of -lGL.
It should link correctly if you replace -lGL by -framework OpenGL

Can't compile CUDA driver api sample under OS X

I'm trying to compile code that uses nvidia cuda driver api, but compilation return following error:
g++ -fPIC -o exec helloWorldDriverAPI.cpp.o -lcuda
ld: library not found for -lcuda
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [exec] Error 1
Here is sample code that i have problem with:
https://github.com/mciancia/CUDA-Driver-api
I tried pointing libraries folder manually but it didn't work for me.
Also, i don't have any problems with compiling this code under Linux.
I'm using macbook with nvidia 750m under os x 10.10 and latest driver (6.5)
This was answered elsewhere, copying the answer here to get it off the unanswered list:
You need to add the location of the library.
The LIB_CUDA variable in your Makefile should be:
LIB_CUDA := -L/usr/local/cuda/lib -lcuda