Can't compile CUDA driver api sample under OS X - c++

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

Related

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

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?

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

How to resolve build errors in OSX cctools?

I am attempting to build tools from the CCtools collection for OSX, under OSX. I am doing this for research purposes.
When I run the makefile for the entire project I get a linker error:
=========== /Applications/Xcode.app/Contents/Developer/usr/bin/make all for misc =============
cc -Os -DLTO_SUPPORT -DTRIE_SUPPORT -g -Wall -I. -I./../include -I. -I/usr/local/include -c -o ./lipo.o lipo.c
cc -nostdlib -r \
-o ./lipo.private.o \
./lipo.o -L./../libstuff -lstuff
cc -o ./lipo.NEW \
./lipo.private.o
Undefined symbols for architecture x86_64:
"_is_llvm_bitcode_from_memory", referenced from:
_main in lipo.private.o
_check_archive in lipo.private.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [lipo.NEW] Error 1
make: *** [all] Error 1
Running the make files of the individual tools nets me a similar linker error. This occurs for all versions of the CCtools I have tried (Including 877.5, the latest source, and 862, the version that my installed tools are at.)
What am I missing to make the tools compile?
How can I coax the linker to let me know what library I am missing?
Where can I find instruction to make the tools compile?
Additional info:
I have XCode and developer tools installed, and I build projects all the time.
I also have gcc installed from brew.
I must be missing something stupid.
I cannot give you the exact solution for your version 877.5 but the overall problem is that the compilation requires some of the LLVM code on your machine. It might be as simple as missing include directories for the LLVM headers or can require linking some of the LLVM libraries. In your case, they seem to be related to LLVM Bitcode somehow.
In my case, I have just built a subset of the more recent version cctools-895. It complained about a missing symbol related to LLVM's llvm-c/lto.h header. The error went away when I added the following to the problematic file's compilation rules:
-I/opt/llvm-7.0.0/include/
The version of LLVM 7 was a random guess that worked because I had it on my machine. You might want to tailor your include paths to point to the correct version of LLVM that the cctools are supposed to be built with.
The easiest way to get the LLVM on your machine is to get a binary version from the LLVM Download page.

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

Installing Moses Translation Software. Error message: "ld: library not found for -lboost_thread"

I am installing the Moses Translation Software on my Mac OS X 10.9.5 with Xcode 6.1. The instructions say that I need g++ and Boost installed. Once I do that, I git clone, "cd" into the directory, and then type ./bjam -j8. First, I verified I have the prerequisites. First, g++ (I just clicked the TAB to see what was available):
$ g++
g++ g++-4.9
Then boost:
$ brew install boost
Warning: boost-1.56.0 already installed
Then I tried installing:
$ ./bjam -j8
Tip: install tcmalloc for faster threading. See BUILD-INSTRUCTIONS.txt for more information.
mkdir: bin: File exists
...patience...
...patience...
...found 4469 targets...
...updating 155 targets...
darwin.link lm/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/query
ld: library not found for -lboost_thread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
// Additional error messages...
...failed darwin.link mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/util_test...
...skipped <pmert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi>util_test.passed for lack of <pmert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi>util_test...
darwin.link mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/vocabulary_test
ld: library not found for -lboost_thread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
"g++" -o "mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/vocabulary_test" "mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/VocabularyTest.o" "mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/libmert_lib.a" -lboost_unit_test_framework -llzma -lbz2 -ldl -lboost_system -lz -lboost_thread -lm -liconv -g -Wl,-dead_strip -no_dead_strip_inits_and_terms
...failed darwin.link mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/vocabulary_test...
...skipped <pmert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi>vocabulary_test.passed for lack of <pmert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi>vocabulary_test...
...failed updating 72 targets...
...skipped 83 targets...
The build failed. If you need support, run:
./jam-files/bjam -j8 --debug-configuration -d2 |gzip >build.log.gz
then attach build.log.gz to your e-mail.
You MUST do 3 things before sending to the mailing list:
1. Subscribe to the mailing list at http://mailman.mit.edu/mailman/listinfo/moses-support
2. Attach build.log.gz to your e-mail
3. Say what is the EXACT command you executed when you got the error
ERROR
There's a ton of error messages not shown (condensed into "// Additional error messages"), and they are all of the form "ld: library not found for -lboost_thread". So it's clear that something can't find a boost-related library, but I don't know how to fix this. Does anyone have suggestions? I literally just copied a couple of lines from the installation instructions, and Moses is popular enough such that an obvious error in the installation instructions would have been caught long ago.
Additional comment: On the installation instructions page, they list a command where they can force an installer to find the boost library:
./bjam --with-boost=~/workspace/temp/boost_1_55_0 -j8
My boost is in
/usr/local/Cellar/boost/1.56.0/
I tried substituting the --with-boost= argument with the above file path, but that did not work either (I got the same errors).
I'm going to post this on the Moses mailing list but I'd also want to ask here because I have gotten this same error ("library not found ... clang: error: linker command failed with exit code 1") with other software and it would be helpful for me to learn a general strategy for making sure that clang can find my libraries.
This package expects a non-standard layout of boost (or maybe that's the standard liayout for installed boost on many systems, but it certainly isn't the default layout for boost in my working directories):
bjam --help says:
--with-boost=/path/to/boost
If Boost is in a non-standard location, specify it here. This directory is
expected to contain include and lib or lib64.
When my Boost build tree is in
/home/sehe/custom/boost/boost // headeers
/home/sehe/custom/boost/stage
/home/sehe/custom/boost/stage/lib // libraries
I have created a "forwarding" directory - so I'm not required to install boost:
mkdir /tmp/boost-moses
cd /tmp/boost-moses/
ln -sfv /home/sehe/custom/boost/stage/lib lib
ln -sfv /home/sehe/custom/boost include
Now I could trigger a build in the mosesdecoder directory with
./bjam --with-boost=/tmp/boost-moses
It's not said here which Moses version ComputerScientist compiled, but his last comment hit the nail. When I was about to compile version 2.1.1, I needed to rewrite Jamroot file and jam-files/boost-build/tools/mpi.jam and change all the boost_mpi mentions to boost_mpi-mt. It seems to me that boost-1.55 used different library style then boost-1.56 and Moses was in that version adapted to 1.55.
However I am not able to compile Moses 3.0 with either boost-1.55 or boost-1.56 now because of undefined reference to boost::filesystem::path::stem().
Unfortunatelly I can not post this as a comment to previous answer...