Compiling vsftpd 3.0.0 is failing - c

I recently tried to compile vsftpd 3.0.0 but it fails due the following compile error:
gcc -c seccompsandbox.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W - Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2 -idirafter dummyinc
seccompsandbox.c:63: error: ‘O_DIRECTORY’ undeclared here (not in a function)
seccompsandbox.c:63: error: ‘O_CLOEXEC’ undeclared here (not in a function)
make: *** [seccompsandbox.o] Error 1
As I'm not very familar with the source and the environment I have no idea how to fix this. I imagine that it has something to do with the new seccomp filter sandbox. A Search on google showed me that the error is reproducible but no solution was submitted.
My linux kernel version is 2.6.32-5-amd64 and I'm using gcc version 4.4.5 (Debian 4.4.5-8)
Any ideas welcome.
(If you need additional information's don't hesitate to ask)

At least on Debian O_DIRECTORY and O_CLOEXEC are defined only if _GNU_SOURCE is defined.
Although _GNU_SOURCE is set for certain modules in the current vsftp release it is not set generally.
As a work around you might use the following patch:
diff -Naur vsftpd-3.0.0.orig/seccompsandbox.c vsftpd-3.0.0/seccompsandbox.c
--- vsftpd-3.0.0.orig/seccompsandbox.c 2012-04-05 00:41:51.000000000 +0200
+++ vsftpd-3.0.0/seccompsandbox.c 2012-06-30 15:25:52.000000000 +0200
## -11,7 +11,7 ##
#include "seccompsandbox.h"
#if defined(__linux__) && defined(__x86_64__)
-
+#define _GNU_SOURCE
#include "session.h"
#include "sysutil.h"
#include "tunables.h
Disclaimer: Applying this patch makes the current vsftp release compile, I have now clue wether the created binaries work correctly or not.

I'm using SLES 11 sp1 64bit, kernel 2.6.32, gcc ver 4.3.4; changing or removing FORTIFY_SOURCE made no difference, get same error. I'm not a c programmer - the flags O_DIRECTORY and O_CLOEXEC are in seccompsandbox.c:
static const int kOpenFlags =
O_CREAT|O_EXCL|O_APPEND|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_LARGEFILE;
It compiles if you remove them but that really fills me with confidence....
The vrf_findlibs.sh is also broken, I had to rejig the script so it found a 64bit version of libcap first or it keeps selecting the 32bit copy (the -lcap doesn't work either, says it isn't found):
# Look for libcap (capabilities)
if locate_library /lib64/libcap.so; then
echo "/lib64/libcap.so.2";
elif locate_library /lib/libcap.so.1; then
echo "/lib/libcap.so.1";
elif locate_library /lib/libcap.so.2; then
echo "/lib/libcap.so.2";
else
locate_library /usr/lib/libcap.so && echo "-lcap";
locate_library /lib/libcap.so && echo "-lcap";
locate_library /lib64/libcap.so && echo "-lcap";
fi

Related

"error: implicitly declaring library function 'exit' with type" when configuring NetCDF on Mac

I need to compile the following project on a mac: cost733clas-1.4_rev23.tgz (download link)
The problem is, I have never worked with fortran or C and for the most part just worked with IDE's which took care of everything ...
Using the project guide I found out, that I need a fortran90 and a C compiler. Compilation using gcc worked up to a point, but at some point it fails on a sub-package/dependency (netcdf).
...
checking nm flags...
checking for C-equivalent to Fortran routine "SUB"... sub_
checking for Fortran "byte"... yes
checking for Fortran "integer*2"... yes
checking if Fortran "byte" is C "signed char"... configure: error: Could not compile conftest.c
configure: error: ./configure failed for netcdf-4.0.1
content of config.log:
configure:25351: gfortran -c -g -O2 conftest.f
configure:25354: $? = 0
configure:25356: result: yes
configure:25374: checking for Fortran "integer*2"
configure:25382: gfortran -c -g -O2 conftest.f
configure:25385: $? = 0
configure:25387: result: yes
configure:25414: checking if Fortran "byte" is C "signed char"
configure:25424: gcc -c -g -O2 conftest.c
conftest.c:4:3: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
exit(values[1] != -2 || values[2] != -3);
^
conftest.c:4:3: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
1 error generated.
configure:25427: $? = 1
configure:25468: error: Could not compile conftest.c
Does anyone have any suggestions on what compiler I should try/what flags I should use? (and how to set them)
the solution to my problem was to use linux instead of mac, i'm not quite sure what went wrong on mac, but creating a virutal linux machine and doing the same there works just fine.
for people who want to create a virtual machine some useful links:
https://www.virtualbox.org/wiki/Downloads
https://askubuntu.com/questions/413594/what-does-no-bootable-medium-found-mean-in-virtualbox
https://www.osboxes.org/ubuntu/#ubuntu-21-04-info
https://www.how2shout.com/linux/how-to-install-brew-ubuntu-20-04-lts-linux/

configure: error: C compiler cannot create executables - Mac Sierra

I know these have been posted before, but I'm stuck and can't seem to get anywhere, even by reading copious responses to similar issues to mine.
I get the dreaded "C compiler cannot..." from the title of this post.
I'm on macOS Sierra (long story as to why I'm behind), and have XCode CLT 9.2 installed. I ditched the full XCode app and just went down to the CLT - installed from the Dev area.
Otherwise, I have the latest Homebrew, GCC, Dialog, Libtool, and Automake/Autoconf - some were pre-reqs for the LIRC system I'm trying to get compiled and installed (IR subsystem).
brew config shows that it properly sees the correct XCode CLT, so my guess is that that part is ok.
I get errors once I run the ./configure for this system I'm trying to get up and running...here's the output:
Configuration: .setup.config, executable shell script: configure.sh
Starting the generated shell script which will call configure with the right
parameters...
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Volumes/Macintosh HD Giant/Users/Nidocamen/Downloads/LIRC-port-for-Mac-OS-X-master':
configure: error: C compiler cannot create executables
See `config.log' for more details
Thought it could be a permissions issue on the LIRC folder, but it's accessible.
I put in a symlink to ensure that gcc is running gcc-9 in /usr/local/bin and ensured that that path is before /usr/bin (brew doctor isn't complaining about that anymore).
Anyways, I'm otherwise really not sure what's causing this to fail. I've been a developer before, but more on the web app side of things and not at this level.
If anyone has some suggestions, I'd love to hear them...thanks! :)
UPDATE - here's some output from the log that would appear to narrow this down. While the people who created this install claims it works well on recent macOS version, it seems like some of the code used is really outdated and that could be why it's not compiling.
Configured with: ../configure --build=x86_64-apple-darwin16 --prefix=/usr/local/Cellar/gcc/9.2.0 --libdir=/usr/local/Cellar/gcc/9.2.0/lib/gcc/9 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 9.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues
Thread model: posix
gcc version 9.2.0 (Homebrew GCC 9.2.0)
configure:3322: $? = 0
configure:3311: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3322: $? = 1
configure:3311: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:3322: $? = 1
configure:3342: checking whether the C compiler works
configure:3364: gcc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 conftest.c >&5
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
configure:3368: $? = 1
configure:3406: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "lirc"
| #define VERSION "0.9.1-git"
| /* end confdefs.h. */
I had a similar issue, and in my case the "library not found for -lSystem" was caused by a line in my .bash_profile
alias openclc=/System/Library/Frameworks/OpenCL.framework/Libraries/openclc
No idea why I had put that in there, but unalias-ing it fixed my issues...

Resolve TCC warnings on macOS

I'm looking for a C interpreter to use while making a simple C utility to avoid compiling all the time. I installed TCC as suggested here but I get warnings and errors. How do I run TCC correctly?
$ tcc -run hello.c
.../usr/include/sys/cdefs.h:81: warning: #warning "Unsupported compiler detected"
#if !defined(__GNUC__) || __GNUC__ < 4
#warning "Unsupported compiler detected"
#endif
Setting __GNUC__ causes an error later on:
tcc -D__GNUC__=4 -run hello.c
.../usr/include/i386/_types.h:98: error: ';' expected (got "__darwin_va_list")
#if (__GNUC__ > 2)
typedef __builtin_va_list __darwin_va_list; /* va_list */
#else
typedef void * __darwin_va_list; /* va_list */
#endif
My environment:
~$ gcc --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
If TCC is not fit for macOS, please suggest a C interpreter that plays nicely.
For sure one that will work is CERN's Cling or any other based on LLVM/Clang, since that is what Apple uses in macOS.
The block comment immediately above the line your first message complains about is
/* This SDK is designed to work with clang and specific versions of
* gcc >= 4.0 with Apple's patch sets */
#if !defined(__GNUC__) || __GNUC__ < 4
#warning "Unsupported compiler detected"
#endif
which is pretty clear - you do need gcc or clang. Fortunately both of those compilers are really easy to install - use https://www.macports.org.
I wouldn't bother with a C interpreter - it's not an interpreted language.
First of all, tcc is not an "interpreter" it is a very fast compiler that can be used to compile and run your C code as if it were script.
Secondly, the "Unsupported compiler detected" warning is just that, a warning. I get that warning all the time and my code still compiles and runs no problem. If the warning bothers you, you can simply run tcc with the -w option to suppress the warnings (probably only advisable if you are re-running a file that you already know has no issues).
For example, if you are running the C code as if it's a script using the tcc shebang line, you can change it to this
#!/usr/local/bin/tcc -w -run
There can be a couple of other issues when running tcc on macOS. The main one is missing include files. On macOS the include files may not be installed to /usr/include/. See this question for the fix. Once Xcode had properly installed the headers, I still needed to update my environment variable to get tcc to find them.
export C_INCLUDE_PATH="/usr/include:$C_INCLUDE_PATH"
You can see where tcc is looking for header by running tcc -vv.

gcc creates a different folder base on its version

When I try to rpmbuild something I got this error message
checking for x86_64-redhat-linux-gcc... no
checking for gcc... no
checking for x86_64-redhat-linux-cc... no
checking for cc... no
checking for x86_64-redhat-linux-cl.exe... no
checking for cl.exe... no
And I found out that, the tool are in /usr/bin/gcc48 what I did is link the gcc48 to gcc folder: Which I got the idea from this link https://stackoverflow.com/a/13327320/612920
ln /usr/bin/gcc48 /usr/bin/gcc
And when I tried to run rpmbuild again I got this error message:
checking for x86_64-redhat-linux-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/usr/src/rpm/BUILD/courier-unicode-1.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
error: Bad exit status from /var/tmp/rpm-tmp.jrbnrw (%prep)
What is wrong? I had already installed all development tools and its on its latest versions. Can Somebody help me?
And by the way I am using Amazons Redhat (gcc version 4.8.2 20131212 (Red Hat 4.8.2-7) (GCC))
UPDATED:
config.log
configure:3499: $? = 0
configure:3488: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-amazon-linux/4.8.2/lto-wrapper
Target: x86_64-amazon-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugu$
Thread model: posix
gcc version 4.8.2 20131212 (Red Hat 4.8.2-7) (GCC)
configure:3499: $? = 0
configure:3488: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3499: $? = 4
configure:3488: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'
gcc: fatal error: no input files
compilation terminated.
configure:3499: $? = 4
configure:3519: checking whether the C compiler works
configure:3541: gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp$
collect2: fatal error: cannot find 'ld'
compilation terminated.
configure:3545: $? = 1
configure:3583: result: no
configure: failed program was:
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3588: error: in `/home/falko/rpm/BUILD/courier-unicode-1.1':
configure:3590: error: C compiler cannot create executables
gcc is one of a number of tools required to build a software package, and as you can see from the error in your config.log, some more are missing from your system:
collect2: fatal error: cannot find 'ld'
It is complaining that it cannot find the system linker (ld).
Before addressing this, I recommend you set the gcc version to be used correctly. Unfortunately the advice you followed from https://stackoverflow.com/a/13327320/612920 is somewhat incomplete.
Redhat based systems provide a mechanism for being able to switch between different implementations of a piece of software at will (for example, different versions). This tool is called alternatives. You should use that to set the GCC version that will be used when you run 'gcc' at the command line. It will update a whole set of symlinks, not just the one you manually set.
sudo alternatives --config gcc
After doing this set the linker to be used:
sudo alternatives --config ld
Note that when I've tried out an AMI linux image, I found that by installing gcc like this:
sudo yum install gcc48
it automatically set the correct 'alternatives' for the newly installed compiler and corresponding linker. I'm not sure how your system got into the state that it is currently in, but if you still have problems after the above procedure, I recommend uninstalling and re-installing gcc and binutils.
After a couple of research I had found out that I am just lacking of ld(GNU linker) tool from RedHat's developer tool set and I also found out that there is an alternative tool just in case ld(GNU linker) is not available, ld.bfd(alternative to the GNU linker) which is in my case it is available. What I did, I make a link from ld.bfd to ld:
ln /usr/bin/ld.bfd /usr/bin/ld
I don't know if it is the proper solution but it works for me.
Reference: Red_Hat_Developer_Toolset

How do I patch libxml2 so it will compile with ICU support when using a prefix?

I'm trying to fix a bug in libxml2. I cannot get it to compile with --with-icu when using --prefix=/Server/software. I have submitted a bug report here, but I need to get it to compile for resolving a conflict when compiling PHP with intl support. I suspect it's a problem with the Makefile. My experience with Makefile's is limited. The desired result is coming up with a patch that can be submitted to the linked bug report.
The --with-icu flag causes LIBXML_ICU_ENABLED to be defined. The included code is supposed to resolve a conflict when including headers from both icu and libxml2 (specifically, both use UChar). The PHP plugin intl, activated with --enable-intl, requires icu. libxml2 is needed by PHP for DOM/XML functions.
There are two problems.
First, this config:
./configure --prefix=/Server/software --enable-shared --enable-static --with-icu
Results in:
configure: error: libicu config program icu-config not found
This happens because of this code in configure.in:
WITH_ICU=0
if test "$with_icu" != "yes" ; then
echo Disabling ICU support
else
ICU_CONFIG=icu-config
if ${ICU_CONFIG} --cflags >/dev/null 2>&1
then
ICU_LIBS=`icu-config --ldflags`
LDFLAGS="$LDFLAGS $ICU_LIBS"
WITH_ICU=1
echo Enabling ICU support
else
AC_MSG_ERROR([libicu config program icu-config not found])
fi
fi
Specifically ICUCONFIG=icu-config isn't respecting --prefix=/Server/software. I can work around this by doing export PATH=/Server/software/bin:$PATH.
This "fixes" the ./configure problem.
Second, when I run make I get errors, the most relavent being:
./include/libxml/encoding.h:31:26: error: unicode/ucnv.h: No such file or
directory
The unicode/uncv.h file is in /Server/software/include/unicode/uncv.h. I suspect the compiler is looking for this file in the local directory and in my /usr directory.
This is what the error is referring to:
#ifdef LIBXML_ICU_ENABLED
#include <unicode/ucnv.h>
#endif
Clearly this is a path issue when using --with-icu and --prefix=/Server/software. Without --with-icu it compiles fine, but this is needed to resolve a define UChar conflict when compiling PHP with both icu and libxml2.
The result of icu-config --cflags is:
-O2 -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long
This is being piped into /dev/null.
The result of icu-config --ldflags is:
-lpthread -lm -L/Server/software/lib -licui18n -licuuc -licudata -lpthread -lm
What needs to be changed to resolve these issues?
So, take a look at where it's using icu-config. It should be doing something like icu-config --cppflags which should set -I/Server/Software/include or similar. You could work around it by setting CPPFLAGS to include such a parameter yourself.
Can you include the actual compile command line immediately before the error?
Sounds like a bug in libxml - it ought to search ${PREFIX}/bin for icu-config.
Also, ICU now exports pkg-config files, which are more of a standard way to find such items.
Try this before WITH_ICU :
ICU_CPPFLAGS=`icu-config --cppflags`
CPPFLAGS="$CPPFLAGS $ICU_CPPFLAGS"
update I'm going to quote Luke's last response. Glad it's working.
I solved the linker problems, so now it all works. For this question
using libxml 2.7.7 was the solution. It seems OX X 10.6 ships with
2.7.8. So for it to work you have to compile libxml2 yourself with 2.7.7. The linker problems are solved by adding LIBS="-lresolv -lstdc++" just before PHP's ./configure. If installing to a non-standard location you also need to compile ICU with
--enable-rpath. I've accepted your answer. Feel free to update it with this information :). – Luke 17 hours ago

Resources