LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What is the difference between 32bit library and 64 library? (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-the-difference-between-32bit-library-and-64-library-4175543885/)

444ghost 05-28-2015 03:23 PM

What is the difference between 32bit library and 64 library?
 
Hello guys.

I'm using this library (downloaded at http://wavelet2d.sourceforge.net/). I found out that this library is only working on 32bit systems (http://www.linuxquestions.org/questi...ol-4175543660/).

Now I need to work with the library on a 64 system. I thought libraries are just a group of pure object codes so I honestly didn't expect to face this kind of problems.

If you could help me understand why this is and how I can make 64bit libraries from the same source codes that made the 32bit library (perhaps where I should more look into or something, I'm NOT asking you for 100% answers if I'm annoying you by any means), then that would be great.

I'd appreciate your help.

Thank you.

yooy 05-28-2015 03:53 PM

you run into compatility issue.. in future perhaps 64bit systems will have similar functionality as 32 bit sistems.

hope you are using latest packages.

if you can afford you can make 32bit installation to usb flash or disk, or if you are on ubuntu make usb key with unetbootin and leave some space for saved data..

suicidaleggroll 05-28-2015 04:01 PM

The pre-compiled libraries in that download were compiled for 32-bit. If you want 64-bit libraries, you'll have to recompile the provided source code with a 64-bit compiler. See here:
http://www.adp-gmbh.ch/cpp/gcc/create_lib.html

444ghost 05-28-2015 04:19 PM

Quote:

Originally Posted by yooy (Post 5368986)
you run into compatility issue.. in future perhaps 64bit systems will have similar functionality as 32 bit sistems.

hope you are using latest packages.

if you can afford you can make 32bit installation to usb flash or disk, or if you are on ubuntu make usb key with unetbootin and leave some space for saved data..

I'm also working on other VMs that are based on 64 bit. I'm trying to make one combined VM so working on 32 bit system won't really work for me. But just for the sake of its stability, I tried this out on a 32 bit system and it worked well. Thank you for the reply:D

444ghost 05-28-2015 04:27 PM

Quote:

Originally Posted by suicidaleggroll (Post 5368990)
The pre-compiled libraries in that download were compiled for 32-bit. If you want 64-bit libraries, you'll have to recompile the provided source code with a 64-bit compiler. See here:
http://www.adp-gmbh.ch/cpp/gcc/create_lib.html

Code:

g++ -Wall -c wavelet2s.cpp // compiling

ar rcs libwavelet2s.a wavelet2s.o // linking the wavelet object with the library

g++ -static wavedemo1.cpp -L. -lwavelet2s -o wavedemo1 // compiling

This is what I tried on my 64 bit system. I checked out your link but there is not much difference between that and my approach (correct me if I'm wrong). You said I need to recompile using 64 compiler and I found this link (http://stackoverflow.com/questions/1...64-bit-machine), I might try a couple of things in that link and see if I have more questions, thank you for the reply:D

suicidaleggroll 05-28-2015 04:31 PM

Quote:

Originally Posted by 444ghost (Post 5369004)
Code:

g++ -Wall -c wavelet2s.cpp // compiling

ar rcs libwavelet2s.a wavelet2s.o // linking the wavelet object with the library

g++ -static wavedemo1.cpp -L. -lwavelet2s -o wavedemo1 // compiling

This is what I tried on my 64 bit system. I checked out your link but there is not much difference between that and my approach (correct me if I'm wrong).

Yes that seems fine

Quote:

Originally Posted by 444ghost (Post 5369004)
You said I need to recompile using 64 compiler and I found this link (http://stackoverflow.com/questions/1...64-bit-machine), I might try a couple of things in that link and see if I have more questions, thank you for the reply:D

Since you're on a 64-bit system, gcc is your 64-bit compiler. No flags are needed to force it to build a 64-bit binary, that's the default.

On a 32-bit system, "gcc file.c" will build a 32-bit binary
On a 64-bit system, "gcc file.c" will build a 64-bit binary, while "gcc -m32 file.c" will build a 32-bit binary

32-bit systems can only run 32-bit code, 64-bit systems can run both 32 and 64-bit code (usually, there are a few exceptions but they're rare).

suicidaleggroll 05-28-2015 04:34 PM

Quote:

Originally Posted by yooy (Post 5368986)
you run into compatility issue.. in future perhaps 64bit systems will have similar functionality as 32 bit sistems.

Future? What future? If this was a necro-post from 2002 then maybe I'd agree with you. 64-bit Linux systems have had as much or more functionality than 32-bit Linux systems for nearly a decade.

Quote:

Originally Posted by yooy (Post 5368986)
if you can afford you can make 32bit installation to usb flash or disk, or if you are on ubuntu make usb key with unetbootin and leave some space for saved data..

There is absolutely no need to set up a standalone 32-bit system on an external USB drive to build or run 32-bit code...especially not something that he can just recompile for his architecture.

444ghost 05-28-2015 04:42 PM

Quote:

Originally Posted by suicidaleggroll (Post 5369006)
Yes that seems fine


Since you're on a 64-bit system, gcc is your 64-bit compiler. No flags are needed to force it to build a 64-bit binary, that's the default.

On a 32-bit system, "gcc file.c" will build a 32-bit binary
On a 64-bit system, "gcc file.c" will build a 64-bit binary, while "gcc -m32 file.c" will build a 32-bit binary

32-bit systems can only run 32-bit code, 64-bit systems can run both 32 and 64-bit code (usually, there are a few exceptions but they're rare).

It's weird that I ran the same g++/gcc compiler on a 64 system and gives me some errors, that wavelet library also needs to work with fftw library (http://www.fftw.org/), perhaps I also need to take a second look at that library (fftw) as well for being 32 bit or 64 bit compatible. I'm not at school right now but I'll try a few things more first in the morning tomorrow and see if I have more questions. Again, I'd appreciate your help/comments.

SCSIraidGURU 05-28-2015 04:46 PM

From a programming standpoint, I try to use only 32-bit libraries and 32-bit coding practices. I found 64-bit causes nothing but headaches. You can run 32-bit apps in 64-bit OS just fine. Most apps don't require more than 2 GB of RAM to run. My most complex C# code don't usually hit 200 MB of RAM. So the 2GB 32-bit limit for single apps never comes into play. I program in Microsoft Visual Studio for Windows and the Linux version. Both have x86 and 64bit modes for C# and VB. CAD and A/V apps like Photoshop can use more than 2GB of RAM for processing. Most games are 32-bit because they run on the GPU not the local RAM and CPU. I have seen more of my 64-bit code crash than the 32-bit code.

444ghost 05-28-2015 04:52 PM

Quote:

Originally Posted by SCSIraidGURU (Post 5369013)
From a programming standpoint, I try to use only 32-bit libraries and 32-bit coding practices. I found 64-bit causes nothing but headaches. You can run 32-bit apps in 64-bit OS just fine. Most apps don't require more than 2 GB of RAM to run. My most complex C# code don't usually hit 200 MB of RAM. So the 2GB 32-bit limit for single apps never comes into play. I program in Microsoft Visual Studio for Windows and the Linux version. Both have x86 and 64bit modes for C# and VB. CAD and A/V apps like Photoshop can use more than 2GB of RAM for processing. Most games are 32-bit because they run on the GPU not the local RAM and CPU. I have seen more of my 64-bit code crash than the 32-bit code.

I suppose I can just make 32 bit executable files and copy those on 64 bit systems and run. I thought of this before and now you are reminding me again, I'll definitely try this out tomorrow. Thank you for the reply.

suicidaleggroll 05-28-2015 04:57 PM

Quote:

Originally Posted by SCSIraidGURU (Post 5369013)
From a programming standpoint, I try to use only 32-bit libraries and 32-bit coding practices. I found 64-bit causes nothing but headaches. You can run 32-bit apps in 64-bit OS just fine. Most apps don't require more than 2 GB of RAM to run. My most complex C# code don't usually hit 200 MB of RAM. So the 2GB 32-bit limit for single apps never comes into play. I program in Microsoft Visual Studio for Windows and the Linux version. Both have x86 and 64bit modes for C# and VB. CAD and A/V apps like Photoshop can use more than 2GB of RAM for processing. Most games are 32-bit because they run on the GPU not the local RAM and CPU. I have seen more of my 64-bit code crash than the 32-bit code.

If your 64-bit code is crashing, then you're doing something wrong. I've seen people just assume that pointers are always 32-bits and they bounce back and forth between pointer and 32-bit ints like they're equivalent. This will work on 32-bit, it'll fail catastrophically on 64-bit.

32-bit code also runs slower on a 64-bit machine, sometimes significantly so. If you need to stick with 32-bit for compatibility with 32-bit systems that's fine, but doing it because your programs are crashing in 64-bit means you're really screwing up somewhere.

It's not always about RAM usage either. The standard 32-bit I/O libraries can't read or write files larger than 4 GB for example, even if you're never loading that much data into RAM at once.

suicidaleggroll 05-28-2015 05:00 PM

Quote:

Originally Posted by 444ghost (Post 5369011)
It's weird that I ran the same g++/gcc compiler on a 64 system and gives me some errors, that wavelet library also needs to work with fftw library (http://www.fftw.org/), perhaps I also need to take a second look at that library (fftw) as well for being 32 bit or 64 bit compatible. I'm not at school right now but I'll try a few things more first in the morning tomorrow and see if I have more questions. Again, I'd appreciate your help/comments.

It would help if you posted the errors. If you're referring to your previous thread, you were trying to build the example code in 64-bit while using the 32-bit wavelet library. That will clearly fail. If you recompile the library in 64-bit, and then build the example code in 64-bit, it should be fine.

It's not about "supporting" one architecture or another, you just need to match it up. If you want to build the example code in 64-bit, then you need to have the 64-bit version of all of the required libraries. If you want to build the example code in 32-bit, then you need to have the 32-bit version of all of the required libraries. That's all.

You should have the option to install the 32 or 64-bit (or both) version of fftw on your system. For example, here are the fftw package options on CentOS 7 (trimmed a bit for simplicity):
Code:

# yum list | grep fftw
fftw.i686                            3.3.3-8.el7              @base           
fftw.x86_64                          3.3.3-8.el7              @base           
fftw-devel.i686                      3.3.3-8.el7              @base           
fftw-devel.x86_64                    3.3.3-8.el7              @base           
fftw-static.i686                      3.3.3-8.el7              @base           
fftw-static.x86_64                    3.3.3-8.el7              @base

i686 is the 32-bit version, x86_64 is the 64-bit version, you just install the one(s) you need.

444ghost 05-28-2015 05:06 PM

Quote:

Originally Posted by suicidaleggroll (Post 5369023)
It would help if you posted the errors. If you're referring to your previous thread, you were trying to build the example code in 64-bit while using the 32-bit wavelet library. That will clearly fail. If you recompile the library in 64-bit, and then build the example code in 64-bit, it should be fine. You should have the option to install the 32 or 64-bit (or both) version of fftw on your system, provided you're running a system that supports multilib (most do, some don't, at least not well).

I believe I tried to recompile the library on a 64 system (not referring to my previous thread), but I'll double-check and try to troubleshoot by myself a little bit more tomorrow and ask more questions if I seem to have one.

suicidaleggroll 05-28-2015 05:27 PM

Quote:

Originally Posted by 444ghost (Post 5369024)
I believe I tried to recompile the library on a 64 system (not referring to my previous thread), but I'll double-check and try to troubleshoot by myself a little bit more tomorrow and ask more questions if I seem to have one.

Working fine for me. Here's what I did:

1) Change wavedemo1.cpp to use wavelet2s.h instead of wavelet2d.h

2) Go to the src/static directory

3) Rebuild the library in 64-bit:
g++ -static -c wavelet2s.cpp
ar rcs libwavelet2s64.a wavelet2s.o
cp libwavelet2s64.a ../../linuxstatic/

4) Go to the examples directory

5) 32-bit build command:
g++ -m32 -static -L../linuxstatic -I../linuxstatic wavedemo1.cpp -lwavelet2s -lfftw3 -o wavedemo1-32

6) 64-bit build command:
g++ -static -L../linuxstatic -I../linuxstatic wavedemo1.cpp -lwavelet2s64 -lfftw3 -o wavedemo1-64

Both wavedemo1-32 and wavedemo1-64 run without error. I'm not sure what the outputs mean, but recon.txt and diff.txt are identical between the 32 and 64-bit versions. dwtout.txt does differ, not sure if that's significant.

444ghost 05-29-2015 09:52 AM

Quote:

Originally Posted by suicidaleggroll (Post 5369034)
Working fine for me. Here's what I did:

1) Change wavedemo1.cpp to use wavelet2s.h instead of wavelet2d.h

2) Go to the src/static directory

3) Rebuild the library in 64-bit:
g++ -static -c wavelet2s.cpp
ar rcs libwavelet2s64.a wavelet2s.o
cp libwavelet2s64.a ../../linuxstatic/

4) Go to the examples directory

5) 32-bit build command:
g++ -m32 -static -L../linuxstatic -I../linuxstatic wavedemo1.cpp -lwavelet2s -lfftw3 -o wavedemo1-32

6) 64-bit build command:
g++ -static -L../linuxstatic -I../linuxstatic wavedemo1.cpp -lwavelet2s64 -lfftw3 -o wavedemo1-64

Both wavedemo1-32 and wavedemo1-64 run without error. I'm not sure what the outputs mean, but recon.txt and diff.txt are identical between the 32 and 64-bit versions. dwtout.txt does differ, not sure if that's significant.

It worked really great! Thank you so much for helping me get a better understanding in this!


All times are GMT -5. The time now is 08:10 PM.