This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

compiling a 64-bit program with g++ for Solaris


 
Hi,
 
I've used g++ for a couple years now but am now contemplating writing
some 64-bit executables. As a simple test, I wrote the following:

#include <iostream>

int main()
{
	int a = 4;
	long b = 7;
	std::cout<<sizeof(a)<<"\t"<<sizeof(b)<<"\n";
}


I then compiled using g++ 3.4.1 on a Solaris machine:
SunOS sde2 5.7 Generic_106541-42 sun4u sparc SUNW,Ultra-4

I will be using various Solaris machines and OS's.

When I compile using:

g++ test.cpp -o test

I get the expected output of 4 bytes for each variable. When I compile
with:

g++ -m64 test.cpp -o test

and then execute it I get:

ld.so.1: test: fatal: /usr/local/lib/libstdc++.so.6: wrong ELF class:
ELFCLASS32
Killed

I assume this is because the C++ library was built for 32-bit. Is it
easy to rebuild the library for 64-bit and have both versions available
for linking? Are there other compiler/linker options I should be using?
Any FAQs or help would be appreciated.

thanks,
matthew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]