LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices



Reply
 
Search this Thread
Old 02-24-2009, 05:46 AM   #1
fatmcgav
LQ Newbie
 
Registered: Jan 2007
Posts: 5

Rep: Reputation: 0
Cross Compile x86_64 to i386 - GCC Error


Hi there,

I'm trying to cross compile from x86_64 to i386 on CentOs 5.2.

When I do an rpmbuild, GCC errors with:
Quote:
checking for C compiler default output file name... configure: error: C compiler cannot create executables
The complete Rpmbuild output looks like:
Code:
rpmbuild]$ rpmbuild -ba --target=i386 SPECS/nrpe.spec
Building target platforms: i386
Building for target i386
Executing(%prep): /bin/sh -e /home/gavinw/rpmbuild/tmp/rpm-tmp.72716
+ umask 022
+ cd /home/gavinw/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /home/gavinw/rpmbuild/BUILD
+ rm -rf nrpe-2.12
+ /bin/gzip -dc /home/gavinw/rpmbuild/SOURCES/nrpe-2.12.tar.gz
+ tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd nrpe-2.12
++ /usr/bin/id -u
+ '[' 500 = 0 ']'
++ /usr/bin/id -u
+ '[' 500 = 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /home/gavinw/rpmbuild/tmp/rpm-tmp.72716
+ umask 022
+ cd /home/gavinw/rpmbuild/BUILD
+ cd nrpe-2.12
+ LANG=C
+ export LANG
+ unset DISPLAY
+ export PATH=/sbin:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/gavinw/bin:/usr/sbin
+ PATH=/sbin:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/gavinw/bin:/usr/sbin
+ CFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables'
+ CXXFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables'
+ ./configure --with-init-dir=/etc/init.d --with-nrpe-port=5666 --with-nrpe-user=nagios --with-nrpe-group=nagios --prefix=/usr/local/nagios --exec-prefix=/usr/local/nagios/bin --bindir=/usr/local/nagios/bin --sbindir=/usr/local/nagios/lib/nagios/cgi --libexecdir=/usr/local/nagios/libexec --datadir=/usr/local/nagios/share/nagios --sysconfdir=/usr/local/nagios/etc --localstatedir=/var/log/nagios --enable-command-args
checking for a BSD-compatible install... /usr/bin/install -c
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... configure: error: C compiler cannot create executables
See `config.log' for more details.
error: Bad exit status from /home/gavinw/rpmbuild/tmp/rpm-tmp.72716 (%build)


RPM build errors:
    Bad exit status from /home/gavinw/rpmbuild/tmp/rpm-tmp.72716 (%build)

Config.log shows:
Code:
configure:1821: checking for C compiler default output file name
configure:1824: gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables   conftest.c  >&5
/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status
configure:1827: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
|
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:1866: error: C compiler cannot create executables
See `config.log' for more details.
Any ideas where i'm going wrong???

Cheers
Gavin
 
Old 02-24-2009, 08:25 AM   #2
kentyler
Member
 
Registered: Dec 2008
Location: Cleveland Ohio
Distribution: CentOS
Posts: 235

Rep: Reputation: 36
You need to install glibc-devel packages. Your spec file is broke because it should ask you for this package as it's required.
 
Old 02-24-2009, 10:31 AM   #3
fatmcgav
LQ Newbie
 
Registered: Jan 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by kentyler View Post
You need to install glibc-devel packages. Your spec file is broke because it should ask you for this package as it's required.
Good shout, that enabled me to compile the RPM's...

However i've hit an issue when trying to install/use these RPM's...

It installs correctly, however the files wont execute.

On doing a "file" on one of the files, it gives me:
Quote:
$ file /usr/local/nagios/libexec/check_load
/usr/local/nagios/libexec/check_load: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
So am I right in assuming it hasn't correctly compiled it for i386 rather than x86_64???

Any ideas why?

The spec file looks like:
Code:
### RPM Spec File for Nagios Plugins - Modified by Gavin Williams for ACT usage.
%define _prefix         /usr/local
%define _exec_prefix    /usr/local
%define _sysconfdir     /usr/local/nagios/etc
%define _datadir        /usr/local/share

Name: nagios-plugins
Version: 1.4.13
Release: 1
Summary: Host/service/network monitoring program plugins for Nagios

Group: Applications/System
License: GPL
URL: http://nagiosplug.sourceforge.net/
Source0: http://dl.sf.net/sourceforge/nagiosplug/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Prefix: %{_prefix}/nagios/libexec
Packager: Gavin Williams <gavin.williams@card.co.uk>
Vendor: Nagios Plugin Development Group
Provides: nagios-plugins

%{!?custom:%global custom 0}
Obsoletes: nagios-plugins-custom nagios-plugins-extras


# Requires


%description

Nagios is a program that will monitor hosts and services on your
network, and to email or page you when a problem arises or is
resolved. Nagios runs on a unix server as a background or daemon
process, intermittently running checks on various services that you
specify. The actual service checks are performed by separate "plugin"
programs which return the status of the checks to Nagios. This package
contains those plugins.


%prep
%setup -q

%pre
if getent passwd nagios >/dev/null 2>&1 ;
then : ;
else /usr/sbin/useradd -d /home/nagios -r -s /bin/bash nagios >/dev/null 2>&1 || exit 1 ; fi


%build
./configure \
--prefix=%{_prefix} \
--exec-prefix=%{_exec_prefix} \
--libexecdir=%{_exec_prefix}/nagios/libexec \
--datadir=%{_datadir}
make

%install
rm -rf $RPM_BUILD_ROOT
make AM_INSTALL_PROGRAM_FLAGS="" DESTDIR=${RPM_BUILD_ROOT} install
install -d ${RPM_BUILD_ROOT}
#install -m 664 command.cfg ${RPM_BUILD_ROOT}/etc/nagios
%find_lang %{name}


%clean
rm -rf $RPM_BUILD_ROOT


%files -f %{name}.lang
%defattr(-,nagios,nagios)
#%config(missingok,noreplace) /etc/nagios/command.cfg
%doc CODING COPYING FAQ INSTALL LEGAL README REQUIREMENTS SUPPORT THANKS
%doc ChangeLog
%defattr(775,nagios,nagios)
%dir %{_exec_prefix}
%{_datadir}/locale/de/LC_MESSAGES/nagios-plugins.mo
%{_datadir}/locale/fr/LC_MESSAGES/nagios-plugins.mo
%{_exec_prefix}/nagios/libexec

%changelog
* Mon Dec 29 2008 Gavin Williams <gavin.williams@card.co.uk> - Modified for ACT Usage
* Mon May 23 2005 Sean Finney <seanius@seanius.net> - cvs head
- just include the nagios plugins directory, which will automatically include
  all generated plugins (which keeps the build from failing on systems that
  don't have all build-dependencies for every plugin)
* Tue Mar 04 2004 Karl DeBisschop <karl[AT]debisschop.net> - 1.4.0alpha1
- extensive rewrite to facilitate processing into various distro-compatible specs
* Tue Mar 04 2004 Karl DeBisschop <karl[AT]debisschop.net> - 1.4.0alpha1
- extensive rewrite to facilitate processing into various distro-compatible specs
Any info appreciated.

Regards
Gavin
 
Old 02-26-2009, 03:17 PM   #4
kentyler
Member
 
Registered: Dec 2008
Location: Cleveland Ohio
Distribution: CentOS
Posts: 235

Rep: Reputation: 36
From rpmbuild manpage. You will need to specify the target in either command line or spec file.

--target PLATFORM
When building the package, interpret PLATFORM as arch-vendor-os and set the macros %_target, %_target_cpu, and %_target_os accordingly.
 
Old 02-26-2009, 04:55 PM   #5
fatmcgav
LQ Newbie
 
Registered: Jan 2007
Posts: 5

Original Poster
Rep: Reputation: 0
ken,

cheers for the response, however as per my first post i am specifying the target arch of i386 in the build command... hence the first reason of the post...

anyone else?

cheers
gavin
Quote:
Originally Posted by kentyler View Post
From rpmbuild manpage. You will need to specify the target in either command line or spec file.

--target PLATFORM
When building the package, interpret PLATFORM as arch-vendor-os and set the macros %_target, %_target_cpu, and %_target_os accordingly.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error building cross gcc-3.3.2 for i386-mingw32msvc target ugenn Linux - Software 2 10-05-2012 03:33 AM
Gcc internal error when cross compile kotao_78 Programming 2 09-20-2006 04:20 AM
Errors during the test suite for Glibc-20050926 32 Bit � Cross compile x86_64 Basel Linux From Scratch 3 10-29-2005 07:45 AM
kernel cross-compile(i386 to sparc) jiyun0121 Debian 1 10-20-2005 08:00 AM
i386 compile with fedora-core3 x86_64? markelo Programming 7 04-15-2005 12:59 PM


All times are GMT -5. The time now is 03:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration