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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux