libpcap compiling as external library - compilation

I'm making a project that requires libpcap library, I downloaded the library from official website (libpcap-1.7.2.tar.gz) and I want to compile and the project on Unix server, but I am not allowed to install the library there (school server) and I cannot run the gcc as root.
What command shall I use? Or is it even possible? I can't find any info. (.. my aim is to run the binary on another linux OS (with root permissions) without the need of installing the lib.)
I already tried:
gcc -Wall test.c -lpcap -Ilib/libpcap-1.7.2
but getting an error:
lib/libpcap-1.7.2/pcap.h:43:23: fatal error: pcap/pcap.h: No such file or directory
#include <pcap/pcap.h>
^

Related

gcc compiler giving error because missing files for flags

I am trying to compile code for a course. I want to use the -Wall -pedantic and -std=c99 tag since those are used to check the code by the teachers. In a previous course where I had to do this I ran the code on a linux virtual boot provided by the teachers where everything was preinstalled to run the code. But since then I switched over my PC to linux from windows so I do not have those things installed. when running the following command in my terminal
gcc −std=c99 −Wall −pedantic myprogram.c
I get the following errors roughly translated to english.
gcc: error: -std=cgg: File or directory does not exist
gcc: error: -Wall: File or directory does not exist
gcc: error: -pedantic: File or directory does not exist
what do I have to install and how to make this working?

Yocto meta-toolchain fatal error: stdio.h: No such file or directory

Question: How to add the standard library to arm-fslc-linux-gnueabi-gcc
Background:
I just had bitbake compile the meta-toolchain in the Yocto project.
I then installed the resulting SDK-toolchain
$
./build/tmp/deploy/sdk/fslc-framebuffer-glibc-x86_64-meta-toolchain-armv7at2hf-neon-toolchain-2.4.2.sh
which then installed the SDK-toolchain in /opt/fslc-framebuffer/2.4.2/
I can then easily run the executable to source the correct environment variables.
$
./opt/fslc-framebuffer/2.4.2/environment-setup-armv7at2hf-neon-fslc-linux-gnueabi
I now have access to the cross-compiler arm-fslc-linux-gnueabi-gcc
So far so good...
I then downloaded the barebone SDK from NXP here.
It's a great piece of work, but it might be somewhat outdated. First unzip the file, and then follow steps within the SDK readme.pdf.
Following the readme.pdf i do the following: To build the SDK, use the ./tools/build_sdk command from the root folder. I get multiple error but they are all related to the standard library such as:
iMX6_Platform_SDK/sdk/drivers/accelerometer/src/mma8451.c:31:10: fatal error: string.h: No such file or directory #include <string.h>
iMX6_Platform_SDK/sdk/include/sdk.h:40:10: fatal error: stdio.h: No such file or directory #include <stdio.h>
So how do I solve this? Do I cross compile the standard library or do I get the binary some other place?
SDK build by yocto is little bit different than normal arm toolchain.
I believe you used
arm-fslc-linux-gnueabi-gcc hello.c
but actually you need to use Makefiles or Macros like below,
${CC} hello.c -o hello
Write this directly into your terminal or put it into a makefile.

gfortran can't find OpenMP library (omp_lib.mod) under MinGW

I'm trying to compile a Fortran code that someone has sent me. It compiles fine on my Linux box, now I'm trying to compile it under MinGW on Windows. But when I run the gfortran command to compile and link it, it fails with the following error:
undumag_main_omp.f:8175:9:
use omp_lib
1
Fatal Error: Can't open module file 'omp_lib.mod' for reading at (1): No such file or directory
compilation terminated.
I'm using the -fopenmp switch to use OpenMP.
I've installed MinGW (5.3.0) using the Installation Manager, selecting the mingw32-base and mingw32-gcc-fortran packages. Are there other packages I should install for OpenMP compatibility? Or do I need to compile the omp_lib.mod file myself, and if so how? I can see that I have some libgomp.* files in my MinGW\lib\gcc\mingw32\5.3.0 folder, but there is no omp_lib_mod file anywhere.

building my own gcc version

My distro (CentOS 6.3) comes with gcc 4.4.6. Since I wanted to try out the Fortran2003 features I decided to compile gcc 4.7.
I followed the steps I found online: compiled separately first gmp, mpc, mpfr, ppl and cloog and the compiled gcc.
I run the configured script as:
configure --prefix=... --with-gmp=... --with-mpfr=... --with-mpc=... --program-suffix=-4.7 --enable-cloog-backend=isl --with-ppl=... --with-cloog=... --disable-multilib
This worked all right and I was able to compile with make & make install.
Now, when trying my new compiler with a simple test program (a hello world kind of thing) I get the error:
gfortran-4.7 -o test test.F90
/home/amcastro/gcc-4.7/output/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/f951: error while loading shared libraries: libcloog-isl.so.1: cannot open shared object file: No such file or directory
So I decide to set LD_LIBRARY_PATH=/home/amcastro/gcc-4.7/output/lib
and then I can compile.
When running I get the error:
./test
./test: error while loading shared libraries: libquadmath.so.0: cannot open shared object file: No such file or directory
So I set LD_LIBRARY_PATH=/home/amcastro/gcc-4.7/output/lib:/home/amcastro/gcc-4.7/output/lib64
and now the program runs normally.
The question is: Why is that my distro version of gcc (4.4.6) does not need me to set LD_LIBRARY_PATH? how does the distro gcc know where to look for these dynamically liked libraries? should I somehow make them to link statically?
I read also that setting LD_LIBRARY_FLAG is not a good idea. Is there another solution?
Thank you in advance
A.

boost_thread not linking on NaCl

I receive this error when linking -lboost_thread into my executable on google Native Client (pepper_19):
nacl_sdk/pepper_19/toolchain/mac_x86_glibc/x86_64-nacl/usr/lib/libboost_thread.a: could not read symbols: Archive has no index; run ranlib to add one
I compiled boost according to the instructions at naclports here: http://code.google.com/p/naclports/wiki/InstallingSDL (except using the boost library directory instead of SDL... I also used this same process to correctly compile NaCl zlib library)
cd naclports/src/libraries/boost_1_47_0
export NACL_PACKAGES_BITSIZE=32; ./nacl-boost_1_47_0.sh
export NACL_PACKAGES_BITSIZE=64; ./nacl-boost_1_47_0.sh
this generates the libboost_thread.a file and puts it them in the /usr/lib directories of my NACL installation. I thought maybe somehow I mistakenly built a wrong type of library for linking with NaCl. Is there a way to check this and/or fix it?
I tried:
cd naclports/src/out/repository-x86_64/boost_1_47_0/bin.v2/libs/thread/build/darwin-4.2.1/release/link-static/threading-multi
nm libboost_thread.a
and this yielded:
libboost_thread.a(thread.o):
0000000000052d08 s EH_frame0
000000000004f50c s GCC_except_table100
000000000004f534 s GCC_except_table101
000000000004f574 s GCC_except_table102
000000000004f5c0 s GCC_except_table103
000000000004f600 s GCC_except_table104
000000000004f64c s GCC_except_table105
000000000004f68c s GCC_except_table106
000000000004f6d8 s GCC_except_table107
.
.
.
.
etc, etc..
However then I ran:
nacl_sdk/pepper_19/toolchain/mac_x86_glibc/bin/x86_64-nacl-nm libboost_thread.a
and got:
__.SYMDEF SORTED: File format not recognized
nacl_sdk/pepper_19/toolchain/mac_x86_glibc/bin/x86_64-nacl-nm: thread.o: File format not recognized
nacl_sdk/pepper_19/toolchain/mac_x86_glibc/bin/x86_64-nacl-nm: once.o: File format not recognized
And finally. I ran:
file pthread/thread.o
pthread/thread.o: Mach-O 64-bit object x86_64
however the same command on a zlib object file results in:
ELF 64-bit LSB relocatable, x86-64, version 1, not stripped
I would appreciate advice on building a correctly cross-compiled NaCl libboost_thread.a
Thank you.
Some libraries in NaCl ports can only be built on linux. So you have to either find why boost decides to use system ar instead of x86_64-nacl-ar or install VM with linux where they are the same.

Resources