Using gnu toolchain compiled library in Keil - c

I'm trying to use a library I compiled under debian by GNU toolchain in Keil and getting this error:
._build\nrf52832_xxaa_s132.axf: Error: L6218E: Undefined symbol
_impure_ptr
this symbol comes from newlib, How can I compile a library with arm-none-eabi-gcc without newlib?
I've already tried -nostdlib but it doesn't work.

Related

undefined reference to symbol 'CERT_GetDefaultCertDB##NSS_3.2'

I recently added libcurl dependency to my c++ library. I statically compiled libcurl with-nss for https support. I use Debian 7 for compilation.
I create two builds for my library - static and shared
Shared version is linking fine with binaries built on any Linux distro, but the static build only links with binaries when compiled on Debian 7.
I tried static linking on Ubuntu 16.04, Debian Stretch but all are reporting following error during compilation:
g++ -Wall -o Sample Sample.cpp -Wl,-Bstatic -L. -lMyLibrary -Wl,-Bdynamic -lssl3
/usr/bin/ld: ./libMyLibrary.a(libcurl_la-nss.o): undefined reference to symbol 'CERT_GetDefaultCertDB##NSS_3.2'
//usr/lib/x86_64-linux-gnu/libnss3.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:22: recipe for target 'Sample' failed
make: *** [Sample] Error 1
Static compilation now only works on Debian 7 which is a big problem.
Static libraries are just archives of object files. As one consequences, they don't carry any dependency information. So, if you link a static library which depends on some other libraries, you have to add these explicitly in your linking command.
In your case, this means:
find whoever defines CERT_GetDefaultCertDB##NSS_3.2 -- some answers to this FAQ could help here
add this library to your linker command (with -l, after your static library)

ALSA Library and Cross Compiling for ARM

I'm trying to make an "C" application for my NXP(Freescale) imx6 that Debian OS installed on it. My host machine is Ubuntu 16.04. I'm using eclipse as an IDE and I can manage to cross compile until today. I use arm-linux-gnueabihf-gcc as an compiler and arm-linux-gnueabihf-ld as an linker. I added -lasound option to my linker parameter, but still can not build the application. I get an error
arm-linux-gnueabihf-ld: cannot find -lasound
I think I don't have the libasound.so file on my Ubuntu (Host) machine and my linker couldn't link to library to my application.
I copied the libasound.so file from my ARM machine to my host machine to the /home/user/Downloads folder, but still couldn't compile.
Is there a step to use ALSA library in Cross Compilation project before build?
Here is the output of build operation
Building target: tihc_linux_application
Invoking: GCC C Linker
/usr/bin/arm-linux-gnueabihf-ld -static -L/home/user/Downloads -pthread -lasound -o "main" ./src/main.o
/usr/bin/arm-linux-gnueabihf-ld: mode armelf_linux_eabi
/usr/bin/arm-linux-gnueabihf-ld: cannot find -lasound
You ask for static link (via -static) but provide shared library so ld probably ignores it (to be sure you can run with -Wl,--verbose). One option is to cross-compile libalsa from scratch and then use resulting static lib to link your app. Another option is to search for pre-compiled gnueabihf libalsa somewhere...

xCode produces "Undefined symbols for architecture x86_64" error while gcc compiles without errors

When compiling a demo program for a library with xCode, I get an undefined symbols error. The same C code compiles without any problems with gcc test.c -pthread -ltraffic. I did set the compiler flags I. xCode without any success.
What does xCode do differently than gcc? Don't they both use LLVM?
The problem is that all your external libraries (pthread, traffic, etc..) have to be compiled for both i386 and x86_64 architectures. This means that you have to have either two library files for each library or one "fat" library file (see here).

gcc including GMP library and osx mavericks

I am not able to compile C programs that use the gmp library under OSX mavericks, it says that it cannot find the gmp.h header file, I comiled the program like this gcc factor.c -lgmp, but it would not recognize the linker flag.
How can i compile C programs that use GMP?

Cross-compiling R for ARM (Raspberry Pi)

I need to build R (http://www.r-project.org/) for Arch Linux ARM running on Raspberry Pi. I am having trouble running ./configure. I have built my own toolchain using crosstool-ng and it does work, I've compiled other applications with it just fine.
The issue appears to be that I cannot link the Fortran libraries to C code. Here is where configure fails:
checking for Fortran 77 libraries of gfortran... -L/home/njackson/bcm2708rpi-toolchain/lib -L/home/njackson/bcm2708rpi-toolchain/lib/gcc/arm-rpi-linux-gnueabi/4.7.3 -L/home/njackson/bcm2708rpi-toolchain/arm-rpi-linux-gnueabi/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6 -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../.. -lgfortran -lm /home/njackson/bcm2708rpi-toolchain/arm-rpi-linux-gnueabi/lib/libgfortran.a /home/njackson/bcm2708rpi-toolchain/lib/gcc/arm-rpi-linux-gnueabi/4.7.3/libgcc.a
checking for dummy main to link with Fortran 77 libraries... unknown
configure: error: in `/home/njackson/R-2.15.3':
configure: error: linking to Fortran libraries from C fails
See `config.log' for more details
It fails here.
I used the following configure command:
./configure --host=arm-linux-gnueabihf CC=/home/njackson/bcm2708rpi-toolchain/bin/arm-rpi-linux-gnueabi-gcc CXX=/home/njackson/bcm2708rpi-toolchain/bin/arm-rpi-linux-gnueabi-g++ FC=/home/njackson/bcm2708rpi-toolchain/bin/arm-rpi-linux-gnueabi-gfortran MAIN_LD=/home/njackson/bcm2708rpi-toolchain/bin/arm-rpi-linux-gnueabi-ld --with-readline=no
I'd appreciate help getting this compiled. Thanks.
I figured it out.
One should set F77=/path/to/gfortran instead of the FC variable.

Resources