llvm toy example error - llvm

I am trying to run the make file of the toy example given here, but it gives me the following error:
g++ -o parser parser.o codegen.o main.o tokens.o corefn.o native.o `llvm-config
--libs` `llvm-config --ldflags` -lpthread -ldl -L/usr/bin -lz -lncurses -rdynamic
/usr/bin/ld: cannot find -lz
/usr/bin/ld: cannot find -lncurses
collect2: error: ld returned 1 exit status
Makefile:31: recipe for target 'parser' failed
make: *** [parser] Error 1
The software I am using is:
clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Ubuntu is a virtual machine running on Windows 8.1.
Any comment will be appreciated.

Related

compilation of Makefile gives 'ld returned, DSO missing' errors

I am new to the Unix system; have been trying to install and compile a code using a Makefile, but I get the following error:
gcc -o ../zmass zmass.o useful.o open.o -O3 `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
/usr/bin/ld: zmass.o: undefined reference to symbol 'pow##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [../zmass] Error 1
Could anybody help me with this? I have already installed gtk+-2.0.
You need to add -lm after `pkg-config --libs gtk+-2.0` in your Makefile

undefined reference gcc cxa

I'm trying to compile a program with make, but I get stuck on a error raised (see below) :
gcc -Wall -g -O2 -I. -I../include -I/usr/include/libxml2/ -I/usr/include/x86_64-linux-gnu/ -I/usr/include/geotiff/ -I/usr/local/hdf4/hdf-4.2.11/hdf4/include/ -I/usr/local/hdf-eos/hdfeos/include/ -I -I -o convert_lpgs_to_espa convert_lpgs_to_espa.o -L../lib -l_espa_format_conversion -l_espa_raw_binary -l_espa_common -L/usr/lib/x86_64-linux-gnu/ -lxml2 -L/usr/lib/ -lgeotiff -L/usr/lib/x86_64-linux-gnu/ -ltiff -L/usr/lib/x86_64-linux-gnu/ -ljpeg -L -ljbig -L/usr/local/hdf-eos/hdfeos/hdfeos2/lib -lgctp -L -lz -lm
/usr/lib/x86_64-linux-gnu/libicuuc.so.52: référence indéfinie vers « __cxa_throw_bad_array_new_length#CXXABI_1.3.8 »
collect2: error: ld returned 1 exit status
Makefile:95: recipe for target 'convert_lpgs_to_espa' failed
make[1]: *** [convert_lpgs_to_espa] Error 1
make[1]: Leaving directory '/project/$folders$/tools'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2
Following this close question : program linking fails when using custom built gcc, I purge and reinstall libstdc++-4.9-dev.
I'm running
Ubuntu 15.04 with gcc (Ubuntu 4.9.2-10ubuntu13) 4.9.2
How can I resolve this issue ?
It's because you link using gcc instead of g++. The difference is that the g++ command adds the C++ runtime library when linking.
You can either change from using gcc to g++, or manually link with the C++ runtme library by adding -lstdc++.

C++/R: clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am trying to install and run a this project. It is written in C++ and R. I follow the instructions and when I type the make command, I get this error:
R CMD SHLIB src/C/util.c src/C/factor_model_util.c src/C/pagerank.c src/C/hierarchical.c src/C/factor_model_multicontext.c src/C/factor_model_util2.cpp -o lib/c_funcs.so
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o lib/c_funcs.so src/C/util.o src/C/factor_model_util.o src/C/pagerank.o src/C/hierarchical.o src/C/factor_model_multicontext.o src/C/factor_model_util2.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 -lgfortran -lquadmath -lm -Wall -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [lib/c_funcs.so] Error 1
make: *** [c_funcs] Error 1
Here is my "clang --version" results:
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
Does anyone know what should I do? I saw the answers about xcode projects, but here I am only trying to use make for compiling.
Thanks
I had a very similar issue, and solved it by installing the newer gfortran 4.8.2. For some reason the main page links to version 4.3.2, which causes this issue (I believe because R binaries are actually built with a newer gfortran).

How to build llvm example's ModuleMaker by using clang++

I'm trying to build ModuleMaker from the LLVM example.
When I invoke:
clang++ -g ModuleMaker.cpp `llvm-config --cppflags --ldflags --libs core jit native` -o ModuleMaker
I received the error message:
/home/huangered/Desktop/ModuleMaker/main.cpp:59: undefined reference to `llvm::WriteBitcodeToFile(llvm::Module const*, llvm::raw_ostream&)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How can I fix this?
clang++ main.cpp `llvm-config --cppflags --ldflags --libs core jit native bitwriter` -o main
o.i get it. i should add a bitwriter component into the llvm-config.

Libpqxx complaining about missing references

So I have the following problem:
g++ -std=c++0x -O3 -I/usr/include/scip main.cpp locations/locationreader.cpp locations/locationassigner.cpp scheduler.o optimizer.o dbmanager.o scheduleData.o exam.o -o main -L/usr/lib -lscip -lreadline -lgmp -lz -llpispx -lsoplex -lobjscip -lnlpi.cppad -lscipopt -lzimpl -lpqxx -lpq -pthread
/usr/lib/../lib64/libpqxx.so: undefined reference to `PQescapeIdentifier'
collect2: error: ld returned 1 exit status
make: *** [main] Error 1
And I cannot figure out why it cannot find the reference because I have libpq installed and its right there in /usr/lib64
$ ls | grep pq
libpq.so
libpq.so.5
libpq.so.5.2
libpqxx-4.0.so
libpqxx.so
So if I could get any help with this that would be lovely
PQescapeIdentifier appeared in PostgreSQL 9.0, which corresponds to libpq.so.5.3
9.0 release notes have this entry:
Add libpq functions PQescapeLiteral() and PQescapeIdentifier() (Robert
Haas)
You seem to use client libraries from PostgreSQL-8.4 (libpq.so.5.2), that would be why it lacks this function.