undefined reference errors while compiling a QT program - qt

I just installed QtSDK 1.2 on my redhat enterprise linux 5.6. While compiling a QT program, I got the following errors:
[root#stack example1]# make
g++ -m64 -Wl,-O1 -Wl,-rpath,/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib -o example1 fac1.o -L/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib -lQtGui -lQtCore -lpthread
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so: undefined reference to `g_main_context_push_thread_default'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so: undefined reference to `inotify_init1#GLIBC_2.9'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to `pipe2#GLIBC_2.9'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so: undefined reference to `g_main_context_pop_thread_default'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to `FcFreeTypeQueryFace'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to `FT_Library_SetLcdFilter'
/opt/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtGui.so: undefined reference to `__longjmp_chk#GLIBC_2.11'
collect2: ld returned 1 exit status
make: *** [example1] Error 1
[root#stack example1]#
It seems g++ compiler uses all correct options. Befor I installed QtSDK 1.2 on rhel 5.6, I had copied libstdc++.so.6.0.10 to /usr/lib64 and relinked libstdc++.so.6 to libstdc++.so.6.0.10, since QtSDK requires GLIBCXX_3.4.9 symbols in the libstdc++ library. I think this may be the source of the problem. But I'm not sure about that. So any advice? Thanks in advance.

My answer is multiple questions:
Are you in a 64 architecture? If not why using 64 libraries?
Did the libraries copied are 64 versions ?
If it is the case, why do you need to copy them, there should already be standard libraries in /usr/lib64
If it is not the case the errors are legit.
How did you compiled Qt in the first place? if your Qt libraries are really 64 bits, then it means the environment setup was already correct.

Related

Trying to compile R Package RSAP

I'm trying to compile the R Package RSAP using the command
R CMD INSTALL RSAP
The necessary SAP library SAP NW RFCSDK is located in C:\nwrfcsdk.
I'm building on Windows 10 64
R version 3.4 32 bit (I tired 64 as well)
R tools with mingw32
It does not compile but terminates with the following errors:
c:/Rtools/mingw_32/bin/gcc -shared -s -static-libgcc -o RSAP.dll tmp.def RSAP.o -L. -LC:/nwrfcsdk/lib -lsapnwrfc -llibsapucum -Ld:/Compiler/gcc-4.9.3/local330/lib/i386 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-34~1.0/bin/i386 -lR
RSAP.o:RSAP.c:(.text+0x4b): undefined reference to `RfcPing#8'
RSAP.o:RSAP.c:(.text+0x23a): undefined reference to `RfcUTF8ToSAPUC#24'
RSAP.o:RSAP.c:(.text+0x2d5): undefined reference to `RfcUTF8ToSAPUC#24'
RSAP.o:RSAP.c:(.text+0x369): undefined reference to `RfcUTF8ToSAPUC#24'
RSAP.o:RSAP.c:(.text+0x3ef): undefined reference to `RfcSAPUCToUTF8#24'
RSAP.o:RSAP.c:(.text+0x4b8): undefined reference to `RfcSAPUCToUTF8#24'
RSAP.o:RSAP.c:(.text+0x645): undefined reference to `RfcUTF8ToSAPUC#24'
RSAP.o:RSAP.c:(.text+0x6e3): undefined reference to `RfcUTF8ToSAPUC#24'
RSAP.o:RSAP.c:(.text+0x719): undefined reference to `RfcOpenConnection#12'
RSAP.o:RSAP.c:(.text+0x923): undefined reference to `RfcCloseConnection#8'
...
and so on until it stops with
collect2.exe: error: ld returned 1 exit status
keine DLL erzeugt
ERROR: compilation failed for package 'RSAP'
* removing 'C:/Users/jmueller/R/win-library/3.4/RSAP'
* restoring previous 'C:/Users/jmueller/R/win-library/3.4/RSAP'
What am I doing wrong? Any help is highly appreciated!
This is what happens when you try to build RSAP in the 32-bit environment of R using the 64-bit version of the SAP NW RFC SDK. I had the same problem and after executing the following command in the 64-bit environment of RGui (with the 64-bit version of SAP NW RFC SDK located in C:\nwrfcsdk) the undefined references were gone.
Command:
install.packages('RSAP', repos=c('http://piersharding.com/R'), type="source", configure.args=c('--with-nwrfcsdk-include=C:/nwrfcsdk/include --with-nwrfcsdk-lib=C:/nwrfcsdk/lib'))
as described in:
https://github.com/piersharding/RSAP/blob/master/INSTALL

GCC is always trying to use the static libc library instead of shared

I'm not sure what went wrong on my server, it's running CentOS 7 and I recently tried to build a library and got the error:
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie
collect2: error: ld returned 1 exit status
First, I thought it's a mistake in the libraries source code, but after some testing I created a minimal working C++ program:
#include <iostream>
int main() {
std::cout<<"works!";
}
And I try to build it first statically...
gcc -static main.c
Works. Generates a.out, which is what I expected, now if I type...
gcc main.c
I get the same error as above, it tries to link libc.a but I didnt specify static linking.
I managed to solve it with:
yum install glibc-devel.i686 glibc-i686

Compiling QScintilla on Ubuntu Fails

I'm trying to compile Qscintilla 2.9.2 on Ubuntu 16.04 64bit using Qt 5.7 got the following error message:
-L/home/mwambi/Qt5.7.0/5.7/gcc_64/lib -lQt5PrintSupport -L/usr/lib64 -lQt5Widgets -lQt5Gui -lQt5Core -lpthread -lGL
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
Makefile:979: recipe for target 'libqscintilla2.so.12.0.1' failed
make: *** [libqscintilla2.so.12.0.1] Error 1
I do not know what the library GL is and where to find it. How can I solve this?
In my experience, this troubleshooting procedure is enough to solve about 90% of missing library issues during compilation:
"-l[name]" implies there's a "lib[name].so"
Search your system for "lib[name]" (use locate or find).
If you find it on your system, check paths ($LB_LIBRARY_PATH and the build system's -L flags) and verify that the architecture matches (x86+64 vs. i686).
Do a repository search for "lib[name]" (use apt, yum, synaptic, &c.).
Install it if it's missing.
Type "lib[name].so" into google or a dedicated package-search site (like RPMFind or packages.ubuntu.com) and see what package names come up, then search for as in #2-3.
In this case, libGL is an implementation of OpenGL. You can install Mesa or find an alternative implementation (I've only ever used Qt with Mesa). Here's a list of packages that provide libGL; if you already have one of these installed on your system, try fetching the dev versions of whichever ones you already have.

Library of opencl not found?

I am trying to compile an opencl sample code but I am getting the following error
/usr/bin/ld: cannot find -lOpenCL
/usr/bin/ld: cannot find -loclUtil_x86_64
/usr/bin/ld: cannot find -lshrutil_x86_64
collect2: error: ld returned 1 exit status
make: *** [../../..//OpenCL//bin//linux/release/DeviceQuery] Error 1
I am using intel based machine ...
My make file is
EXECUTABLE := DeviceQuery
CCFILES := devQury.cpp
include ../common/common_opencl.mk
Any help would be of great help
Thanks ,
Piyush
Make sure that the OpenCL library (libOpenCL.so) is present in /usr/lib. This should have been put in place by the driver, so you shouldn't have to do anything.
If not then copy libOpenCL.so present in your cuda toolkit (lib64) to the above location.
sudo cp /usr/local/cuda-7.0/lib64/libOpenCL.so /usr/lib
This fixes the error
/usr/bin/ld: cannot find -lOpenCL
collect2: error: ld returned 1 exit status
Have you installed the OpenCL SDK from either Intel or AMD? If not then perhaps you should follow these instructions. If you have an SDK installed then your makefile is probably missing -L... in the compiler command line, where ... is the path to the lib folder in the OpenCL SDK that should contain a file libOpenCL.a or something similar.

R won't call gfortran compiled object?

I made a simple fortran routine
subroutine add(x,y)
real(8) :: x,y
y = x + 3
end subroutine
saved as test.f90.
I compile with
gfortran -shared test.f90 -o test.so
In R (in the same directory), I use
dyn.load('test.so')
but it gives me this error:
Error in dyn.load("test.so") :
unable to load shared object '/Users/Steven/Documents/PhD/npsR/test.so':
dlopen(/Users/Steven/Documents/PhD/npsR/test.so, 6): Symbol not found: ___addtf3
Referenced from: /usr/local/gfortran/lib/libquadmath.0.dylib
Expected in: /Library/Frameworks/R.framework/Resources/lib/libgcc_s.1.dylib
in /usr/local/gfortran/lib/libquadmath.0.dylib
Does anyone know why? I'm using mac osx Lion, with R v2.15.0 and gfortran 4.6.2.
Thank you!
Unless you really understand what you're doing, you should use gfortran that comes with R tools. The missing symbol in libgcc isn't surprising since you're trying to run code compiled with a 4.6 gfortran in a 4.2 runtime environment.
You can only use the gfortran version that was used to build R.
Since you are on Lion and presumably have Xcode installed you can get the appropriate version of gfortran from here: http://r.research.att.com/tools/
Go to section: "Apple Xcode gcc-42 add-ons" and choose the appropriate version.
You'll have to get rid of your gfortran 4.6.2 completely or make it inaccessible by changing PATH if possible (which I doubt unless it is in /opt/...).
And do use R CMD SHLIB since that will pass the correct options to compiler and linker.

Resources