6

I'm making my first steps on the linux platform. I've installed Centos x64. I'm attempting to build a small program with a couple of functions and a couple of unit tests.

I'm using Netbeans 7.1.2 as the development environment.

Here is the output from the build process:

CLEAN SUCCESSFUL (total time: 671ms)

"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/home/john/Dev/GoatsCheese'
"/usr/bin/gmake"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/goatscheese
gmake[2]: Entering directory `/home/john/Dev/GoatsCheese'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -m32   -c -g -I/usr/include/cppunit -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -m32    -o dist/Debug/GNU-Linux-x86/goatscheese build/Debug/GNU-Linux-x86/main.o  
/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status

The compiler is set to create a 32-bit executable, but I shouldn't think that would be a problem (32 bit executables can be created on an x64 platform on Windows - the platform I'm familiar with).

Locate finds the crt1.o file in the following places:

locate crt1.o
/usr/lib64/Mcrt1.o
/usr/lib64/Scrt1.o
/usr/lib64/crt1.o
/usr/lib64/gcrt1.o

I'm not sure if I'm missing a package or if I should create a symlink.

fishfood
  • 4,092
  • 4
  • 28
  • 35

3 Answers3

12

You need to install the 32-bit standard C library development package. It's probably named something like libc6-dev-i386.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
2

I think ld was looking for 32-bit crt1.o but you only have 64-bit version.

0

The problem you can't find the crt1.o is probably because you are missing one of the library specifier options. I am not familiar with Netbeans, but you should add the /usr/lib64. Somewhere in the g++ command line it should look like: "-L /usr/lib64".

NB: It's a thinking flaw to assume that because it works on Windows that way, other platforms with same CPU will behave the same way. This doesn't sound right.

I would suggest you build in 32bit binaries with 32bit library, and build 64bit binaries linked to 64bit library.

Daniel Baktiar
  • 1,692
  • 11
  • 22
  • I don't agree with you. Windows can build x64 or x86 executables on either platform. It follows that the linux platform should also be capable of this. – fishfood May 28 '12 at 13:26
  • Again, it's not that Linux platform is not capable. It is not safe to assume that. Linux is a platform, not a development tools (compiler/linker). So when you make a statement, you should mention which development tools (compiler/linker) you are referring to. It's development tools (e.g. Visual Studio), not Windows that is capable of 32bit and 64bit binaries. Other tools may not be capable of. In Linux you can even generate Windows binaries through cross-compiling because of the development tool is capable of doing that. – Daniel Baktiar Jun 03 '12 at 17:11