Building libc (newlib) results in "cannot find -lc" - c

I built a cross-compiler for sh3eb-elf targets. Now I need a libc implementation. However, when I want to build newlib, configure fails.
Running configure:
../newlib-cygwin/configure --host=sh3eb-elf
It fails. A quick look into config.log:
configure:4435: sh3eb-elf-gcc conftest.c >&5
[...]/sh3eb-elf/sh3eb-elf/lib/gcc/sh3eb-elf/8.1.0/../../../../sh3eb-elf/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
configure:4439: $? = 1
Obviously the linker does not find libc which is what I am trying to build here in the first place. I am confused... Are the parameters of configure wrong?

I'm not sure why, but as Chrono Kitsune pointed out, using --target=sh3eb-elf does the trick.

Related

Linking fftw-3.3.6-pl2 while compiling my file using gcc

I'm trying to run a simple code that includes the fftw library. I know the code is right as it is provided as a test code by the authors. This is what I typed during compilation:
gcc my file.c -L/home/ankit/Desktop/fftw-3.3.6-pl2/lib/
-I/home/ankit/Desktop/fftw-3.3.6-pl2/include/ -lfftw -lm
I get the errors:
myfile.c: (.Text+0x2c):. undefined reference to 'fftw_plan_dft_2d'
collect2: ld returned 1 exit status
It wasn't a linking problem, installation was faulty and I had to use 'sudo make install' to get the permission for the installation to be successful. I could link it with 'gcc test.c -lfftw3 -lm' after. Thanks for your suggestions!

Unable to compile C++ programs on CentOS

I am getting the below error during ./configure.
configure:3429: checking whether the C compiler works
configure:3451: gcc -m32 -D_FILE_OFFSET_BITS=64 -m32 conftest.c >&5
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
configure:3455: $? = 1
configure:3493: result: no
configure:3498: error: in `/root/cjk/1.x/src/externals/mecab':
configure:3500: error: C compiler cannot create executables
I have tried couple of solutions mentioned in internet but to no avail.
I have installed complete Developers package in the machine.
I have installed glibc-devel.i686 package as well.
I ran into the exact same issue (CentOS 6.5 x64, gcc 4.4.7). I made sure yum install glibc-devel.i686 was performed. A quick find / -name "libgcc_s.*" revealed:
/lib64/libgcc_s.so.1
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libgcc_s.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so
So, perhaps you can try the workaround suggested here:
Add the absolute path to the gcc_s library on the link line, OR
(Recommended) If the library's filename has any major and minor version numbers appended to it, simply create a soft link to the library in the same location without the major and minor version numbers in the target filename.
I settled for compiling/linking my application statically by adding -static to my gcc invocation. So,
gcc -static -m32 ...
In that case make sure yum install glibc-static.i686 is done.

gromacs compilation gives undefined reference error

i would like to use gromacs on my open suse 12.3 platform but am having trouble with it.
when trying to compile an analyzing tool using gmx_template i first got this error:
g++ -L/usr/local/gromacs/lib -o msd msd.o -lmd -lgmx -lfftw3f -lxml2 -lnsl -lm
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: /usr/local /gromacs/lib/libgmx.a(pthreads.c.o): undefined reference to symbol 'pthread_getaffinity_np##GLIBC_2.3.4'
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: note: 'pthread_getaffinity_np##GLIBC_2.3.4' is defined in DSO /lib64/libpthread.so.0 so try adding it to the linker command line
/lib64/libpthread.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [msd] Fehler 1
then i added
/lib64/libpthread.so.0 to the -L options in the makefile
but now i get a lot of errors like this:
/usr/local/gromacs/lib/libgmx.a(pbc.c.o): In function `put_atoms_in_box_omp._omp_fn.0':
pbc.c:(.text+0x862f): undefined reference to `omp_get_num_threads'
i think they are all related to openmp. i do not understand enough of the building process
to enable openmp support (probably -fopenmp) and am at the same time surprised in case
i would have to change the cmake files in order to make gromacs work. i used the quick and dirty install following the gromacs installation instructions on their website.
any suggestions what i can do / did wrong so far ?
i am using gcc 4.7
Here is my gromacs-2018.4 installation process.
pre-installed packages
gcc-8.3.0
cmake-3.14.1
fftw-3.3.8
./configure --prefix=/histor/kang/yangpc/soft/lib/packages/fftw-3.3.8/single_nompi/ --enable-sse2 --enable-avx --enable-float --enable-shared
install gromacs
export PATH=/histor/kang/yangpc//soft/09.system/cmake-3.14.1-Linux-x86_64/bin/:/histor/kang/yangpc//soft/lib/packages/gcc-8.3.0/bin/:$PATH
export CMAKE_PREFIX_PATH="/histor/kang/yangpc/soft/lib/packages/fftw-3.3.8/single_nompi/:/histor/kang/yangpc//soft/lib/packages/gcc-8.3.0/"
export LD_LIBRARY_PATH="/histor/kang/yangpc/soft/lib/packages/gcc-8.3.0/lib64/:$LD_LIBRARY_PATH"
unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUD
export LD_LIBRARY_PATH=/histor/kang/yangpc/soft/lib/packages/gmp-5.1.3/lib/:/histor/kang/yangpc/soft/lib/packages/mpc-1.0.1/lib/:/histor/kang/yangpc/soft/lib/packages/mpfr-4.0.1/lib/:$LD_LIBRARY_PATH
~/soft/09.system/cmake-3.14.1-Linux-x86_64/bin/cmake .. -DCMAKE_INSTALL_PREFIX=/histor/kang/yangpc/soft/13.DrugDesign/GROMACS/gromacs-2018.4/InstallPos/ -DCMAKE_C_COMPILER="/histor/kang/yangpc/soft/lib/packages/gcc-8.3.0/bin/gcc" -DCMAKE_CXX_COMPILER="/histor/kang/yangpc/soft/lib/packages/gcc-8.3.0/bin/g++"
make
make install

cannot find -lpthread

I am trying to cross compile samba server.
./config works just fine, but when I want to build with make the prompt says:
Linking shared library bin/libsmbclient.so.0
/opt/qnx630/host/linux/x86/usr/bin/ntoarm-ld: cannot find -lpthread
collect2: ld returned 1 exit status
make: *** [bin/libsmbclient.so.0] Error 1
Anyone knows a solution?
had this same problem w/mingw. got libpthreadGC2.a from ftp://sourceware.org/pub/pthreads-win32/dll-latest/lib/x86/, put it in C;\mingw\lib and renamed it to libpthread.a. i didn't know gcc's -l switch means "apprend 'lib' to the front and '.a' to the back" e.g. -lpthread = libpthread.a
Make sure that the pthread library is in the library search path of the linker.

Two basic questions on the -l(blah) flag while compiling / installing programs

I am new to Ubuntu and I had the following questions.
When compiling a C or any other program one often writes a command such as gcc hello.c -lm
I am told the -lm option is for explicitly linking the math library during the compiling
phase. I wanted to know where the library 'foo' is supposed to be located if linked with - lfoo.
This is an error I get when I was trying to install a package named SUPERLU which in turn depends on the existence of a package named PARMETIS. (ending of the stuff after running make)
/usr/bin/ld: cannot find -lparmetis
collect2: ld returned 1 exit status
make[1]: * [pddrive] Error 1
make[1]: Leaving directory `/home/gaurish108/Desktop/ResearchMeetings/SUPERPETS/SuperLU_DIST_2.4/EXAMPLE'
make: * [example] Error 2
What should I do ???? I found that there is no ld folder in my /usr/bin/......Should I modify my make.inc file in some way?
Take a look here: http://www.network-theory.co.uk/docs/gccintro/gccintro_21.html. -lm says "search for libm.a in the search path". libm.a is found in /usr/lib/libm.a.

Resources