Trying to compile C program, every time I run make or gmake as recommended I get this error.
$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src all
gcc -g -W -Wall -O3 -D_FILE_OFFSET_BITS=64 -D_REVISION=0 -Iinclude -c -o osdep/radiotap/radiotap.o osdep/radiotap/radiotap.c
In file included from osdep/radiotap/radiotap.c:17:
osdep/radiotap/platform.h:6:10: fatal error: 'endian.h' file not found
#include <endian.h>
^
1 error generated.
make[1]: *** [osdep/radiotap/radiotap.o] Error 1
make: *** [all] Error 2
$ gmake
gmake -C src all
gmake[1]: Entering directory '/Users/silent/Desktop/aircr-1.2-rc1/src'
gcc -g -W -Wall -O3 -D_FILE_OFFSET_BITS=64 -D_REVISION=0 -Iinclude -c -o osdep/radiotap/radiotap.o osdep/radiotap/radiotap.c
In file included from osdep/radiotap/radiotap.c:17:
osdep/radiotap/platform.h:6:10: fatal error: 'endian.h' file not found
#include <endian.h>
^
1 error generated.
<builtin>: recipe for target 'osdep/radiotap/radiotap.o' failed
gmake[1]: *** [osdep/radiotap/radiotap.o] Error 1
gmake[1]: Leaving directory '/Users/silent/Desktop/aircr-1.2-rc1/src'
Makefile:25: recipe for target 'all' failed
gmake: *** [all] Error 2
According to some forms online recommended to check the file in this location ~/usr/include/machine but doesn't say what to do if found or not! nothing else was helpful. Then, I found this http://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/Endian.h
silent:~/usr/include/machine
$ ls
_limits.h _types.h fasttrap_isa.h profile.h vmparam.h
_mcontext.h byte_order.h limits.h signal.h
_param.h `endian.h` param.h types.h
As you can the file I am getting the error for is already existed! Any help would be appreciated. Thank you.
PS: I am newbie, I don't know what is this link above talking about :(!
On OSX and iOS, you can include endian.h this way:
#include <machine/endian.h>
But note that this will fail on Android or Linux because they expect #include <endian.h>.
You can also include sys/types.h, which will include the right endian.h both on iOS/OSX and Android/Linux:
#include <sys/types.h>
You have to tell the c compiler where it can find this file:
export CFLAGS="$CFLAGS -I~/usr/include/machine"
then run make.
Alternatively you can edit the file Makefile to add the -I~/usr/include/machine part where necessary.
Related
Everyone: situation: MacOS with x86_64-w64-mingw32 compiling toolchain I tried to compile GDB for Windows from the source code of GDB. But, after ./configure, I got
/bin/sh ./libtool --tag=CC --mode=link x86_64-w64-mingw32-gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Wno-format -I./../zlib -Iincludedir -D__USE_MINGW_ACCESS -release `cat libtool-soversion` -Llibdir -Wl,--stack,12582912 -o libbfd.la -rpath /usr/local/lib archive.lo archures.lo bfd.lo bfdio.lo bfdwin.lo cache.lo coff-bfd.lo compress.lo corefile.lo elf-properties.lo format.lo hash.lo init.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo binary.lo ihex.lo srec.lo tekhex.lo verilog.lo `cat ofiles` -L./../zlib -lz
./libtool: line 5208: cd: libdir: No such file or directory
libtool: link: cannot determine absolute directory name of `libdir'
make[4]: *** [libbfd.la] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-bfd] Error 2
I am sure my MingW32 is fully built and capable.
x86_64-w64-mingw32-addr2line x86_64-w64-mingw32-dllwrap x86_64-w64-mingw32-gcc-ranlib x86_64-w64-mingw32-ld.bfd x86_64-w64-mingw32-size
x86_64-w64-mingw32-ar x86_64-w64-mingw32-elfedit x86_64-w64-mingw32-gcov x86_64-w64-mingw32-lto-dump x86_64-w64-mingw32-strings
x86_64-w64-mingw32-as x86_64-w64-mingw32-g++ x86_64-w64-mingw32-gcov-dump x86_64-w64-mingw32-nm x86_64-w64-mingw32-strip
x86_64-w64-mingw32-c++ x86_64-w64-mingw32-gcc x86_64-w64-mingw32-gcov-tool x86_64-w64-mingw32-objcopy x86_64-w64-mingw32-windmc
x86_64-w64-mingw32-c++filt x86_64-w64-mingw32-gcc-10.2.0 x86_64-w64-mingw32-gfortran x86_64-w64-mingw32-objdump x86_64-w64-mingw32-windres
x86_64-w64-mingw32-cpp x86_64-w64-mingw32-gcc-ar x86_64-w64-mingw32-gprof x86_64-w64-mingw32-ranlib
x86_64-w64-mingw32-dlltool x86_64-w64-mingw32-gcc-nm x86_64-w64-mingw32-ld x86_64-w64-mingw32-readelf
I install it via HomeBrew And here is the config for libdir in my Makefile
prefix = /usr/local
exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
LDFLAGS = -Llibdir
...
"libdir=$(libdir)" \
...
Totally have no idea how to fix this. Any idea? Or if you need some more information to figure it out, just let me know.
And just download the source code of GDB, I think you could duplicate the same scenario.
./libtool: line 5208: cd: libdir: No such file or directory
libtool: link: cannot determine absolute directory name of `libdir'
make[4]: *** [libbfd.la] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-bfd] Error 2
make: *** [all] Error 2
As the command line and error message say, you give libtool not the right path.
The command line contains -Llibdir and the error message says "cannot determine absolute directory name of 'libdir'".
So you wrote your Makefile to use libdir literally and not as the variable as it should be. Change it into:
LDFLAGS = -L$(libdir)
or
LDFLAGS = -L${libdir}
There is no real difference between parentheses and braces, just don't mix them up. Helpful links are:
The difference between parentheses and curly braces in GNU Make and
What's the difference between parenthesis $() and curly bracket ${} syntax in Makefile?
I am trying to build OpenFOAM from source with MPICH-3.3.2 but got
g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -I -IlnInclude -I. -I/home/pranto/OpenFOAM-dev/src/OpenFOAM/lnInclude -I/home/pranto/OpenFOAM-dev/src/OSspecific/POSIX/lnInclude -fPIC -c PstreamGlobals.C -o /home/pranto/OpenFOAM-dev/platforms/linux64GccDPInt32OptSYSTEMMPI/src/Pstream/mpi/PstreamGlobals.o
UPstream.C:30:17: fatal error: mpi.h: No such file or directory
compilation terminated.
/home/pranto/OpenFOAM-dev/wmake/rules/General/transform:25: recipe for target '/home/pranto/OpenFOAM-dev/platforms/linux64GccDPInt32OptSYSTEMMPI/src/Pstream/mpi/UPstream.o' failed
make[4]: *** [/home/pranto/OpenFOAM-dev/platforms/linux64GccDPInt32OptSYSTEMMPI/src/Pstream/mpi/UPstream.o] Error 1
make[4]: *** Waiting for unfinished jobs....
In file included from PstreamGlobals.C:26:0:
PstreamGlobals.H:41:17: fatal error: mpi.h: No such file or directory
compilation terminated.
In file included from UIPread.C:30:0:
PstreamGlobals.H:41:17: fatal error: mpi.h: No such file or directory
compilation terminated.
Although I set export WM_MPLIB=SYSTEMMPI in etc/bashrc.
But with the OpenMPI everything is ok.
What are the additional settings I have to consider to build OpenFOAM with MPICH-3.3.2?
In the "openfoma/etc" directory, there is a setting file for mpi where you can change the version and the location of the mpich you used. Hope this will help you. By the way, it is not necessary to set the bashrc file.
I am new to postgresql. I want to install postgresql through source code in windows. I am using MinGW and msys for installation. Configure command is working fine with me. When i execute make command I am getting errors. Would any one please help me to rectify these errors.
[gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -I../../../../src/include -I./src/include/port/win32 -DEXEC_BACKEND -I/home/roopteja.itha/openssl/include -I/home/roopteja.itha/uuid "-I../../../../src/include/port/win32" -DBUILDING_DLL -c -o spgtextproc.o spgtextproc.c
In file included from ../../../../src/include/c.h:101:0,
from ../../../../src/include/postgres.h:47,
from spgtextproc.c:40:
../../../../src/include/pg_config_os.h:333:18: error: unknown type name '_locale_t'
#define locale_t _locale_t
^
../../../../src/include/utils/pg_locale.h:69:9: note: in expansion of macro 'locale_t'
typedef locale_t pg_locale_t;
^~~~~~~~
make[4]: *** [spgtextproc.o] Error 1
make[4]: Leaving directory `/home/roopteja.itha/postgresql-9.5.10/src/backend/access/spgist'
make[3]: *** [spgist-recursive] Error 2
make[3]: Leaving directory `/home/roopteja.itha/postgresql-9.5.10/src/backend/access'
make[2]: *** [access-recursive] Error 2
make[2]: Leaving directory `/home/roopteja.itha/postgresql-9.5.10/src/backend'
make[1]: *** [all-backend-recurse] Error 2
make[1]: Leaving directory `/home/roopteja.itha/postgresql-9.5.10/src'
make: *** [all-src-recurse] Error 2]
I am not able resolve this issue. Would anyone suggest necessary implementations.
The 'locale_t' type is defined in xlocale.h. The pg_locale.h has a condition before including xlocale.h One of the conditions might not be satisfied, so your xlocale.h is not included yet. Something like this.
#ifndef _PG_LOCALE_
#define _PG_LOCALE_
#if defined(LOCALE_T_IN_XLOCALE) || defined(WCSTOMBS_L_IN_XLOCALE)
#include <xlocale.h>
#endif
#ifdef USE_ICU
#include <unicode/ucol.h>
#endif
I am trying to configure glibc-2.11.1 using gcc-4.6.1 for kernel 3.16. I am following steps given at http://www.gnu.org/software/libc/manual/html_node/Configuring-and-compiling.html when i am doing make after compiling some file it is giving
make -r PARALLELMFLAGS="" CVSOPTS="" -C ../glibc-2.11.1 objdir=`pwd` all
make[1]: Entering directory `/home/amar/Desktop/glib1/glibc-2.11.1'
make subdir=csu -C csu ..=../ subdir_lib
make[2]: Entering directory `/home/amar/Desktop/glib1/glibc-2.11.1/csu'
gcc /home/amar/Desktop/glib1/gnu/csu/crti.S -c -I../include -I/home/amar/Desktop/glib1/gnu/csu -I/home/amar/Desktop/glib1/gnu -I../sysdeps/i386/elf -I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../sysdeps/unix/sysv/linux/i386/i686 -I../nptl/sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv/i386 -I../nptl/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../nptl/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i686/fpu -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../nptl/sysdeps/i386 -I../sysdeps/i386 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -I../nptl -I.. -I../libio -I. -D_LIBC_REENTRANT -include ../include/libc-symbols.h -DHAVE_INITFINI -DASSEMBLER -I/home/amar/Desktop/glib1/gnu/csu/. -DGAS_SYNTAX -g -Wa,--noexecstack -g0 -o /home/amar/Desktop/glib1/gnu/csu/crti.o
/tmp/ccEB9vct.s: Assembler messages:
/tmp/ccEB9vct.s: Error: open CFI at the end of file; missing .cfi_endproc directive
/tmp/ccEB9vct.s: Error: open CFI at the end of file; missing .cfi_endproc directive
make[2]: *** [/home/amar/Desktop/glib1/gnu/csu/crti.o] Error 1
make[2]: Leaving directory `/home/amar/Desktop/glib1/glibc-2.11.1/csu'
make[1]: *** [csu/subdir_lib] Error 2
make[1]: Leaving directory `/home/amar/Desktop/glib1/glibc-2.11.1'
make: *** [all] Error 2
Why is it so ? How I can rectify this error? Please help me. Thanks in advance
Why is it so ?
The file crti.S that is failing to build is generated by compiling csu/initfini.c, and then splitting the resulting initfini.s on "magic markers".
Unfortunately, this splitting is extremely dependent on the version of gcc that is used to generate initfini.s, and doesn't always work.
This entire mechanism has been eliminated in Feb 2012.
Your options are:
build a newer version of glibc (current is 2.19), or
build using older version of GCC (Google search shows many instances of gcc-4.6 causing this problem).
The following make output is showing an undefined reference, and I am not sure what is causing it. Could someone help?
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/g/workspace/c_cpp/MongoDriverTest'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/mongodrivertest.exe
make[2]: Entering directory `/cygdrive/g/workspace/c_cpp/MongoDriverTest'
mkdir -p build/Debug/Cygwin_4.x-Windows
rm -f build/Debug/Cygwin_4.x-Windows/main.o.d
gcc -std=c99 -c -g -I../mongodb-mongo-c-driver/src/\*.c -MMD -MP -MF build/Debug/Cygwin_4.x-Windows/main.o.d -o build/Debug/Cygwin_4.x-Windows/main.o main.c
mkdir -p dist/Debug/Cygwin_4.x-Windows
gcc -std=c99 -o dist/Debug/Cygwin_4.x-Windows/mongodrivertest build/Debug/Cygwin_4.x-Windows/main.o
nbproject/Makefile-Debug.mk:61: recipe for target `dist/Debug/Cygwin_4.x-Windows/mongodrivertest.exe' failed
make[2]: Leaving directory `/cygdrive/g/workspace/c_cpp/MongoDriverTest'
nbproject/Makefile-Debug.mk:58: recipe for target `.build-conf' failed
make[1]: Leaving directory `/cygdrive/g/workspace/c_cpp/MongoDriverTest'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
build/Debug/Cygwin_4.x-Windows/main.o: In function `main':
/cygdrive/g/workspace/c_cpp/MongoDriverTest/main.c:19: undefined reference to `_mongo_connect'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/Cygwin_4.x-Windows/mongodrivertest.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
And this is the content of my main.c:
#include <stdio.h>
#include <stdlib.h>
#include "../mongodb-mongo-c-driver/src/mongo.h"
int main(int argc, char** argv) {
int status;
mongo conn[1];
status=mongo_connect(conn, "127.0.0.1", 27017);
return EXIT_SUCCESS;
}
It was working two days ago, I reinstalled the OS and now it's not working anymore and I don't seem to find the cause. mongo.h exists, mongo.o is there as well. mongo_connect is in mongo.c. Any idea?
Your link line is:
gcc -std=c99 -o dist/Debug/Cygwin_4.x-Windows/mongodrivertest build/Debug/Cygwin_4.x-Windows/main.o
It doesn't tell GCC where to collect mongo_connect() from. You need to specify the Mongo library on the command line.
Given the include line in your source code:
#include "../mongodb-mongo-c-driver/src/mongo.h"
You might add options:
-L../mongodb-mongo-c-driver/lib -lmongo
to the link line. Both the location and the library name are guesses. That would pick up libmongo.dll or libmongo.lib from the specified directory.
If you can't find the library under the ../mongodb-mongo-c-driver directory, somewhere, you may have to build and install it. Alternatively, it may already be installed and you simply need to ensure you are referencing the correct locations where it is installed.
Also, as a general rule, avoid pathnames like that in the source code. You should specify:
#include "mongo.h"
and supply a compile line option to specify where to look for it:
-I../mongodb-mongo-c-driver/src
See also: What are the benefits of a relative path such as #include "../include/header.h" for a header?.