I'm running a fedora 21 distribution, in which the default gcc is 4.9.
I have a custom built gcc/g++ 4.8 in /usr/local/gcc48 (for instance, cuda requires gcc =< 4.8, and i use update-alternatives to chose this one)
I have been compiling a few small programs with this version 4.8 without problem so far.
Now, I have been given a source code which makes uses of vtk libraries and others. If I use default gcc 4.9, cmake and make work fine.
However, when using gcc48, I get:
/usr/lib64/vtk/libvtkCommonDataModel.so.1: référence indéfinie vers « std::__throw_out_of_range_fmt(char const*, ...)#GLIBCXX_3.4.20 »
/lib64/libicuuc.so.52: référence indéfinie vers « __cxa_throw_bad_array_new_length#CXXABI_1.3.8 »
collect2: erreur: ld a retourné 1 code d'état d'exécution
CMakeFiles/main.dir/build.make:365: recipe for target '../bin/main' failed
make[2]: *** [../bin/main] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/main.dir/all' failed
make[1]: *** [CMakeFiles/main.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2
I understand that is it a linker error, I tried to point LD_LIBRARY_PATH=/usr/local/gcc48/lib or LD_LIBRARY_PATH=/usr/local/gcc48/lib64, but i'm stuck.
What is the problem here ?
Thanks
__cxa_throw_bad_array_new_length was added in GCC 4.9. That's what the #CXXABI_1.3.8 version suffix means. You can look up those version codes here:
https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
This error means that you are trying to link an object file /usr/lib64/vtk/libvtkCommonDataModel.so.1 compiled by GCC 4.9 or later with libstdc++.so or libsupc++.so from GCC 4.8 or earlier. Either rebuild libvtkCommonDataModel.so with GCC 4.8, or link against the correct libstdc++.so.
Edit:
Actually, if you want to compile with a newer version of GCC but run with an older libstdc++.so, that can be done.
Compile with -D_GLIBCXX_USE_CXX11_ABI=0 if you want to compile with GCC 5+ and run with libstdc++.so from older GCC. See https://bugzilla.mozilla.org/show_bug.cgi?id=1153109 and Using dual ABI in the libstdc++ manual.
Link against stdc++compat.cpp containing back-compat hacks from Mozilla. You can also take a look at my modified version which doesn't depend on any Mozilla headers, but it's slightly out of date.
In particular, this defines a stub __cxa_throw_bad_array_new_length.
It would be helpful if you post the error message in English.
It appears that the undefined symbol is __cxa_throw_bad_array_new_length. The functions __cxa... come from the C++ runtime library. G++ usually ships with it's own version of this library, called libsupc++. I would guess that the custom-built G++ can not find this library or is emitting a reference to a symbol which is not in the newer (4.9) libsupc++. Try compiling the libsupc++ source that ships with your custom version of G++ and directing the linker toward it. You may also need to do this for libstdc++.
Related
I tried to complile this project: https://github.com/ccshiro/corecraft
I am use Ubuntu 16.04, i have installed: gcc 4.9, 5.0, 6.0; g++ 4.9, 5.0; clang; cmake3; and libsparsehash-dev .
I got this error:
[ 96%] Linking CXX executable mangosd
../game/libgame.a(Map.cpp.o): In function `sh_hashtable_settings<ObjectGuid, std::tr1::hash<ObjectGuid>, unsigned long, 4>::hash(ObjectGuid const&) const':
/usr/include/google/sparsehash/hashtable-common.h:65: undefined reference to `std::tr1::hash<ObjectGuid>::operator()(ObjectGuid) const'
collect2: error: ld returned 1 exit status
src/mangosd/CMakeFiles/mangosd.dir/build.make:244: recipe for target 'src/mangosd/mangosd' failed
make[2]: *** [src/mangosd/mangosd] Error 1
CMakeFiles/Makefile2:930: recipe for target 'src/mangosd/CMakeFiles/mangosd.dir/all' failed
make[1]: *** [src/mangosd/CMakeFiles/mangosd.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Here Map.cpp , here /usr/include/google/sparsehash/hashtable-common.h
I ve tried to google about "collect2: error: ld returned 1 exit status" error, and found that in code might be cyrrilics or non latinics symbols, but i didnt find something wrong in this 2 files above.
On issue tracker i also found same error from another person https://github.com/ccshiro/corecraft/issues/5
I am not C++ programmer so i cant understand what wrong is here, can anyone help me with this?
What you are seeing is a linker error. Everything compiles fine, and then when the linker starts to stitch the code together it's missing a object that defines the functionality of the std::tr1::hash<ObjectGuid>::operator() hash operator. This is a template specialization that allows this object to be used as a unique key in a map (or hash set).
The template for the hash function is specified here. At first glance, I wasn't seeing why it shouldn't link, but then I realized that the linker is looking for std::tr1::hash<ObjectGuid> instead of std::hash<ObjectGuid>. Basically, it looks like your STL library is using TR1 which is an older pre-standard version of C++11.
Your first attempt should be to figure out how to specify that your compiler uses a newer version of the STL library. You should be able to add -std=c++11 to the CMAKE C++ flags (instead of -std=c++0X). Whether this means editing the CMakeLists.txt file to include the flag or making sure that your compiler was installed with a more modern version of STL.
That should fix the problem. I can think of another solution, but I suspect that you will get more errors by linking to an older version of STL.
I am trying to compile qt-dab by using the command line:
qmake qt-dab.pro
make
But I get these error messages:
/usr/bin/ld : ne peut trouver -lqwt-qt5
collect2: error: ld returned 1 exit status
make: *** [linux-bin/qt-dab-0.998] Erreur 1
"qmake -v" gives me QMake version 3.0 using Qt version 5.2.1 in /usr/lib/x86_64-linux-gnu.
Moreover, I installed the qwt-6.1.3 library. Is there a solution for this?
The linker can not find the library: qwt-qt5.
If you've installed the qwt library, you will want to find where it is located.
It sounds like you may have installed version 6 of the library,
but are trying to link with version 5 (which may be non-existent on your machine).
When you find the correct library on your system, you can tell the linker which to directories to search for it using the -L flag.
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.
I've just compiled latest reps of LLVM, Clang and libc++. Now however I have no idea how to configure the environment to use them. I've added in $PATH the one to compiled binaries and have set the
$D_LIBRARY_PATH=$(llvm-config --libdir)
but anyway when I test run 'clang' with example file it uses some '/usr/bin/ld' linker which I have no idea what is it (as I've uninstalled 'g++' because thought it was the problem (before 'clang' used some linker from it) and I don't have any other C++ compilers).
So now how do I point out the right 'llvm-ld', libc++ include and library paths? I don't want to pass some complex arguments every-time. Perhaps I should set some environment variables.
I'm also using KDevelop with the same effect.
Don't judge me if this sounds stupid but it's my first time with Linux (have always used Windows before). I'm using latest 'OpenSUSE' dist.
Update - here is the output window of CodeLite using clang compiler:
/bin/sh -c 'make -j 2 -e -f Makefile'
----------Building project:[ ClangTest - Debug ]---------- make[1]: Entering directory
'/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Workspace/CL_C++_WP/ClangTest'
clang++ -c
"/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Workspace/CL_C++_WP/ClangTest/main.cpp"
-stdlib=libc++ -o ./Debug/main.cpp.o -I. -I/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Build/include/c++/v1/
clang++ -o ./Debug/ClangTest #"ClangTest.txt" -L.
-L/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Build/lib/ /usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lstdc++ /usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lgcc clang-3.7: error: linker command failed
with exit code 1 (use -v to see invocation) ClangTest.mk:76: recipe
for target 'Debug/ClangTest' failed make[1]: * [Debug/ClangTest]
Error 1 make[1]: Leaving directory
'/run/media/bs_ld/8688602a-296d-40e1-bd37-c90e69f45769/Workspace/CL_C++_WP/ClangTest'
Makefile:4: recipe for target 'All' failed make: * [All] Error 2 0
errors, 0 warnings
You should be able to run make install with perhaps an optional DESTDIR=/...... so that it doesn't clobber your system files.
Since you're on OpenSUSE, you might as well use your distribution's build services, and install the SVN version of LLVM-Clang from here. You should be able to find libc++ and LLVM itself as well.
Otherwise, make install DESTDIR=/opt/llvm should work, and then you can add /opt/llvm/bin/ to PATH and use libc++ by adding this compile and link option: -stdlib=libc++. You'll need something like /opt/llvm/lib in LD_LIBRARY_PATH as well to find the libc++ so.
This should work pretty much out of the box, but I have only ever used my distribution's packages, not a self-built Clang to do this.
Note that Clang still uses your system linker, ld, and this is fine. Currently, LLVM does not yet provide a fully functional alternative to this program, but they are working on it.
EDIT: It seems you uninstalled too much: Clang also uses the GCC crtbegin and crtend object files. So just install GCC again along with glibc and its dev package.
I am currently trying to build llvm 3.3 on Windows through Cygwin.
The compilation is going fine, but the build crashes during linking with this error:
llvm[2]: ======= Finished Linking Release+Asserts Executable llvm-mc (without symbols)
make[2]: Leaving directory `/cygdrive/c/Users/Jupotter/Code/llvm-3.3.src/build/tools/llvm-mc'
llvm[2]: Compiling ExecutionDriver.cpp for Release+Asserts build
/cygdrive/c/Users/Jupotter/Code/llvm-3.3.src/build/Release+Asserts/lib/libLLVMMCJIT.a(SectionMemoryManager.o):SectionMemoryManager.cpp:(.text+0x3b): référence indéfinie vers « __register_frame »
/cygdrive/c/Users/Jupotter/Code/llvm-3.3.src/build/Release+Asserts/lib/libLLVMMCJIT.a(SectionMemoryManager.o):SectionMemoryManager.cpp:(.text+0x3b): relocalisation tronquée pour concorder avec la taille: R_X86_64_PC32 vers le symbole indéfini __register_frame
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/c/Users/Jupotter/Code/llvm-3.3.src/build/Release+Asserts/lib/libLLVMMCJIT.a(SectionMemoryManager.o): mauvaise adresse de relocalisation 0x0 dans la section «.pdata»
In English:
undefined reference to "__register_frame
relocation truncated to concord with size: R_X*^_^$_PC32 to undefined symbol __register_frame
wrong relocation address in 0x0 in section ".pdata"
I build llvm with these commands:
$ mkdir build
$ cd build
$ ../configure LDFLAGS=-Wl,--stack,16777216 --disable-jit --enable-targets=host-only
$ make -j4
The LDFLAGS options come from llvm getting started guide for win64 platform. I tried disabling jit since it seem to be libLLVMCJIT where there is a problem.
Any idea what could cause this build to fail?
I have met the same error when compiling llvm on Cygwin(x86_64). But I can compile it on Cygwin(x86) successfully.
External function __register_frame is part of libgcc or other compiler library but only for x86. It looks like you have compiled some code in 32-bit mode or used 32-bit library.