Compiling on windows with 6.0.0 or 6.0.1
ld.lld can't find the library in specified path.
This does not work:
ld.lld Source.o -o Executable.exe -L"C:/Users/Username/Documents/" libcode.a
But this does:
ld.lld Source.o -o Executable.exe C:/Users/Username/Documents/libcode.a
Am I doing something wrong here?
It works with gnu ld just fine.
-l flag is required, omitting the "lib" prefix and extension.
ld.lld Source.o -o Executable.exe -L"C:/Users/Username/Documents/" -lcode
Related
In macOS Sierra, installation for xgboost with openmp enabled always fails.
From https://xgboost.readthedocs.io/en/latest/build.html,
I've tried:
cp make/config.mk ./config.mk; make -j4
With,
export CC=/usr/local/Cellar/llvm/4.0.0_1/bin/clang
export CXX=/usr/local/Cellar/llvm/4.0.0_1/bin/clang++
export CXX1X=/usr/local/Cellar/llvm/4.0.0_1/bin/clang++
It fails with,
clang-4.0clang-4.0: : warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]warning:
argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
ld: library not found for -lomp
ld: library not found for -lomp
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
llvm support openmp, but it fails with ld: library not found for -lomp
related question
Install xgboost on Mac - ld: library not found
But, clang-omp goes to boneyard, and discontinue with llvm's OpenMP support.
I've drilled down to, (with -v option)
/usr/local/Cellar/llvm/4.0.0_1/bin/clang++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -shared -o lib/libxgboost.so build/learner.o build/logging.o build/c_api/c_api.o build/c_api/c_api_error.o build/common/common.o build/common/hist_util.o build/data/data.o build/data/simple_csr_source.o build/data/simple_dmatrix.o build/data/sparse_page_dmatrix.o build/data/sparse_page_raw_format.o build/data/sparse_page_source.o build/data/sparse_page_writer.o build/gbm/gblinear.o build/gbm/gbm.o build/gbm/gbtree.o build/metric/elementwise_metric.o build/metric/metric.o build/metric/multiclass_metric.o build/metric/rank_metric.o build/objective/multiclass_obj.o build/objective/objective.o build/objective/rank_obj.o build/objective/regression_obj.o build/tree/tree_model.o build/tree/tree_updater.o build/tree/updater_colmaker.o build/tree/updater_fast_hist.o build/tree/updater_histmaker.o build/tree/updater_prune.o build/tree/updater_refresh.o build/tree/updater_skmaker.o build/tree/updater_sync.o dmlc-core/libdmlc.a rabit/lib/librabit.a -pthread -lm -fopenmp
SOLVED
cd /usr/local/lib
ln -s /usr/local/Cellar/llvm/4.0.0_1/lib/libomp.dylib libomp.dylib
llvm installation miss its symbolic link.
In my case I solved adding the following linker flag in addition to -lomp:
-Lpath_to_libomp.dylib_folder
or something like:
-Llib/
In my case I used a version of clang that came with Homebrew's llvm instead of the one that came with the Laptop from the factory, and it worked.
An executable I'm compiling needs the rpath to a library file at runtime. Currently, I'm compiling the executable with,
clang -O3 -mllvm -polly -mllvm -polly-target=gpu vector_add.c -lGPURuntime -ldl
And then using either of the following methods to provide the rpath,
Adding it to LD_LIBRARY_PATH
Using patchelf --set-rpath $RPATH a.out
I need a method to indicate the rpath in the clang .... command itself.
I'm running clang5.0.0-svn(7cf8dd5ce168bed45b57e019149e33300c56f94b) and llvm-svn(85f508cd9dba8a982471d98c4f649fb0d63f3451) with ld.gold in Ubuntu 14.04 x86_64.
Thank You !
Use clang ... -Wl,-rpath,/path/to/run-time/library's/dir/. It's a gcc style option that works in clang too.
I'm trying to compile GNU bash 4.3.30 on (and for) my iPad 2, iOS 8.4 using Clang, ld64, cctools, GNU make and the iOS 8.1 SDK. When processing bashversion, Clang is "unable to execute dsymutil", and reports that it "doesn't exist", exiting with error 1.
$ make
(...)
"/usr/bin/ld" -demangle -dynamic -arch armv7 -iphoneos_version_min 5.0.0 -syslibroot /var/mobile/iPhoneOS8.1.sdk -o bashversion -lcrt1.3.1.o -L./lib/termcap /var/tmp/bashversion-814fa1.o buildversion.o -lSystem
"dsymutil" -o bashversion.dSYM bashversion
clang: error: unable to execute command: Executable "dsymutil" doesn't exist!
clang: error: dsymutil command failed with exit code 1 (use -v to see invocation)
make: *** [bashversion] Error 1
$ echo $CC
clang --sysroot /var/mobile/iPhoneOS8.1.sdk -v
$ clang --version
clang version 3.5.0 (trunk)
Target: armv7-apple-darwin-14.0.0
Thread model: posix
$ ld -v
#(#)PROGRAM:ld PROJECT:ld64-
configured to support archs: i386 x86_64 armv4t armv5 armv6 armv7 armv7f armv7k armv8 arm64 arm64v8
$ which dsymutil
$ dsymutil
-sh: dsymutil: command not found
$ find / -name dsymutil
$
Apparently, my iPad has no dsymutil. So, where can I find one? Does it come with Xcode? Or is there any way to compile GNU bash 4.3.30 without it?
Dsymutil is a closed source tool, and is not available for iOS.
But that's not much of a problem, just create a symlink to /bin/true,
i.e.
ln -s /bin/true /usr/bin/dsymutil
I am trying to compile the VLC project for iOS, following the instruction step by step.
git clone git://git.videolan.org/vlc-ports/ios.git
sh buildAspenProject.sh -s -k 7.0
And I get this compiling error:
cd builds/unix; /bin/sh ./configure '--without-png' '--prefix=/Users/change/Desktop/VLC_Library/ios/ImportedSources/vlc/contrib/i686-apple-darwin11-i386' '--build=i686-apple-darwin10' '--host=i686-apple-darwin11' '--target=i686-apple-darwin11' '--program-prefix=' '--enable-static' '--disable-shared' '--disable-dependency-tracking' '--with-pic'
configure: WARNING: unrecognized options: --disable-dependency-tracking
checking build system type... i686-apple-darwin10
checking host system type... i686-apple-darwin11
checking for i686-apple-darwin11-gcc... xcrun clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether xcrun clang accepts -g... yes
checking for xcrun clang option to accept ISO C89... none needed
checking how to run the C preprocessor... xcrun cc -E
checking for i686-apple-darwin10-gcc... no
checking for gcc... gcc
checking for gcc... (cached) gcc
checking for suffix of native executables... rm: conftest.dSYM: is a directory
ld: building for MacOSX, but linking against dylib built for iOS Simulator file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libSystem.dylib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure: error: native C compiler is not working
make[1]: *** [setup] Error 1
make: *** [.freetype2] Error 2
The environment:
XCode 5.0
MountainLion 10.8.4
iPhoneSimulator SDK 7.0
The invocation
$ ld -v
#(#)PROGRAM:ld PROJECT:ld64-224.1
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 armv6m armv7m armv7em
LTO support using: LLVM version 3.3svn, from Apple Clang 5.0 (build 500.2.75)
How do I fix this problem?
Appreciate if any suggestion or idea.
That got me further but got stumped by missing download URL for modplug-xmms.
VLC is insisting on downloading a copy of the source from
MODPLUG_GIT_HASH := 9b08cc646c3dc94dd446ab0671e3427dae8a83fc
MODPLUG_URL := http://sourceforge.net/code-snapshots/git/m/mo/modplug-xmms/git.git/modplug-xmms-git-$(MODPLUG_GIT_HASH).zip
which does not exist as of this time. (Server down?)
I did find of the copy of the source under
http://sourceforge.net/projects/modplug-xmms/files/latest/download/libmodplug-0.8.8.4.tar.gz
I downloaded it and installed it manually:
../ios/ImportedSources/vlc/contrib/iPhoneSimulator-i386/libmodplug
This is a known problem with Xcode 5 for which I don't have a fix yet.
To workaround, go to ImportedSources/vlc/contrib/iPhoneSimulator-i386 and run "make .freetype2". Afterwards, go back to the top directory and run the buildAspen script again.
Note that you'll need to do the same thing (with "iPhoneOS-armv7" and "iPhoneOS-armv7s" respectively) if you decide to compile for iOS devices at a later point.
I hope to fix this shortly. Enjoy hacking VLC for iOS!
I cannot seem to get this to work. I configured with the --with-gcc-toolchain= where after the equals I put the directory where gcc was (/usr/lib/gcc-snapshot/bin).
I also looked into the answers to " clang linker problem" but I do not see how I can get the accepted answer to find the correct location, and the symlink answer would have worked, except that all of the directories that it is searching exist (copying the lib folder from gcc-snapshot to one of the include locations does not seem to help).
As suggested in the other question, the output of clang++ test.cpp -v:
bob#bob:~/programming$ clang++ test.cpp -v
clang version 3.3 (trunk 171350)
Target: x86_64-unknown-linux-gnu
Thread model: posix
"/home/bob/programming/build/Release+Asserts/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name test.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.22 -momit-leaf-frame-pointer -v -resource-dir /home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/bob/programming -ferror-limit 19 -fmessage-length 80 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o /tmp/test-PWiB4M.o -x c++ test.cpp
clang -cc1 version 3.3 based upon LLVM 3.3svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
test.cpp:1:10: fatal error: 'iostream' file not found
#include
^
1 error generated.
clang version 3.3 (trunk revision 171350)
EDIT: There are no .o files in the Release+Asserts folder for the build. Is this normal? If not, why is this the case, and how can I fix it (if I can point it as clang's stdlib, then that works as well).
Edit 2: It also fails to compile int main(){return 0;} as it can't find crtbegin.o. Full output is as follows:
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The results after -v are the same as the above, but with the ending error being different.
Config.log:
The full file can be found here, but the first (non-comment) line is: $ ../llvm/configure --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc
The issue that we've identified is that gcc was installed with --prefix=/usr/lib/gcc-snapshot configure argument. and llvm was configured with --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc argument. It should be the same as the gcc installation prefix, i.e. --with-gcc-toolchain=/usr/lib/gcc-snapshot.
The question's current first line says " I configured with the --with-gcc-toolchain= where after the equals I put the directory where gcc was (/usr/lib/gcc-snapshot/bin).", and the current last line says "first (non-comment) line is: $ ../llvm/configure --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc"
That's puzzling, you might have thought that you had put the flag --with-gcc-toolchain=/usr/lib/gcc-snapshot/bin but you had actually put --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc
Regardless, I think you should try the following.
remove or rename the build directory (the directory where you ran the configure command, i.e. the directory where you found the config.log file) I assume it's the /home/bob/programming/build directory.
now create /home/bob/programming/build directory again. it should be empty now.
cd /home/bob/programming/build
run the following configure command
../llvm/configure --with-gcc-toolchain=/usr/lib/gcc-snapshot
follow through with the rest of your build process.
The issue seems to be that you didn't specify the gcc-toolchain prefix correctly. It should be the same as the --prefix parameter you used while configuring the gcc.
Report back the results here.
Also see Clang 3.2 build broken after building gcc 4.7