Build error: bad reloc address - build

I am trying to build IPopt with MKL blas on a 64 bit machine using MingW 64,
I can go through the configure process using the command below:
../configure ADD_FFLAGS=-fopenmp --with-blas="-L/c/intel/COMPOS~1/mkl/lib/intel64 \
-lmkl_intel_lp64_dll -lmkl_intel_thread_dll -lmkl_core_dll -Wl,\
--rpath,/c/intel/COMPOS~1/mkl/lib/intel64" \
--with-lapack="-L/c/intel/COMPOS~1/mkl/lib/intel64 \
-lmkl_intel_lp64_dll -lmkl_intel_thread_dll -lmkl_core_dll -Wl,\
--rpath,/c/intel/COMPOS~1/mkl/lib/intel64"
and I get successful configuration message, However when I try to proceed with "make" I get an error as below:
g++ -O3 -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual
-Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-lon
g-long -DIPOPT_BUILD -o ipopt.exe ampl_ipopt.o -Wl,--rpath -Wl,"/c/intel/COMPOS~
1/mkl/lib/intel64" -Wl,--rpath -Wl,"/c/intel/COMPOS~1/mkl/lib/intel64" -Wl,--rpa
th -Wl,"/c/intel/COMPOS~1/mkl/lib/intel64" -Wl,--rpath -Wl,"/c/intel/COMPOS~1/mk
l/lib/intel64" -Wl,--rpath -Wl,"/c/intel/COMPOS~1/mkl/lib/intel64" ./.libs/libi
poptamplinterface.a ../../Interfaces/.libs/libipopt.a /home/Kevin/mybuild/coin
ipopt/build_64_intel/ThirdParty/ASL/.libs/libcoinasl.a /home/Kevin/mybuild/coi
nipopt/build_64_intel/ThirdParty/Mumps/.libs/libcoinmumps.a -L/c/intel/COMPOS~1/
mkl/lib/intel64 -Lc:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1 -Lc:/mingw6
4/bin/../lib/gcc -Lc:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../.
./x86_64-w64-mingw32/lib/../lib -Lc:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4
.7.1/../../../../lib -Lc:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../
../../x86_64-w64-mingw32/lib -Lc:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.
1/../../.. /home/Kevin/mybuild/coinipopt/build_64_intel/ThirdParty/HSLold/.lib
s/libcoinhsl.a -lgfortran -lgomp -lmingwthrd -lmingw32 -lgcc_s -lmoldname -lming
wex -lmsvcrt -lquadmath -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 /home
/Kevin/mybuild/coinipopt/build_64_intel/ThirdParty/Metis/.libs/libcoinmetis.a
-lmkl_intel_lp64_dll -lmkl_intel_thread_dll -lmkl_core_dll
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/libgcc.a(unwind-sjlj.o): In f
unction `_Unwind_SjLj_Register':
c:\crossdev\build\gcc-tdm64\x86_64-w64-mingw32\libgcc/../../../../src/gcc-4.7.1/
libgcc/unwind-sjlj.c:127: multiple definition of `_Unwind_SjLj_Register'
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/libgcc_s.a(d000017.o):(.text+
0x0): first defined here
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/libgcc.a(unwind-sjlj.o): In f
unction `_Unwind_SjLj_Unregister':
c:\crossdev\build\gcc-tdm64\x86_64-w64-mingw32\libgcc/../../../../src/gcc-4.7.1/
libgcc/unwind-sjlj.c:174: multiple definition of `_Unwind_SjLj_Unregister'
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/libgcc_s.a(d000020.o):(.text+
0x0): first defined here
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/libgcc.a(unwind-sjlj.o): In f
unction `_Unwind_SjLj_Resume':
c:\crossdev\build\gcc-tdm64\x86_64-w64-mingw32\libgcc/../../../../src/gcc-4.7.1/
libgcc/unwind.inc:220: multiple definition of `_Unwind_SjLj_Resume'
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/libgcc_s.a(d000018.o):(.text+
0x0): first defined here
c:/intel/COMPOS~1/mkl/lib/intel64/mkl_intel_lp64_dll.lib(_dgetrf_lp64.obj):(.tex
t[dgetrf]+0xb4): undefined reference to `__security_check_cookie'
c:/intel/COMPOS~1/mkl/lib/intel64/mkl_intel_lp64_dll.lib(_dgetrf_lp64.obj):(.tex
t[dgetrf]+0xf5): undefined reference to `__security_check_cookie'
c:/intel/COMPOS~1/mkl/lib/intel64/mkl_intel_lp64_dll.lib(_dgetrf_lp64.obj):(.xda
ta+0xc): undefined reference to `__GSHandlerCheck'
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw3
2/bin/ld.exe: c:/intel/COMPOS~1/mkl/lib/intel64/mkl_intel_lp64_dll.lib(_dgetrf_l
p64.obj): bad reloc address 0x1 in section `.text[DGETRF]'
collect2.exe: error: ld returned 1 exit status
make[3]: *** [ipopt.exe] Error 1
make[3]: Leaving directory `/home/Kevin/mybuild/coinipopt/build_64_intel/Ipopt
/src/Apps/AmplSolver'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/Kevin/mybuild/coinipopt/build_64_intel/Ipopt
/src/Apps'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/Kevin/mybuild/coinipopt/build_64_intel/Ipopt
'
make: *** [all-recursive] Error 1
I would be thankful if somebody could help with it.
Follow Up: I think I found what the error stems from,
when running configure, it goes back to the shared library of MKL and gets its path as (available in the configure log file):
/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler
which indeed its not a short path! so I guess this is raising the problem but I don't know how to force configure get short path! In addition, I am using Windows 8 64 bit, despite enabling 8.3 naming convention (Reg. Key set to 0) still I only get 8.3 name for some directories for example I don't get short path for Program Files and Program Files (x86).

Simple answer:
Intel MKL for windows does not provide compatibility with gnu compilers available with MingW!
Switched to OpenBlas and it was sorted.
Special Thanks goes to Tony Kelman.

Related

undefined reference compiling taskwarrior on arm chromebook

I tried to build task-2.5.1 on my armv81 chromebook inside a termux session. It didn't work due build dependencies so I installed them then uncompressed and started in a fresh new directory. When I ran make VERBOSE=1 I got an undefined reference to __atomic_fetch_add_4 when linking...
[ 98%] Linking CXX executable lex
cd /data/data/com.termux/files/home/src/task-2.5.1/src && /data/data/com.termux/files/usr/bin/cmake -E cmake_link_script CMakeFiles/lex_executable.dir/link.txt --verbose=1
/data/data/com.termux/files/usr/bin/c++ -Wall -Wsign-compare -Wreturn-type -std=c++11 -stdlib=libc++ -O3 -DNDEBUG -rdynamic CMakeFiles/lex_executable.dir/lex.cpp.o -o lex libtask.a commands/libcommands.a columns/libcolumns.a libtask.a -lgnutls -luuid
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: libtask.a(Nibbler.cpp.o): in function `Nibbler::Nibbler(Nibbler const&)':
Nibbler.cpp:(.text+0x8c): undefined reference to `__atomic_fetch_add_4'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: libtask.a(Nibbler.cpp.o): in function `Nibbler::operator=(Nibbler const&)':
Nibbler.cpp:(.text+0xe0): undefined reference to `__atomic_fetch_add_4'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: Nibbler.cpp:(.text+0x104): undefined reference to `__atomic_fetch_add_4'
/data/data/com.termux/files/usr/bin/arm-linux-androideabi-ld: libtask.a(Nibbler.cpp.o): in function `Nibbler::~Nibbler()':
Nibbler.cpp:(.text+0x174): undefined reference to `__atomic_fetch_add_4'
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/CMakeFiles/lex_executable.dir/build.make:90: src/lex] Error 1
make[2]: Leaving directory '/data/data/com.termux/files/home/src/task-2.5.1'
make[1]: *** [CMakeFiles/Makefile2:175: src/CMakeFiles/lex_executable.dir/all] Error 2
make[1]: Leaving directory '/data/data/com.termux/files/home/src/task-2.5.1'
make: *** [Makefile:152: all] Error 2
I found this discussion about undefined references in arm builds. I tried adding a -latomic to CMakeFiles/task_executable.dir/link.txt but it didn't change the output.
Any ideas how to fix this?
Many thanks to wbsch in this issue (posted just after this one) for the link to the known fix which was successful on my machine, removing the three lines from CMakeLists.txt.

collect2.exe: error: ld returned 5 exit status

I've recently updated all msys2 packages and now I can't build my project.
The error occurs at the moment of linking one of .dlls - target_library.dll.
The error message isn't clear to me. What does status 5 mean?
collect2.exe: error: ld returned 5 exit status
Full message:
g++ -Wl,-s,--relax,--gc-sections -shared -Wl,-subsystem,windows -mthreads -Wl,--out-implib,C:/msys64/workspace/Project_Root_Directory/project/src/../build/release/plugins/libtarget_library.dll.a -o ../../../../build/release/plugins/target_library.dll object_script.target_library.Release -lglu32 -lopengl32 -luser32 -LC:/msys64/workspace/Project_Root_Directory/project/build/release -LC:/msys64/workspace/Project_Root_Directory/project/third-party/out/lib -LC:/msys64/workspace/Project_Root_Directory/project/deps/lib -lexif -ldecimal -lsqlite3 -lutils -LC:/Python35/libs -lpython35 -lkmlbase -lkmlengine -lkmldom -lkmlxsd -lminizip -luriparser -lkmlconvenience -lcore -lrender -lraster -lgui -LC:/msys64/workspace/Project_Root_Directory/project/deps/lib/target_library/win64 -LC:/msys64/mingw64/lib C:/msys64/mingw64/lib/libQt5Widgets.dll.a C:/msys64/mingw64/lib/libQt5WinExtras.dll.a C:/msys64/mingw64/lib/libQt5Gui.dll.a C:/msys64/mingw64/lib/libQt5Network.dll.a C:/msys64/mingw64/lib/libQt5Concurrent.dll.a C:/msys64/mingw64/lib/libQt5Xml.dll.a C:/msys64/mingw64/lib/libQt5Core.dll.a
collect2.exe: error: ld returned 5 exit status
make[4]: *** [Makefile.Release:159: ../../../../build/release/plugins/target_library.dll] Error 1
make[4]: Leaving directory '/workspace/Project_Root_Directory/project/src/modules/plugins/target_library'
make[3]: Leaving directory '/workspace/Project_Root_Directory/project/src/modules/plugins/target_library'
make[2]: *** [Makefile:384: sub-target_library-make_first] Error 2
make[2]: Leaving directory '/workspace/Project_Root_Directory/project/src/modules/plugins'
make[1]: *** [Makefile:297: sub-plugins-make_first] Error 2
make[1]: Leaving directory '/workspace/Project_Root_Directory/project/src/modules'
make: *** [Makefile:44: sub-modules-make_first] Error 2
gcc 7.1.0, Qt5 5.9.1, qmake, Win7 x64
I had the same issue.
I link my project with static library.
After mingw64 upgrade, my project stoped building with the same error.
I found out that debug version built successfully. So i compared linker flags. In release version Qt add this flags "-Wl,-s,--relax,--gc-section".
I couldn't find any information about "-s" flag, but due to this link i figured out that -gc-section flag was the reason of fail.
I added the following code to my .pro-file, and it worked
mingw {
contains(QT_ARCH, x86_64): {
LIBS+=-Wl,--no-gc-sections
}
}
Just in case someone finds this due the same problem, please, add the following flag to your compiler -Wl,--verbose (or --verbose to the linker). This will show which library was not found or give you more information about the problem.

Linking library with gcc - ld: cannot find -larpack

I am installing software on a server with no root privileges. I come across the following error during installation:
make[1]: *** [hgaprec] Error 1
make[1]: Leaving directory `/seq/.../SOFTWARE/hgaprec/src'
make: *** [all-recursive] Error 1
Making install in src
make[1]: Entering directory `/seq/.../SOFTWARE/hgaprec/src'
g++ -O3 -o hgaprec ratings.o main.o log.o hgaprec.o -larpack -llapack -
lblas -lgsl -lpthread -lgslcblas
/.../software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/bin/ld: cannot
find -larpack
collect2: error: ld returned 1 exit status
make[1]: *** [hgaprec] Error 1
make[1]: Leaving directory `/seq/.../SOFTWARE/hgaprec/src'
make: *** [install-recursive] Error 1
Since library arpack could not be found, I then installed it here /seq/.../SOFTWARE/hgaprec/ARPACK and found that the process generated a static file libarpack_LINUX.a. To link this static library to gcc the following command was used:
gcc -larpack -L/seq/.../SOFTWARE/hgaprec/ARPACK/libarpack_LINUX.a
However, I keep getting the same error while installation of the software that larpack was not found. Am I using the linking command wrong?
You either want gcc main.c /seq/../SOFTWARE/hgaprec/ARPACK/libarpack_LINUX.a (you don't need -l and -L if you're specifying the full path to static library), or as #Julian_Cienfuegos suggested gcc main.c -L/seq/../SOFTWARE/hgaprec/ARPACK/ -larpack_LINUX. This assumes you're only compiling a single file called main.c which contains your main() function, and outputs the a.out binary.
EDIT: Added explanation of main.c.
My issue got solved after including the ARPACK library path as part of LD flag in configure like so:
./configure --prefix=/seq/.../SOFTWARE/hgaprec LDFLAGS="-L/seq/.../SOFTWARE/hgaprec/ARPACK/"

Undefined reference to symbol, DSO missing from command line

I'm trying to compile the Lotech framework under Debian Jessie, but I'm can't seem to get past a specific point in compilation. I've searched the error messages that come up, and almost all of them seem to be resolved by installing or linking a missing dependency, but I can't figure out what that dependency is in this situation.
cp buildtmp.linux/liblt.a linux/
cd clients/glfw/ && make LTCFLAGS="-O3 -DNDEBUG -DLTLINUX " && cp ltclient ../../
make[1]: Entering directory `/home/jake/Desktop/copy-lotech-master/clients/glfw'
g++ -O3 -DNDEBUG -DLTLINUX -I../../linux/include -L../../linux ltclient.cpp \
-o ltclient -static-libstdc++ -static-libgcc ../../linux/liblt.a ../../linux/libpng.a ../../linux/libz.a ../../linux/liblua.a ../../linux/libvorbis.a ../../linux/libbox2d.a ../../linux/libglfw.a ../../linux/libGLEW.a ../../linux/libopenal.a ../../linux/libcurl.a -lX11 -lGL wrap_memcpy.o -Wl,--wrap=memcpy
/usr/bin/ld: ../../linux/libopenal.a(helpers.o): undefined reference to symbol 'dlclose##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [ltclient] Error 1
make[1]: Leaving directory `/home/jake/Desktop/copy-lotech-master/clients/glfw'
make: *** [ltclient] Error 2
For me this does the trick
set (CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl")
Useful links
Link1
Link2
Link3 <- Cmake how to find libraries
Link4
Link5
DSO means Dynamic Shared Object. Add the option "-lpthread" works for me.

GLFW MinGW link error

I've been attempting to test out GLFW with C++ for quite a while and am having constant linker issues. I am fairly new to C++, although I have experience in Java and C#, working directly with the compiler is fairly new to me. Here's my setup information.
IDE: Qt Creator
OS: Windows 7 64-bit
Compiler: MinGW32 4.8.1
01:23:26: Starting: "C:\MinGW\bin\mingw32-make.exe"
C:/MinGW/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'A:/workspace_cpp/Test-Debug'
g++ -Wl,-subsystem,console -mthreads -o debug\Test.exe debug/main.o -lglfw3 -lopengl32
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor.::(.text+0x2c7): undefined reference to `CreateDCW#16'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x358): undefined reference to `GetDeviceCaps#8'
Makefile.Debug:77: recipe for target 'debug\Test.exe' failed
mingw32-make[1]: Leaving directory 'A:/workspace_cpp/Test-Debug'
Makefile:34: recipe for target 'debug' failed
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x370): undefined reference to `GetDeviceCaps#8'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor .c:(.text+0x39e): undefined reference to `DeleteDC#4'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj): bad reloc address 0x20 in section `.eh_frame'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
The code I'm testing is the code on the GLFW Documentation Page, I'm using my own build of GLFW, and have already tried this and several other potential solutions. I have tried using the prebuilt GLFW mingw libraries but I couldn't get them to work.
The solution as posted by enhzflep was to include to gdi32 library when compiling, making all the necessary linkers -lglfw3 -lgdi32 -lopengl32, as the missing methods, CreateDCW, GetDeviceCaps and DeleteDC are all inside of libgdi32.a in the MinGW lib folder C:\MinGW\lib\libgdi32.a in this case.