I am a llvm beginner. I run the command:
../llvm-6.0.0.src/build/bin/opt -load=./test.so -Hello < main.bc
according to the tutorial but got the error:
opt: CommandLine Error: Option 'use-dbg-addr' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
I googled again and again, and got nothing about this error.
You need a LLVM build with shared libraries enabled, which corresponds to cmake options BUILD_SHARED_LIBS=On. You can check what type of LLVM you have installed by either checking its lib directory or executing:
llvm-config --shared-mode
This should report shared; anything else will require you to recompile.
Related
I am trying to install the xlnt library on Ubuntu 18. I have installed xlnt exactly as the instructions say on the repo. When I try to compile my code, the following error pops up:
/usr/bin/ld: cannot find -lxlnt
collect2: error: ld returned 1 exit status
makefile:204: recipe for target 'BOF-debug-static' failed
make: *** [BOF-debug-static] Error 1
I have been installing other libraries to get the code working, and I've noticed that the other libraries are creating .a files at /usr/local/lib along with a few other .la, and .so files. When I install xlnt, it is not creating any .a files, but does create a .so and .so.1.2 files. Not sure if that is relevant, but it's something I've noticed.
How do I make xlnt discoverable to g++ and get the -lxlnt flag to work?
The target you are building BOF-debug-static is evidently one that requests
either a fully static linkage, with the -static linkage option, or possibly one that
requests static linkage specifically of libxlnt, with a linkage option such as:
-Wl,-Bstatic -lxlnt -Wl,-Bdynamic
Since, as you observed, libxlnt by default provides only a shared/dynamic library libzlint.so ( -> libzlint.so.X.Y.Z),
and no static library libzlnt.a, the linker ignores the the shared library when
required to link -lxlnt statically and says:
/usr/bin/ld: cannot find -lxlnt
You cannot link a shared library statically.
However, if you configure the CMake build system with:
cmake -DSTATIC=ON [your previous options...]
then make will build a static library and running make install (as root) will create /usr/local/lib/libxlnt.a.
I am trying to run an example program (comes with installation of Armadillo library) in Xcode and getting the following error:
linker command failed with exit code -1 (use -v for invocation)
I can't figure out what's going in from Google searches.
I can build and run the program on the command prompt using:
g++ example1.cpp -O2 -larmadillo
Here's my build setting:
Here's my search path to include the armadillo.h header:
My code is:
The actual error is:
I was able to build successfully by installing macport.
Here are the steps:
Download and install macport from https://www.macports.org/.
Set Library path as /opt/local/lib.
Set Header path as /opt/local/include.
Set Other Linker Flags as -larmadillo.
I use Code::Blocks IDE with wxWidgets in Debian 8.9 Jessie (x86-64).
When I use the GNU GCC Compiler everything works fine thus compiling nice wxWidgets executable for Linux.
But I need to have my program working on Windows platforms so I have to do cross-compiling.
I have installed mingw32 and followed the cross-compiling instructions given
here.
I did my wxWidgets build configuration as follows:
./configure prefix=/usr/i686-w64-mingw32 --host=i686-w64-mingw32 --enable-unicode --build=`./config.guess` --disable-shared
This is so because the MinGW compiler I have is i686-w64-mingw32, located in the folder /usr/i686-w64-mingw32, and wxWidgets version is 3.1.
My compiler set-up in Code::Blocks should be correct because I managed to do cross-compiling for simple console applications and those run properly on Windows 10.0. But when it comes to wxWidgets applications there are several problems:
The compiler gives me the error (it happens when --static is added to Other compiler options in the build options for the project):
fatal error: wx/app.h: No such file or directory|
Now since wx directory in question is in the path /usr/i686-w64-mingw32/include/wx-3.1 I added this path to the search directories for the project (the build target only for the moment). This worked fine to proceed further.
My compiler settings are: wx-config --host=i686-w64-mingw32 --static --cflags
The compiler swears again (not surprised though :-)):
fatal error: wx/setup.h: No such file or directory|
Ok I've found this one in /usr/i686-w64-mingw32/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.1, so added this path to the compiler search directories.
The linker is swearing this time (creeping on my nerves):
for the build target:
undefined reference to `wxEntry(HINSTANCE__*, HINSTANCE__*, char*, int)'|
for the release target:
undefined reference to `wxAppConsoleBase::CheckBuildOptions(char const*, char const*)'|
My linker settings are wx-config --host=i686-w64-mingw32 --static --libs
I tried hard to fix this with several different build options for the wxWidgets library but with no effect on the result. So please, someone help!
I also noticed that running ./config.guess form the wxWidgets download directory gives me x86_64-unknown-linux-gnu. Thus this mean I should use x86_64-w64-mingw32 (I have this one installed in /usr/x86_64-w64-mingw32) compiler instead i686-w64-mingw32?
So the main issue is that the command wx-config --static --cflags is not recognized in Other compiler options and wx-config --static --libs is not recognized in Other linker options.
The problem persisted even though I added the path to wx-config file in the .bashrc file from the home directory, i.e. export PATH="$PATH:/usr/i686-w64-mingw32/bin". At that time I was able to run wx-config from the terminal at any location.
To solve it I've changed the options to /usr/i686-w64-mingw32/bin/wx-config --static --cflags in Other compiler options and /usr/i686-w64-mingw32/bin/wx-config --static --libs in Other linker options. This worked as a charm.
I've added the location of libstdc++-6.dll (simply found it with a search in the file manager) in Link libraries and the flags -static and -static-libgcc in Other linker options and finally did the testing with the minimal sample as Igor suggested. Just create new console application, add minimal.cpp file to it and all of the mentioned above.
The compiler did a Minimal.exe file that I have opened successfully with wine.
Note: All the include directories I mentioned in my question were in wx-config --cflags for the compiler and wx-config --libs for the linker, so no need to add them in search directories.
I was trying an openmp code with clang compiler as specified in
http://clang-omp.github.io/
I downloaded the code via git and did make and make install. It successfully installed the clang compiler with openmp support. But when I try to compile a sample code (specified in the above link), I get the following error :
/usr/bin/ld: cannot find -liomp5
I did not specify path to include and lib as mentioned in the site, but I intend to specify them while compiling on command line with -L and -I options.
$clang -I/usr/lib/gcc/i686-linux-gnu/4.6/include -fopenmp test.c -o test
However, I could not find path for iomp5 lib and hence I got the above error. Can someone please tell me how to resolve this?
At first you need to build openmp library libiomp5. You can take the latest source code here
http://llvm.org/svn/llvm-project/openmp/trunk/
I am trying to build and link a C++, cmake-based project with clang (3.0). This project links to several libraries that are installed in a custom directory /my/dir/. This directory is included in the LD_LIBRARY_PATH and LIBRARY_PATH environment variables. Project builds and links fine with g++.
The link command generated and executed by cmake looks like the following:
/usr/bin/clang++ -O3 stuff.cpp.o -o stuff -rdynamic -lmylib
ld then complains with the following message:
/usr/bin/ld: cannot find -lmylib
The link command above runs fine whenever I manually add -L/my/dir/. Is there a way to link without specifying the -L flag?
The $LD_LIBRARY_PATH environment variable (and its various alternatives on other UNIX-based platforms) is used at runtime, not link time, to find libraries.
Using -L is the correct approach and cannot be avoided.
Note: A better approach under Linux (you don't specify your platform so I'm guessing) is to correctly configure a file in /etc/ld.so.conf.d/ and avoid using $LD_LIBRARY_PATH altogether.