How to fix 'sincos##GLIBC_2.2.5' undefined reference for fftw3 library - c

I have been trying to install and execute a c-program using fftw3 library on Ubuntu machine but getting this error so many times.
How to fix the error? Help is much appreciated.
latest source code was downloaded: http://www.fftw.org/download.html
Install commands:
sudo -H ./configure --enable-float --enable-sse --enable-threads
sudo -H make
sudo -H make install
Trying to compile:
gcc -Wall -O3 -o jediconvolve jediconvolve.c -L /usr/local/lib -lm -lcfitsio -lfftw3f
Errors:
bhishan#jedisim_sources:gcc -Wall -O3 -o jediconvolve jediconvolve.c -L /usr/local/lib -lm -lcfitsio -lfftw3f
/usr/bin/ld: /usr/local/lib/libfftw3f.a(trig.o): undefined reference to symbol 'sincos##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
file jediconvolve.c to test
https://pastebin.com/fHKwejj7

Related

DLL file format not recognized

So I've been trying to install the luasql-mysql module for a while now and I keep running into problems. This time when I go to install it gives me this error:
luasql-mysql 2.5.0-1 depends on lua >= 5.1 (5.3-1 provided by VM)
mingw32-gcc -O2 -c -o src/luasql.o -IC:\Program Files\lua-5.3.5\src src/luasql.c -
Ic:/windows/system32/include
mingw32-gcc -O2 -c -o src/ls_mysql.o -IC:\Program Files\lua-5.3.5\src src/ls_mysql.c -
Ic:/windows/system32/include
mingw32-gcc -shared -o luasql/mysql.dll src/luasql.o src/ls_mysql.o -Lc:/windows/system32 -
lmysqlclient C:\Program Files\lua-5.3.5\src/lua53.dll -lm
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lmysqlclient
C:\Program Files\lua-5.3.5\src\lua53.dll: file not recognized: file format not recognized
collect2.exe: error: ld returned 1 exit status
Error: Build error: Failed compiling module luasql/mysql.dll
I'm going to try reinstalling everything and hopefully that works but if anyone knows why I'm getting this problem then I would appreciate the help.

Compile C on CentOS to static library

I'm able to compile and run my application in C on CentOS with the following parameters:
gcc test.c -o test -lpcap -lssl -lcrypto -L /usr/local/lib -L /usr/local/opt/openssl/lib/ -lhiredis
But I need to run the application on a machine where I cannot compile, nor download ex. hiredis.
So I need to compile everything together on my own CentOS - which does match in setup.
I've read about the static flag, but when doing so I get the following errors:
gcc -static test.c -o test -lpcap -lssl -lcrypto -L /usr/local/lib -L /usr/local/opt/openssl/lib/ -lhiredis
/usr/bin/ld: cannot find -lpcap
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
/usr/local/lib/libhiredis.a(net.o): In function `_redisContextConnectTcp':
/home/alfredballe/hiredis/net.c:399: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
What am I doing wrong?

Compiling C code that uses R libraries in Netbeans

I've been having trouble debugging some C code that I'm writing as part of an R package. The code compiles and executes when I use R CMD SHLIB from the Windows console (i.e. cmd.exe):
>R CMD SHLIB MaximumAgreementForest.c
gcc -m64 -I"C:/PROGRA~1/R/R-32~1.4RE/include" -DNDEBUG -I"d:/RCompile/r-compiling/local/local323/include" -O2 -Wall -std=gnu99 -mtune=core2 -c MaximumAgreementForest.c -o MaximumAgreementForest.o
gcc -m64 -shared -s -static-libgcc -o MaximumAgreementForest.dll tmp.def MaximumAgreementForest.o -Ld:/RCompile/r-compiling/local/local323/lib/x64 -Ld:/RCompile/r-compiling/local/local323/lib -LC:/PROGRA~1/R/R-32~1.4RE/bin/x64 -lR
The script also built correctly in Netbeans until I started using the functions R_alloc and C_alloc from the R libraries. Now it doesn't seem to be able to find the definitions of a number of R-specific functions. When I attempt to build the project in Netbeans the console lists the following:
cd 'C:\Work\Fun\implied_weight\MAF'
C:\MinGW\msys\1.0\bin\make.exe -f Makefile CONF=Debug
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Work/Fun/implied_weight/MAF'
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/libMAF.dll
make.exe[2]: Entering directory `/c/Work/Fun/implied_weight/MAF'
mkdir -p build/Debug/MinGW-Windows/_ext/5c0
rm -f "build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o.d"
gcc -DDEBUG -O2 -Wall -mtune=core2 -c -g -Wall -I/C/Program\ Files/R/R-3.2.4revised/include -MMD -MP -MF "build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o.d" -o build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o ../MaximumAgreementForest.c
mkdir -p dist/Debug/MinGW-Windows
gcc -DDEBUG -O2 -Wall -mtune=core2 -o dist/Debug/MinGW-Windows/libMAF.dll build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o -L/C/Program\ Files/R -L/C/Program\ Files/R/R-3.2.4revised/library -shared
build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o: In function `forest_new':
C:\Work\Fun\implied_weight\MAF/../MaximumAgreementForest.c:37: undefined reference to `R_alloc'
build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o: In function `forest_plant':
C:\Work\Fun\implied_weight\MAF/../MaximumAgreementForest.c:55: undefined reference to `S_alloc'
[...]
C:\Work\Fun\implied_weight\MAF/../MaximumAgreementForest.c:515: undefined reference to `R_chk_free'
collect2.exe: error: ld returned 1 exit status
My script, a single .c file, contains the lines
#define USE_RINTERNALS
#include <R.h> // which itself #includes R_ext/Memory, R_ext Printf
#include <R_ext/Print.h>
#include <R_ext/Memory.h>
#include <Rinternals.h>
Figuring that Netbeans is failing to point to the relevant libraries, I have tried adding and removing C:/Program Files/R/R-3.2.4revised/include and C:/Program Files/R/R-3.2.4revised/bin/x64 at File→Project Properties→General→Source folders, to no effect.
Under File→Project Properties→Build→C compiler, I have included C:/Program Files/R/R-3.2.4revised/include.
When I add C:/Program Files/R/R-3.2.4revised/bin/x64/R.dll to Build→Linker→Libraries→Libraries, via the Add Library... option, I receive the error c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lR, and the linker exits without (before?) complaining about the undefined references.
When I subsequently add "C:/Program Files/R/R-3.2.4revised/bin/x64/", which is already in by System PATH, to Build→Linker→Additional Library Directories, the compiler fails with the message C:/Program Files/R/R-3.2.4revised/bin/x64/R.dll: file not recognized: File format not recognized
What am I missing... how can I point Netbeans to the relevant R libraries?
The File format not recognized error is encountered when a 32-bit compiler tries to load to a 64-bit .dll (or vice-versa). Changing the path
C:/Program Files/R/R-3.2.4revised/bin/x64/R.dll
to
C:/Program Files/R/R-3.2.4revised/bin/i386/R.dll
resolved the problem.

What openGL package am I missing?

I am trying to resurrect on old OpenGL program on a Linux Mint system. I installed freeglut3-dev using Synaptic Package Manager. The compiler does not complain about not being able to find the glut include file anymore, but now I have other problems:
cc -Wall -o gears main.c draw_gears.c gl_drawing.c load_data.c normal.c prep_data.c -lglut
/usr/bin/ld: /tmp/ccfNsT0O.o: undefined reference to symbol 'glNewList'
//usr/lib/i386-linux-gnu/mesa/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [gears] Error 1
Try this:
cc -Wall -o gears main.c draw_gears.c gl_drawing.c load_data.c normal.c prep_data.c -lglut -lGLU -lGL

Linking using g++ fails searching for -lstdc++

I'm trying to use someone else's Makefile to complile a very simple c++ library. The makefile is as follows:
JNIFLAGS=-O2 -pthread -I/usr/lib/jvm/java-6-sun/include -I/usr/lib/jvm/java-6-sun/include/linux
all:
rm -f ../dist/libUtils.so
g++ $(JNIFLAGS) -c -m32 -o com_markets_utils_dates_NativeTime.o com_markets_utils_dates_NativeTime.cpp
g++ $(JNIFLAGS) -c -m32 -o DateUtil.o DateUtil.cpp
g++ -pthread -m32 -shared -fPIC -o ../dist/libUtils.so DateUtil.cpp
g++ -pthread -m32 -shared -fPIC -o ../dist/libNativeTime.so DateUtil.o com_markets_utils_dates_NativeTime.o
This compiles fine, but the linker complains:
...
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.1/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.1/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.1/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.1/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [all] Error 1
FYI, I am on Ubuntu 9.10 64bit.
Posting for future reference, a solution I found was to install g++-multilib. I had the same incompatible problem relating to -lstdc++ on g++ version 4.6.1
On further probing: g++-multilib is a dummy package which installed g++4.6-multilib which in turn installed the appropriate libstdc++.so under the /usr/lib/gcc/x86_64-linux-gnu/4.6/32 folder.
Answering my own question:
Ths solution seems to be a bit of a hack, you need to create a symlink for the 32 bit version of the library (after installing the packages mentioned in #nos's answer):
$ sudo ln -s /usr/lib32/libstdc++.so.6 /usr/lib32/libstdc++.so
Once you've done this, the linker will automagically find the correct library to use.
It seems you're compiling a 32 bit library on a 64 bit machine, however a 32 bit version of libstdc++ is not present.
Try apt-get install ia32-libs libc6-i386 libc6-dev-i386 lib32gcc1 lib32stdc++6
(btw. you're producing a .so , you should specify -fPIC when compiling your .cpp files as well)

Resources